Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #17 from plone/active-auth-key
Browse files Browse the repository at this point in the history
rename auth plugins list, it is not a key
  • Loading branch information
bloodbare committed Nov 19, 2016
2 parents a433439 + f250679 commit 10a44a9
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/plone.server/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Creating default content
Once started, you will require to add at least a Plone site to start fiddling around::

curl -X POST -H "Accept: application/json" -H "Authorization: Basic YWRtaW4=" -H "Content-Type: application/json" -d '{
"@type": "Plone Site",
"@type": "Site",
"title": "Plone 1",
"id": "plone",
"description": "Description"
Expand Down
4 changes: 2 additions & 2 deletions src/plone.server/plone/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
DEFAULT_PERMISSION = []
AVAILABLE_ADDONS = {}
JSON_API_DEFINITION = {}
ACTIVE_AUTH_EXTRACTION_KEY = []
ACTIVE_AUTH_USER_KEY = []
AUTH_EXTRACTION_PLUGINS = []
AUTH_USER_PLUGINS = []
CORS = {}

SCHEMA_CACHE = {}
Expand Down
2 changes: 1 addition & 1 deletion src/plone.server/plone/server/api/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async def __call__(self):
'title': data['title']
}
headers = {
'Location': '/plone/ttt'
'Location': self.request.path + data['id']
}

return Response(response=resp, headers=headers)
Expand Down
10 changes: 4 additions & 6 deletions src/plone.server/plone/server/auth/participation.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-
from plone.server.interfaces import IRegistry
from plone.server.interfaces import IRequest
from plone.server import ACTIVE_AUTH_EXTRACTION_KEY
from plone.server import ACTIVE_AUTH_USER_KEY
from plone.server import AUTH_EXTRACTION_PLUGINS
from plone.server import AUTH_USER_PLUGINS
from plone.server.transactions import get_current_request
from plone.server.utils import import_class
from zope.component import adapter
from zope.interface import implementer
from zope.security.interfaces import IParticipation
Expand Down Expand Up @@ -72,10 +70,10 @@ async def __call__(self):
# Cached user
if not hasattr(self.request, '_cache_user'):

for plugin in ACTIVE_AUTH_EXTRACTION_KEY:
for plugin in AUTH_EXTRACTION_PLUGINS:
await plugin(self.request).extract_user()

for plugin in ACTIVE_AUTH_USER_KEY:
for plugin in AUTH_USER_PLUGINS:
await plugin(self.request).create_user()

self.principal = getattr(self.request, '_cache_user', None)
Expand Down
4 changes: 3 additions & 1 deletion src/plone.server/plone/server/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def __repr__(self):

def createContent(type_, **kw):
"""Utility to create a content.
This method should not be used to add content, just internally.
"""
factory = getCachedFactory(type_)
Expand Down Expand Up @@ -185,6 +185,8 @@ def createContentInContainer(container, type_, id_, request=None, **kw):
obj.__name__ = id_
obj.__parent__ = container
container[id_] = obj
if 'id' not in kw:
kw['id'] = id_
for key, value in kw.items():
setattr(obj, key, value)
return obj
Expand Down
4 changes: 2 additions & 2 deletions src/plone.server/plone/server/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ def tearDown(cls):
@classmethod
def testSetUp(cls):
resp = cls.requester('POST', '/plone/', data=json.dumps({
"@type": "Plone Site",
"@type": "Site",
"title": "Plone Site",
"id": "plone",
"description": "Description Plone Site"
}))
assert resp.status_code == 200
assert resp.status_code in (200, 401) # 401 is if site already exists...
cls.portal = cls.app['plone']['plone']

@classmethod
Expand Down
14 changes: 7 additions & 7 deletions tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"@type\": \"Plone Site\",\n \"title\": \"Site 1\",\n \"id\": \"site1\",\n \"description\": \"Description\"\n}"
"raw": "{\n \"@type\": \"Site\",\n \"title\": \"Site 1\",\n \"id\": \"site1\",\n \"description\": \"Description\"\n}"
},
"description": ""
},
Expand Down Expand Up @@ -228,7 +228,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"@type\": \"Plone Site\",\n \"title\": \"Site 1\",\n \"id\": \"site1\",\n \"description\": \"Description\"\n}"
"raw": "{\n \"@type\": \"Site\",\n \"title\": \"Site 1\",\n \"id\": \"site1\",\n \"description\": \"Description\"\n}"
}
},
"status": "OK",
Expand Down Expand Up @@ -269,7 +269,7 @@
],
"cookie": [],
"responseTime": 283,
"body": "{\"title\": \"Site 1\", \"@type\": \"Plone Site\", \"id\": \"site1\"}"
"body": "{\"title\": \"Site 1\", \"@type\": \"Site\", \"id\": \"site1\"}"
}
]
},
Expand Down Expand Up @@ -306,7 +306,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"@type\": \"Plone Site\",\n \"title\": \"Site 1\",\n \"id\": \"site1\",\n \"description\": \"Description\"\n}"
"raw": "{\n \"@type\": \"Site\",\n \"title\": \"Site 1\",\n \"id\": \"site1\",\n \"description\": \"Description\"\n}"
},
"description": ""
},
Expand Down Expand Up @@ -554,7 +554,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"@type\": \"Plone Site\",\n \"title\": \"Site 1\",\n \"id\": \"site1\",\n \"description\": \"Description\"\n}"
"raw": "{\n \"@type\": \"Site\",\n \"title\": \"Site 1\",\n \"id\": \"site1\",\n \"description\": \"Description\"\n}"
},
"description": ""
},
Expand Down Expand Up @@ -593,11 +593,11 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"@type\": \"Plone Site\",\n \"title\": \"Site 1\",\n \"id\": \"site1\",\n \"description\": \"Description\"\n}"
"raw": "{\n \"@type\": \"Site\",\n \"title\": \"Site 1\",\n \"id\": \"site1\",\n \"description\": \"Description\"\n}"
},
"description": ""
},
"response": []
}
]
}
}

0 comments on commit 10a44a9

Please sign in to comment.