[Zope3-checkins] CVS: Zope3/src/zope/app/security/tests - module.py:1.1.2.2 modulehookup.py:1.1.2.3 test_basicauthadapter.py:1.1.2.2 test_loginpassword.py:1.1.2.2 test_permissionfield.py:1.1.2.2 test_protectclass.py:1.1.2.3 test_protectsubclass.py:1.1.2.2 test_securitydirectives.py:1.1.2.4 test_settings.py:1.1.2.2 test_zsp.py:1.1.2.4
Tim Peters
tim.one@comcast.net
Tue, 24 Dec 2002 21:21:50 -0500
Update of /cvs-repository/Zope3/src/zope/app/security/tests
In directory cvs.zope.org:/tmp/cvs-serv19240/src/zope/app/security/tests
Modified Files:
Tag: NameGeddon-branch
module.py modulehookup.py test_basicauthadapter.py
test_loginpassword.py test_permissionfield.py
test_protectclass.py test_protectsubclass.py
test_securitydirectives.py test_settings.py test_zsp.py
Log Message:
Whitespace normalization, via Python's Tools/scripts/reindent.py. The
files are fixed-points of that script now. Fixed a few cases where
code relied on significant trailing whitespace (ouch).
=== Zope3/src/zope/app/security/tests/module.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/security/tests/module.py:1.1.2.1 Mon Dec 23 18:49:02 2002
+++ Zope3/src/zope/app/security/tests/module.py Tue Dec 24 21:20:48 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""This empty module is for containing objects used in the course of tests.
=== Zope3/src/zope/app/security/tests/modulehookup.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/app/security/tests/modulehookup.py:1.1.2.2 Tue Dec 24 07:51:17 2002
+++ Zope3/src/zope/app/security/tests/modulehookup.py Tue Dec 24 21:20:48 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""Preliminaries to hookup a test suite with the external TestModule.
@@ -34,7 +34,7 @@
class I2(I):
def m4():
pass
-
+
TestModule.I = I
TestModule.I2 = I2
=== Zope3/src/zope/app/security/tests/test_basicauthadapter.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/security/tests/test_basicauthadapter.py:1.1.2.1 Mon Dec 23 14:32:21 2002
+++ Zope3/src/zope/app/security/tests/test_basicauthadapter.py Tue Dec 24 21:20:48 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
import unittest, sys
=== Zope3/src/zope/app/security/tests/test_loginpassword.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/security/tests/test_loginpassword.py:1.1.2.1 Mon Dec 23 14:32:21 2002
+++ Zope3/src/zope/app/security/tests/test_loginpassword.py Tue Dec 24 21:20:48 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
import unittest, sys
=== Zope3/src/zope/app/security/tests/test_permissionfield.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/security/tests/test_permissionfield.py:1.1.2.1 Mon Dec 23 14:32:21 2002
+++ Zope3/src/zope/app/security/tests/test_permissionfield.py Tue Dec 24 21:20:48 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""Permission fields tests
@@ -43,4 +43,3 @@
if __name__=='__main__':
main(defaultTest='test_suite')
-
=== Zope3/src/zope/app/security/tests/test_protectclass.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/app/security/tests/test_protectclass.py:1.1.2.2 Tue Dec 24 13:07:25 2002
+++ Zope3/src/zope/app/security/tests/test_protectclass.py Tue Dec 24 21:20:48 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
""" Test handler for 'protectClass' directive """
@@ -31,7 +31,7 @@
def setUp(self):
permissionRegistry.definePermission(P1, P1)
permissionRegistry.definePermission(P2, P2)
-
+
class B:
def m1(self):
return "m1"
@@ -102,7 +102,7 @@
protectName(TestModule.test_class, 'm3', P2)
# m1 and m2 are in the interface, so should be set, and m3 should not:
self.assertState(m1P=P1, m2P=P2, m3P=P2)
-
+
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
=== Zope3/src/zope/app/security/tests/test_protectsubclass.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/security/tests/test_protectsubclass.py:1.1.2.1 Mon Dec 23 14:32:21 2002
+++ Zope3/src/zope/app/security/tests/test_protectsubclass.py Tue Dec 24 21:20:48 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""Test proper protection of inherited methods
@@ -49,7 +49,7 @@
self.assertEqual(S().g(), 'B1.g')
self.assertEqual(S().h(), 'B2.h')
-
+
def test_suite():
return makeSuite(Test)
=== Zope3/src/zope/app/security/tests/test_securitydirectives.py 1.1.2.3 => 1.1.2.4 ===
--- Zope3/src/zope/app/security/tests/test_securitydirectives.py:1.1.2.3 Tue Dec 24 07:51:17 2002
+++ Zope3/src/zope/app/security/tests/test_securitydirectives.py Tue Dec 24 21:20:48 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
@@ -61,7 +61,7 @@
xmlconfig(f)
reg=principalRegistry
-
+
p = reg.getPrincipal('1')
self.assertEqual(p.getId(), '1')
self.assertEqual(p.getTitle(), 'Sir Tim Peters')
@@ -108,7 +108,7 @@
#self.assertRaises(AlreadyRegisteredError, xmlconfig, f)
self.assertRaises(ZopeXMLConfigurationError, xmlconfig, f)
-
+
class TestRoleDirective(CleanUp, unittest.TestCase):
def setUp(self):
XMLConfig('meta.zcml', zope.app.security)()
@@ -128,7 +128,7 @@
self.assertEqual(role.getTitle(), 'Tout le monde')
self.assertEqual(role.getDescription(),
'The common man, woman, person, or thing')
-
+
def testDuplicationRegistration(self):
f = configfile("""
<role
=== Zope3/src/zope/app/security/tests/test_settings.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/security/tests/test_settings.py:1.1.2.1 Mon Dec 23 14:32:21 2002
+++ Zope3/src/zope/app/security/tests/test_settings.py Tue Dec 24 21:20:48 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
import unittest, sys
@@ -26,7 +26,7 @@
s.seek(0)
u = Unpickler(s)
newAllow = u.load()
-
+
self.failUnless(newAllow is Allow)
def test_suite():
=== Zope3/src/zope/app/security/tests/test_zsp.py 1.1.2.3 => 1.1.2.4 ===
--- Zope3/src/zope/app/security/tests/test_zsp.py:1.1.2.3 Mon Dec 23 18:52:35 2002
+++ Zope3/src/zope/app/security/tests/test_zsp.py Tue Dec 24 21:20:48 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
@@ -22,24 +22,24 @@
from zope.proxy.context import ContextWrapper
from zope.component import getService
from zope.app.interfaces.security import IRolePermissionManager
-from zope.app.security.registries.permissionregistry import permissionRegistry
-from zope.app.security.registries.principalregistry import principalRegistry
+from zope.app.security.registries.permissionregistry import permissionRegistry
+from zope.app.security.registries.principalregistry import principalRegistry
from zope.app.security.registries.roleregistry import roleRegistry
from zope.app.security.grants.principalpermissionmanager \
- import principalPermissionManager
+ import principalPermissionManager
from zope.app.security.grants.rolepermissionmanager \
- import rolePermissionManager
+ import rolePermissionManager
from zope.app.security.grants.principalrolemanager \
- import principalRoleManager
+ import principalRoleManager
from zope.app.security.grants.annotationprincipalpermissionmanager \
- import AnnotationPrincipalPermissionManager
+ import AnnotationPrincipalPermissionManager
from zope.app.interfaces.security \
- import IPrincipalPermissionManager
+ import IPrincipalPermissionManager
from zope.app.security.grants.annotationprincipalrolemanager \
- import AnnotationPrincipalRoleManager
+ import AnnotationPrincipalRoleManager
from zope.app.security.grants.annotationrolepermissionmanager \
- import AnnotationRolePermissionManager
-from zope.app.interfaces.security import IPrincipalRoleManager
+ import AnnotationRolePermissionManager
+from zope.app.interfaces.security import IPrincipalRoleManager
from zope.app.interfaces.annotation import IAttributeAnnotatable
from zope.app.interfaces.annotation import IAnnotations
from zope.app.attributeannotations import AttributeAnnotations
@@ -50,7 +50,7 @@
class Context:
def __init__(self, user, stack=[]):
self.user, self.stack = user, stack
-
+
class Unprotected:
pass
@@ -67,20 +67,20 @@
jim = principalRegistry.definePrincipal('jim', 'Jim', 'Jim Fulton',
'jim', '123')
self.jim = jim.getId()
-
+
tim = principalRegistry.definePrincipal('tim', 'Tim', 'Tim Peters',
'tim', '456')
self.tim = tim.getId()
- unknown = principalRegistry.defineDefaultPrincipal('unknown',
+ unknown = principalRegistry.defineDefaultPrincipal('unknown',
'Unknown', 'Nothing is known about this principal')
self.unknown = unknown.getId()
-
+
# set up some permissions
- read = permissionRegistry.definePermission('read', 'Read',
+ read = permissionRegistry.definePermission('read', 'Read',
'Read something')
self.read = read.getId()
- write = permissionRegistry.definePermission('write', 'Write',
+ write = permissionRegistry.definePermission('write', 'Write',
'Write something')
self.write = write.getId()
create = permissionRegistry.definePermission('create', 'Create',
@@ -96,14 +96,14 @@
manager = roleRegistry.defineRole('Manager', 'Site Manager')
self.manager = manager.getId()
-
+
arole = roleRegistry.defineRole('Another', 'Another Role')
self.arole = arole.getId()
# grant and deny some permissions to a principal
principalPermissionManager.grantPermissionToPrincipal(self.create, self.jim)
principalPermissionManager.denyPermissionToPrincipal(self.update, self.jim)
-
+
# grant and deny some permissions to the roles
rolePermissionManager.grantPermissionToRole(self.read, self.peon)
@@ -137,7 +137,7 @@
self.read, None, Context(self.unknown)))
self.failIf(self.policy.checkPermission(
self.write, None, Context(self.unknown)))
-
+
self.failIf(
self.policy.checkPermission(
self.read, None, Context(self.unknown)))
@@ -147,7 +147,7 @@
self.__assertPermissions(self.unknown, [])
rolePermissionManager.grantPermissionToRole(self.read, 'Anonymous')
-
+
self.failUnless(
self.policy.checkPermission(
self.read, None, Context(self.unknown)))
@@ -165,7 +165,7 @@
permissions = list(permissionsOfPrincipal(user, object))
permissions.sort()
self.assertEqual(permissions, expected)
-
+
def testPlayfulPrincipalRole(self):
getService(None,"Adapters").provideAdapter(
@@ -182,10 +182,10 @@
self.manager, self.jim)
self.failUnless(self.policy.checkPermission(
self.write, ob, Context(self.jim)))
-
+
def testPlayfulRolePermissions(self):
-
+
ARPM = AnnotationRolePermissionManager
getService(None,"Adapters").provideAdapter(ITest,
IRolePermissionManager, ARPM)
@@ -230,8 +230,8 @@
ARPM(ob2).grantPermissionToRole(test, 'Anonymous')
ARPM(ob2).grantPermissionToRole(test, self.arole)
ARPM(ob3).denyPermissionToRole(test, self.peon)
-
- new = principalRegistry.definePrincipal('new', 'Newbie',
+
+ new = principalRegistry.definePrincipal('new', 'Newbie',
'Newbie User', 'new', '098')
new = new.getId()
principalRoleManager.assignRoleToPrincipal(self.arole, new)
@@ -241,7 +241,7 @@
principalRoleManager.assignRoleToPrincipal(self.peon, new)
self.failIf(self.policy.checkPermission(test, ob, Context(new)))
self.__assertPermissions(new, ['read'], ob)
-
+
def testPlayfulPrinciplePermissions(self):
APPM = AnnotationPrincipalPermissionManager
getService(None,"Adapters").provideAdapter(ITest,
@@ -300,7 +300,7 @@
def __init__(self):
self._roles = { 'test' : {} }
self._permissions = { 'Manager' : {} , 'Peon' : {} }
-
+
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)