def testUnicodeName(self):
     policy = self.policy
     from AccessControl.SimpleObjectPolicies import override_containers
     # By default we allow all access to str, but this may have been
     # overridden to disallow some access of str.format.  So we temporarily
     # restore the default of allowing all access.
     with override_containers(str, 1):
         assert policy.validate('', '', u'foo', '', None)
Пример #2
0
 def testUnicodeName(self):
     policy = self.policy
     from AccessControl.SimpleObjectPolicies import override_containers
     # By default we allow all access to str, but this may have been
     # overridden to disallow some access of str.format.  So we temporarily
     # restore the default of allowing all access.
     with override_containers(str, 1):
         assert policy.validate('', '', u'foo', '', None)
Пример #3
0
 def testContainersContextManager(self):
     from AccessControl.SimpleObjectPolicies import override_containers
     from AccessControl.SimpleObjectPolicies import ContainerAssertions
     from AccessControl.SimpleObjectPolicies import Containers
     from types import TracebackType
     # Surely we have no assertions for this type:
     self.assertNotIn(TracebackType, ContainerAssertions)
     with override_containers(TracebackType, 1):
         self.assertIn(TracebackType, ContainerAssertions)
         self.assertEqual(Containers(TracebackType), 1)
         # Override it again.
         with override_containers(TracebackType, {}):
             self.assertEqual(Containers(TracebackType), {})
         # We are outside the nested override, so the first override should
         # have been restored.
         self.assertEqual(Containers(TracebackType), 1)
     # We are outside all overrides, so the type should no longer be in the
     # assertions.
     self.assertNotIn(TracebackType, ContainerAssertions)
 def testContainersContextManager(self):
     from AccessControl.SimpleObjectPolicies import override_containers
     from AccessControl.SimpleObjectPolicies import ContainerAssertions
     from AccessControl.SimpleObjectPolicies import Containers
     from types import TracebackType
     # Surely we have no assertions for this type:
     self.assertNotIn(TracebackType, ContainerAssertions)
     with override_containers(TracebackType, 1):
         self.assertIn(TracebackType, ContainerAssertions)
         self.assertEqual(Containers(TracebackType), 1)
         # Override it again.
         with override_containers(TracebackType, {}):
             self.assertEqual(Containers(TracebackType), {})
         # We are outside the nested override, so the first override should
         # have been restored.
         self.assertEqual(Containers(TracebackType), 1)
     # We are outside all overrides, so the type should no longer be in the
     # assertions.
     self.assertNotIn(TracebackType, ContainerAssertions)
 def testContainersContextManager(self):
     from AccessControl.SimpleObjectPolicies import override_containers
     from AccessControl.SimpleObjectPolicies import ContainerAssertions
     from AccessControl.SimpleObjectPolicies import Containers
     from types import EllipsisType
     # Surely we have no assertions for this type.  There might be a good
     # reason to have then, but I have not even heard of this type.
     self.assertFalse(EllipsisType in ContainerAssertions)
     with override_containers(EllipsisType, 1):
         self.assertTrue(EllipsisType in ContainerAssertions)
         self.assertEqual(Containers(EllipsisType), 1)
         # Override it again.
         with override_containers(EllipsisType, {}):
             self.assertEqual(Containers(EllipsisType), {})
         # We are outside the nested override, so the first override should
         # have been restored.
         self.assertEqual(Containers(EllipsisType), 1)
     # We are outside all overrides, so the type should no longer be in the
     # assertions.
     self.assertFalse(EllipsisType in ContainerAssertions)
Пример #6
0
 def testAqNames(self):
     policy = self.policy
     names = {
         'aq_self': 0,
         'aq_base': 0,
         'aq_parent': 1,
         'aq_explicit': 1,
         'aq_inner': 1,
     }
     from AccessControl.SimpleObjectPolicies import override_containers
     # By default we allow all access to str, but this may have been
     # overridden to disallow some access of str.format.  So we temporarily
     # restore the default of allowing all access.
     with override_containers(str, 1):
         for name, allowed in names.items():
             if not allowed:
                 self.assertRaises(Unauthorized, policy.validate, '', '',
                                   name, '', None)
             else:
                 policy.validate('', '', name, '', None)
 def testAqNames(self):
     policy = self.policy
     names = {
         'aq_self': 0,
         'aq_base': 0,
         'aq_parent': 1,
         'aq_explicit': 1,
         'aq_inner': 1,
     }
     from AccessControl.SimpleObjectPolicies import override_containers
     # By default we allow all access to str, but this may have been
     # overridden to disallow some access of str.format.  So we temporarily
     # restore the default of allowing all access.
     with override_containers(str, 1):
         for name, allowed in names.items():
             if not allowed:
                 self.assertRaises(Unauthorized, policy.validate,
                                   '', '', name, '', None)
             else:
                 policy.validate('', '', name, '', None)