本文整理汇总了Python中AccessControl.SecurityManager类的典型用法代码示例。如果您正苦于以下问题:Python SecurityManager类的具体用法?Python SecurityManager怎么用?Python SecurityManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SecurityManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testBoboTraverseToMethod
def testBoboTraverseToMethod(self):
# Verify it's possible to use __bobo_traverse__ to a method.
noSecurityManager()
SecurityManager.setSecurityPolicy( self.oldPolicy )
bb = BoboTraversable()
self.failUnless(
bb.restrictedTraverse('bb_method') is not bb.bb_method)
示例2: testBoboTraverseToSimpleAttrValue
def testBoboTraverseToSimpleAttrValue(self):
# Verify it's possible to use __bobo_traverse__ to a simple
# python value
noSecurityManager()
SecurityManager.setSecurityPolicy( self.oldPolicy )
bb = BoboTraversable()
self.assertEqual(bb.restrictedTraverse('bb_status'), 'screechy')
示例3: testDefaultValueWhenNotFound
def testDefaultValueWhenNotFound(self):
# Test that traversing to a non-existent object returns
# the default when provided
noSecurityManager()
SecurityManager.setSecurityPolicy( self.oldPolicy )
self.assertEqual(
self.root.restrictedTraverse('happy/happy', 'joy'), 'joy')
示例4: setUp
def setUp( self ):
get_transaction().begin()
self._policy = UnitTestSecurityPolicy()
SecurityManager.setSecurityPolicy(self._policy)
self.connection = Zope.DB.open()
self.root = self.connection.root()[ 'Application' ]
newSecurityManager( None, UnitTestUser().__of__( self.root ) )
示例5: _setupSecurity
def _setupSecurity(self, policy=None):
from AccessControl import SecurityManager
from AccessControl.SecurityManagement import noSecurityManager
if policy is None:
policy = self.oldPolicy
noSecurityManager()
SecurityManager.setSecurityPolicy(policy)
示例6: testTraverseThroughBoboTraverse
def testTraverseThroughBoboTraverse(self):
# Verify it's possible to use __bobo_traverse__ with the
# Zope security policy.
noSecurityManager()
SecurityManager.setSecurityPolicy( self.oldPolicy )
bb = BoboTraversable()
self.failUnlessRaises(KeyError, bb.restrictedTraverse, 'notfound')
bb.restrictedTraverse('bb_subitem')
示例7: testDefaultValueWhenUnathorized
def testDefaultValueWhenUnathorized(self):
# Test that traversing to an unauthorized object returns
# the default when provided
noSecurityManager()
SecurityManager.setSecurityPolicy(CruelSecurityPolicy())
newSecurityManager( None, UnitTestUser().__of__( self.root ) )
self.root.stuff = 'stuff here'
self.assertEqual(
self.root.folder1.restrictedTraverse('stuff', 42), 42)
示例8: tearDown
def tearDown(self):
noSecurityManager()
SecurityManager.setSecurityPolicy(self.oldPolicy)
del self.oldPolicy
del self.policy
del self.folder2
del self.folder1
self._cleanApp()
示例9: tearDown
def tearDown(self):
noSecurityManager()
SecurityManager.setSecurityPolicy(self.oldpolicy)
del self.root
del self.reflecto
del self.oldpolicy
super(CopyPasteTests, self).tearDown()
示例10: testBoboTraverseToNonAttrValue
def testBoboTraverseToNonAttrValue(self):
# Verify it's possible to use __bobo_traverse__ to an
# arbitrary manufactured object
noSecurityManager()
# Default security policy always seems to deny in this case, which
# is fine, but to test the code branch we sub in the forgiving one
SecurityManager.setSecurityPolicy(UnitTestSecurityPolicy())
bb = BoboTraversable()
self.failUnless(
bb.restrictedTraverse('manufactured') is 42)
示例11: tearDown
def tearDown( self ):
del self.types_tool
del self.workflow_tool
del self.url_tool
del self.discussion_tool
del self.catalog_tool
del self.root
del self._policy
get_transaction().abort()
self.connection.close()
SecurityManager.setSecurityPolicy( self._oldPolicy )
示例12: testBoboTraverseToAcquiredAttribute
def testBoboTraverseToAcquiredAttribute(self):
# Verify it's possible to use __bobo_traverse__ to an acquired
# attribute
noSecurityManager()
SecurityManager.setSecurityPolicy( self.oldPolicy )
folder = self.root.folder1
folder.stuff = 'stuff here'
bb = BoboTraversableWithAcquisition()
bb = bb.__of__(folder)
self.assertEqual(
bb.restrictedTraverse('stuff'), 'stuff here')
示例13: testAcquiredAttributeDenial
def testAcquiredAttributeDenial(self):
# Verify that restrictedTraverse raises the right kind of exception
# on denial of access to an acquired attribute. If it raises
# AttributeError instead of Unauthorized, the user may never
# be prompted for HTTP credentials.
noSecurityManager()
SecurityManager.setSecurityPolicy(CruelSecurityPolicy())
newSecurityManager( None, UnitTestUser().__of__( self.root ) )
self.root.stuff = 'stuff here'
self.failUnlessRaises(Unauthorized,
self.root.folder1.restrictedTraverse, 'stuff')
示例14: tearDown
def tearDown(self):
noSecurityManager()
SecurityManager.setSecurityPolicy(self.oldPolicy)
del self.oldPolicy
del self.policy
del self.folder2
del self.folder1
self._cleanApp()
componenttesting.tearDown()
CopySupportTestBase.tearDown(self)
示例15: testBoboTraverseToAcquiredProtectedObject
def testBoboTraverseToAcquiredProtectedObject(self):
# Verify it's possible to use a __bobo_traverse__ which retrieves
# objects by acquisition
noSecurityManager()
SecurityManager.setSecurityPolicy( self.oldPolicy )
folder = self.root.folder1
# restrict the ability to access the retrieved object itself
folder.manage_permission(access_contents_information, [], 0)
bb = BoboTraversableWithAcquisition()
bb = bb.__of__(self.root)
self.failUnlessRaises(Unauthorized,
self.root.folder1.restrictedTraverse, 'folder1')