summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pyramid/security.py13
-rw-r--r--tests/test_security.py34
2 files changed, 14 insertions, 33 deletions
diff --git a/src/pyramid/security.py b/src/pyramid/security.py
index 4881d94a6..9088a9746 100644
--- a/src/pyramid/security.py
+++ b/src/pyramid/security.py
@@ -60,7 +60,7 @@ def remember(request, userid, **kw):
on this request's response.
These headers are suitable for 'remembering' a set of credentials
implied by the data passed as ``userid`` and ``*kw`` using the
- current :term:`authentication policy`. Common usage might look
+ current :term:`security policy`. Common usage might look
like so within the body of a view function (``response`` is
assumed to be a :term:`WebOb` -style :term:`response` object
computed previously by the view code):
@@ -73,10 +73,10 @@ def remember(request, userid, **kw):
response.headerlist.extend(headers)
return response
- If no :term:`authentication policy` is in use, this function will
+ If no :term:`security policy` is in use, this function will
always return an empty sequence. If used, the composition and
meaning of ``**kw`` must be agreed upon by the calling code and
- the effective authentication policy.
+ the effective security policy.
.. versionchanged:: 1.6
Deprecated the ``principal`` argument in favor of ``userid`` to clarify
@@ -85,7 +85,7 @@ def remember(request, userid, **kw):
.. versionchanged:: 1.10
Removed the deprecated ``principal`` argument.
"""
- policy = _get_authentication_policy(request)
+ policy = _get_security_policy(request)
if policy is None:
return []
return policy.remember(request, userid, **kw)
@@ -107,10 +107,10 @@ def forget(request):
response.headerlist.extend(headers)
return response
- If no :term:`authentication policy` is in use, this function will
+ If no :term:`security policy` is in use, this function will
always return an empty sequence.
"""
- policy = _get_authentication_policy(request)
+ policy = _get_security_policy(request)
if policy is None:
return []
return policy.forget(request)
@@ -132,6 +132,7 @@ def principals_allowed_by_permission(context, permission):
required machinery for this function; those will cause a
:exc:`NotImplementedError` exception to be raised when this
function is invoked.
+
"""
reg = get_current_registry()
policy = reg.queryUtility(IAuthorizationPolicy)
diff --git a/tests/test_security.py b/tests/test_security.py
index 40b5cd061..fae9db76f 100644
--- a/tests/test_security.py
+++ b/tests/test_security.py
@@ -187,32 +187,22 @@ class TestRemember(unittest.TestCase):
return remember(*arg, **kwarg)
- def test_no_authentication_policy(self):
+ def test_no_security_policy(self):
request = _makeRequest()
result = self._callFUT(request, 'me')
self.assertEqual(result, [])
- def test_with_authentication_policy(self):
+ def test_with_security_policy(self):
request = _makeRequest()
registry = request.registry
- _registerAuthenticationPolicy(registry, 'yo')
- result = self._callFUT(request, 'me')
- self.assertEqual(result, [('X-Pyramid-Test', 'me')])
-
- def test_with_authentication_policy_no_reg_on_request(self):
- from pyramid.threadlocal import get_current_registry
-
- registry = get_current_registry()
- request = _makeRequest()
- del request.registry
- _registerAuthenticationPolicy(registry, 'yo')
+ _registerSecurityPolicy(registry, 'yo')
result = self._callFUT(request, 'me')
self.assertEqual(result, [('X-Pyramid-Test', 'me')])
def test_with_missing_arg(self):
request = _makeRequest()
registry = request.registry
- _registerAuthenticationPolicy(registry, 'yo')
+ _registerSecurityPolicy(registry, 'yo')
self.assertRaises(TypeError, lambda: self._callFUT(request))
@@ -228,24 +218,14 @@ class TestForget(unittest.TestCase):
return forget(*arg)
- def test_no_authentication_policy(self):
+ def test_no_security_policy(self):
request = _makeRequest()
result = self._callFUT(request)
self.assertEqual(result, [])
- def test_with_authentication_policy(self):
- request = _makeRequest()
- _registerAuthenticationPolicy(request.registry, 'yo')
- result = self._callFUT(request)
- self.assertEqual(result, [('X-Pyramid-Test', 'logout')])
-
- def test_with_authentication_policy_no_reg_on_request(self):
- from pyramid.threadlocal import get_current_registry
-
- registry = get_current_registry()
+ def test_with_security_policy(self):
request = _makeRequest()
- del request.registry
- _registerAuthenticationPolicy(registry, 'yo')
+ _registerSecurityPolicy(request.registry, 'yo')
result = self._callFUT(request)
self.assertEqual(result, [('X-Pyramid-Test', 'logout')])