From b0a24149ffc4dd3b945b496e5cdb01111c8cf29a Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 11 Jan 2009 22:43:27 +0000 Subject: - Improve test coverage. - Remove old cold which attempts to recover from trying to unpickle a ``z3c.pt`` template; Chameleon has been the templating engine for a good long time now. Running repoze.bfg against a sandbox that has pickled ``z3c.pt`` templates it will now just fail with an unpickling error, but can be fixed by deleting the template cache files. --- repoze/bfg/tests/test_security.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'repoze/bfg/tests/test_security.py') diff --git a/repoze/bfg/tests/test_security.py b/repoze/bfg/tests/test_security.py index 5fa554629..449933c7e 100644 --- a/repoze/bfg/tests/test_security.py +++ b/repoze/bfg/tests/test_security.py @@ -343,6 +343,13 @@ class TestRemoteUserACLSecurityPolicy(unittest.TestCase, PlacelessSetup): result = policy.authenticated_userid(request) self.assertEqual(result, 'fred') + def test_authenticated_userid_no_remote_user(self): + context = DummyContext() + request = DummyRequest({}) + policy = self._makeOne() + result = policy.authenticated_userid(request) + self.assertEqual(result, None) + def test_effective_principals(self): context = DummyContext() request = DummyRequest({'REMOTE_USER':'fred'}) @@ -352,6 +359,13 @@ class TestRemoteUserACLSecurityPolicy(unittest.TestCase, PlacelessSetup): from repoze.bfg.security import Authenticated self.assertEqual(result, [Everyone, Authenticated, 'fred']) + def test_effective_principals_no_remote_user(self): + context = DummyContext() + request = DummyRequest({}) + policy = self._makeOne() + result = policy.effective_principals(request) + from repoze.bfg.security import Everyone + self.assertEqual(result, [Everyone]) class TestRepozeWhoIdentityACLSecurityPolicy(unittest.TestCase, PlacelessSetup): def _getTargetClass(self): @@ -381,6 +395,13 @@ class TestRepozeWhoIdentityACLSecurityPolicy(unittest.TestCase, PlacelessSetup): result = policy.authenticated_userid(request) self.assertEqual(result, 'fred') + def test_authenticated_userid_no_who_ident(self): + context = DummyContext() + request = DummyRequest({}) + policy = self._makeOne() + result = policy.authenticated_userid(request) + self.assertEqual(result, None) + def test_effective_principals(self): context = DummyContext() identity = {'repoze.who.identity':{'repoze.who.userid':'fred'}} @@ -391,6 +412,13 @@ class TestRepozeWhoIdentityACLSecurityPolicy(unittest.TestCase, PlacelessSetup): from repoze.bfg.security import Authenticated self.assertEqual(result, [Everyone, Authenticated, 'fred']) + def test_effective_principals_no_who_ident(self): + context = DummyContext() + request = DummyRequest({}) + policy = self._makeOne() + result = policy.effective_principals(request) + from repoze.bfg.security import Everyone + self.assertEqual(result, [Everyone]) class TestAPIFunctions(unittest.TestCase, PlacelessSetup): def setUp(self): @@ -472,6 +500,16 @@ class TestViewPermission(unittest.TestCase): self.assertEqual(result, True) self.assertEqual(secpol.checked, (context, request, 'repoze.view')) + def test_repr(self): + context = DummyContext() + request = DummyRequest({}) + request.view_name = 'viewname' + secpol = DummySecurityPolicy(True) + permission = self._makeOne(context, request, 'repoze.view') + result = repr(permission) + self.failUnless(result.startswith('")) + class TestViewPermissionFactory(unittest.TestCase): def _getTargetClass(self): from repoze.bfg.security import ViewPermissionFactory -- cgit v1.2.3