From e25a70a7d1c2016eaeff9c630df9109e715bba3b Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 9 Sep 2010 17:46:49 +0000 Subject: Features -------- - In support of making it easier to configure applications which are "secure by default", a default permission feature was added. If supplied, the default permission is used as the permission string to all view registrations which don't otherwise name a permission. These APIs are in support of that: - A new constructor argument was added to the Configurator: ``default_permission``. - A new method was added to the Configurator: ``set_default_permission``. - A new ZCML directive was added: ``default_permission``. Documentation ------------- - Added documentation for the ``default_permission`` ZCML directive. - Added documentation for the ``default_permission`` constructor value and the ``set_default_permission`` method in the Configurator API documentation. - Added a new section to the "security" chapter named "Setting a Default Permission". - Document ``renderer_globals_factory`` and ``request_factory`` arguments to Configurator constructor. --- repoze/bfg/tests/test_zcml.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'repoze/bfg/tests/test_zcml.py') diff --git a/repoze/bfg/tests/test_zcml.py b/repoze/bfg/tests/test_zcml.py index 4cd7f88d3..131122d7b 100644 --- a/repoze/bfg/tests/test_zcml.py +++ b/repoze/bfg/tests/test_zcml.py @@ -1123,6 +1123,30 @@ class TestLocaleNegotiatorDirective(unittest.TestCase): self.assertEqual(action['args'], (dummy_negotiator,)) action['callable'](*action['args']) # doesn't blow up +class TestDefaultPermissionDirective(unittest.TestCase): + def setUp(self): + testing.setUp() + + def tearDown(self): + testing.tearDown() + + def _callFUT(self, context, name): + from repoze.bfg.zcml import default_permission + return default_permission(context, name) + + def test_it(self): + from repoze.bfg.threadlocal import get_current_registry + from repoze.bfg.interfaces import IDefaultPermission + reg = get_current_registry() + context = DummyContext() + self._callFUT(context, 'view') + actions = context.actions + self.assertEqual(len(actions), 1) + regadapt = actions[0] + self.assertEqual(regadapt['discriminator'], IDefaultPermission) + perm = reg.getUtility(IDefaultPermission) + self.assertEqual(perm, 'view') + class TestLoadZCML(unittest.TestCase): def setUp(self): testing.setUp() -- cgit v1.2.3