summaryrefslogtreecommitdiff
path: root/repoze/bfg/tests/test_security.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2008-11-02 22:14:58 +0000
committerChris McDonough <chrism@agendaless.com>2008-11-02 22:14:58 +0000
commit389ac52e76f64da5bdf87acd19aa1b2fb5cf664b (patch)
treedde685da2bda59ba063cff2751cdf913571f1cea /repoze/bfg/tests/test_security.py
parentabe447ecb25bd385cafcdedeae0ee31007283569 (diff)
downloadpyramid-389ac52e76f64da5bdf87acd19aa1b2fb5cf664b.tar.gz
pyramid-389ac52e76f64da5bdf87acd19aa1b2fb5cf664b.tar.bz2
pyramid-389ac52e76f64da5bdf87acd19aa1b2fb5cf664b.zip
- Fix bug where default deny in authorization check would throw a
TypeError (use ``ACLDenied`` instead of ``Denied``).
Diffstat (limited to 'repoze/bfg/tests/test_security.py')
-rw-r--r--repoze/bfg/tests/test_security.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/repoze/bfg/tests/test_security.py b/repoze/bfg/tests/test_security.py
index 43dc38890..5fa554629 100644
--- a/repoze/bfg/tests/test_security.py
+++ b/repoze/bfg/tests/test_security.py
@@ -234,6 +234,21 @@ class TestACLSecurityPolicy(unittest.TestCase, PlacelessSetup):
self.assertEqual(authorizer_factory.permission, 'view')
self.assertEqual(authorizer_factory.context, context)
+ def test_permits_default_deny(self):
+ context = DummyContext()
+ context.__acl__ = []
+ request = DummyRequest({})
+ policy = self._makeOne(lambda *arg: None)
+ authorizer_factory = make_authorizer_factory(None,
+ intermediates_raise=True)
+ policy.authorizer_factory = authorizer_factory
+ result = policy.permits(context, request, 'view')
+ self.assertEqual(result, False)
+ from repoze.bfg.security import Everyone
+ self.assertEqual(authorizer_factory.principals, (Everyone,))
+ self.assertEqual(authorizer_factory.permission, 'view')
+ self.assertEqual(authorizer_factory.context, context)
+
def test_permits_no_principals_withparents_root_has_acl_info(self):
context = DummyContext()
context.__name__ = None
@@ -398,7 +413,9 @@ class TestAPIFunctions(unittest.TestCase, PlacelessSetup):
def test_has_permission_not_registered(self):
from repoze.bfg.security import has_permission
- self.assertEqual(has_permission('view', None, None), True)
+ result = has_permission('view', None, None)
+ self.assertEqual(result, True)
+ self.assertEqual(result.msg, 'No security policy in use.')
def test_authenticated_userid_registered(self):
secpol = DummySecurityPolicy(False)
@@ -591,13 +608,3 @@ class make_authorizer_factory:
raise NoAuthorizationInformation()
return result
return Authorizer()
-
-
-
-
-
-
-
-
-
-