[Checkins] SVN: zope.app.securitypolicy/trunk/ Fixed deprecation
warnings.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Wed Oct 31 15:53:46 EDT 2007
Log message for revision 81329:
Fixed deprecation warnings.
Reactivated functional tests.
Changed:
U zope.app.securitypolicy/trunk/CHANGES.txt
U zope.app.securitypolicy/trunk/buildout.cfg
U zope.app.securitypolicy/trunk/setup.py
U zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/configure.zcml
D zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/ftests.py
U zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/granting_ftest.txt
A zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/tests/test_functional.py
U zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/ftesting.zcml
U zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/principalpermission.py
-=-
Modified: zope.app.securitypolicy/trunk/CHANGES.txt
===================================================================
--- zope.app.securitypolicy/trunk/CHANGES.txt 2007-10-31 19:41:26 UTC (rev 81328)
+++ zope.app.securitypolicy/trunk/CHANGES.txt 2007-10-31 19:53:46 UTC (rev 81329)
@@ -2,33 +2,40 @@
CHANGES
=======
+3.4.5 (2007-10-31)
+------------------
-Version 3.4.4 (2007/10/23)
---------------------------
+- Resolve ``ZopeSecurityPolicy`` deprecation warning.
+- Re-activated the functional tests.
+
+
+3.4.4 (2007-10-23)
+------------------
+
- Avoid deprecation warnings.
-Version 3.4.3 (2007/10/01)
---------------------------
+3.4.3 (2007-10-01)
+------------------
- Correct deferred import for BBB.
-Version 3.4.2 (2007/9/27)
--------------------------
+3.4.2 (2007-09-27)
+------------------
- Add back securitypolicy.zcml
(https://bugs.launchpad.net/zope3/+bug/145655)
-Version 3.4.1 (2007/9/26)
--------------------------
+3.4.1 (2007-09-26)
+------------------
- Zip releases don't seem to work, so let's create a new one.
-Version 3.4.0 (2007/9/25)
--------------------------
+3.4.0 (2007-09-25)
+------------------
- Initial documented release
Modified: zope.app.securitypolicy/trunk/buildout.cfg
===================================================================
--- zope.app.securitypolicy/trunk/buildout.cfg 2007-10-31 19:41:26 UTC (rev 81328)
+++ zope.app.securitypolicy/trunk/buildout.cfg 2007-10-31 19:53:46 UTC (rev 81329)
@@ -1,7 +1,6 @@
[buildout]
-develop = .
+develop = .
parts = test
-find-links = http://download.zope.org/distribution/
[test]
recipe = zc.recipe.testrunner
Modified: zope.app.securitypolicy/trunk/setup.py
===================================================================
--- zope.app.securitypolicy/trunk/setup.py 2007-10-31 19:41:26 UTC (rev 81328)
+++ zope.app.securitypolicy/trunk/setup.py 2007-10-31 19:53:46 UTC (rev 81329)
@@ -27,7 +27,7 @@
version = '3.4.5',
author='Zope Corporation and Contributors',
author_email='zope3-dev at zope.org',
- description='Zope securitypolicy',
+ description="Zope's Default Security Policy ZMI Support",
long_description=(
read('README.txt')
+ '\n\n' +
Modified: zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/configure.zcml
===================================================================
--- zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/configure.zcml 2007-10-31 19:41:26 UTC (rev 81328)
+++ zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/configure.zcml 2007-10-31 19:53:46 UTC (rev 81329)
@@ -1,4 +1,4 @@
-<zope:configure
+<zope:configure
xmlns:zope="http://namespaces.zope.org/zope"
xmlns="http://namespaces.zope.org/browser"
i18n_domain="zope">
@@ -42,7 +42,7 @@
description="A Security Role"
permission="zope.Security"
view="addRole.html"
- />
+ />
<!-- Role Permissions -->
@@ -54,29 +54,29 @@
permission="zope.Security"
class=".rolepermissionview.RolePermissionView">
<page
- name="AllRolePermissions.html"
- template="manage_access.pt"
+ name="AllRolePermissions.html"
+ template="manage_access.pt"
menu="zmi_actions" title="Role-Permissions"
/>
<!-- menu="zmi_actions" title="Role Permissions" / -->
<page
- name="RolePermissions.html"
- template="manage_roleform.pt"
+ name="RolePermissions.html"
+ template="manage_roleform.pt"
/>
<page
- name="RolesWithPermission.html"
+ name="RolesWithPermission.html"
template="manage_permissionform.pt"
/>
</pages>
<zope:class class=".rolepermissionview.PermissionRoles">
- <zope:require
+ <zope:require
permission="zope.Security"
attributes="roles rolesInfo id title description" />
</zope:class>
<zope:class class=".rolepermissionview.RolePermissions">
- <zope:require
+ <zope:require
permission="zope.Security"
attributes="permissions permissionsInfo id title description" />
</zope:class>
@@ -87,9 +87,9 @@
for="zope.annotation.interfaces.IAnnotatable"
name="grant.html"
permission="zope.Security"
- template="granting.pt"
+ template="granting.pt"
class=".granting.Granting"
- menu="zmi_actions" title="Grant"
+ menu="zmi_actions" title="Grant"
/>
Deleted: zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/ftests.py
===================================================================
--- zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/ftests.py 2007-10-31 19:41:26 UTC (rev 81328)
+++ zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/ftests.py 2007-10-31 19:53:46 UTC (rev 81329)
@@ -1,155 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003, 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (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.
-#
-##############################################################################
-"""Functional tests for Security Policy's Grant screens.
-
-$Id$
-"""
-
-import re
-import unittest
-
-import zope.component
-from zope.testing import renormalizing
-from zope.security.interfaces import IPermission
-from zope.security.permission import Permission
-from zope.securitypolicy.role import Role
-from zope.securitypolicy.interfaces import IRole
-
-from zope.app.testing import functional
-from zope.app.securitypolicy.testing import SecurityPolicyLayer
-
-
-class RolePermissionsTest(functional.BrowserTestCase):
-
- def testAllRolePermissionsForm(self):
- response = self.publish(
- '/++etc++site/@@AllRolePermissions.html',
- basic='mgr:mgrpw')
- self.assertEqual(response.getStatus(), 200)
- body = response.getBody()
- self.assert_('Permissions' in body)
- self.assert_('Manage Content' in body)
- self.assert_('Manage Site' in body)
- self.assert_('Roles' in body)
- self.assert_('Site Manager' in body)
- self.assert_('Site Member' in body)
- self.failIf(_result in body)
- self.checkForBrokenLinks(body,
- '/++etc++site/@@AllRolePermissions.html',
- 'mgr:mgrpw')
-
- def testAllRolePermissions(self):
- response = self.publish(
- '/++etc++site/@@AllRolePermissions.html',
- form={'p0r0': 'Allow',
- 'p0': 'zope.ManageContent',
- 'r0': 'zope.Manager',
- 'SUBMIT': 'Save Changes'},
- basic='mgr:mgrpw')
- self.assertEqual(response.getStatus(), 200)
- body = response.getBody()
- self.assert_('<p>Settings changed' in body)
- self.assert_(_result in body)
-
- def testRolesWithPermissionsForm(self):
- response = self.publish(
- '/++etc++site/@@RolesWithPermissions.html'
- '?permission_to_manage=zope.View',
- basic='mgr:mgrpw')
- self.assertEqual(response.getStatus(), 200)
- body = response.getBody()
- self.assert_('Roles assigned to the permission' in body)
- self.assert_('Role' in body)
- self.assert_('Setting' in body)
- self.assert_('"Save Changes"' in body)
- self.checkForBrokenLinks(body, '/@@RolesWithPermissions.html',
- 'mgr:mgrpw')
-
- def testRolesWithPermissionsForm(self):
- response = self.publish(
- '/++etc++site/@@RolePermissions.html?role_to_manage=zope.Manager',
- basic='mgr:mgrpw')
- self.assertEqual(response.getStatus(), 200)
- body = response.getBody()
- self.assert_(
- 'This page shows the permissions allowed and denied the role'
- in body)
- self.assert_('Allow' in body)
- self.assert_('Deny' in body)
- self.checkForBrokenLinks(body, '/++etc++site/@@RolesPermissions.html',
- 'mgr:mgrpw')
-
- def testAllRolePermissionsFormForLocalRoles(self):
- role = Role(u"id", u"Local Role")
- zope.component.provideUtility(role, IRole)
- self.testAllRolePermissions()
-
- response = self.publish(
- '/++etc++site/@@AllRolePermissions.html',
- basic='mgr:mgrpw')
- body = response.getBody()
- self.assert_('Local Role' in body)
-
- def testAllRolePermissionsFormForLocalPermissions(self):
- permission = Permission(u"id", u"Local Permission")
- zope.component.provideUtility(permission, IPermission)
- self.testAllRolePermissions()
-
- response = self.publish(
- '/++etc++site/@@AllRolePermissions.html',
- basic='mgr:mgrpw')
- body = response.getBody()
- self.assert_('Local Permission' in body)
-
- def testRolesWithPermissionsFormForLocalPermission(self):
- permission = Permission(u"id", u"Local Permission")
- zope.component.provideUtility(permission, IPermission, 'id')
-
- response = self.publish(
- '/++etc++site/@@AllRolePermissions.html',
- form={'role_id': 'zope.Manager',
- 'Allow': ['id'],
- 'Deny': ['id'],
- 'SUBMIT_ROLE': 'Save Changes'},
- basic='mgr:mgrpw',
- handle_errors=True)
- body = response.getBody()
- self.assert_('You choose both allow and deny for permission'
- ' "Local Permission". This is not allowed.' in body)
-
-_result = '''\
- <option value="Unset"> </option>
- <option value="Allow" selected="selected">+</option>
- <option value="Deny">-</option>
-'''
-
-
-checker = renormalizing.RENormalizing([
- (re.compile(r"HTTP/1\.1 (\d\d\d) .*"), r"HTTP/1.1 \1 <MESSAGE>"),
- ])
-
-
-def test_suite():
- RolePermissionsTest.layer = SecurityPolicyLayer
- granting = functional.FunctionalDocFileSuite(
- 'granting_ftest.txt', checker=checker)
- granting.layer = SecurityPolicyLayer
- return unittest.TestSuite((
- unittest.makeSuite(RolePermissionsTest),
- granting,
- ))
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
Modified: zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/granting_ftest.txt
===================================================================
--- zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/granting_ftest.txt 2007-10-31 19:41:26 UTC (rev 81328)
+++ zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/granting_ftest.txt 2007-10-31 19:53:46 UTC (rev 81329)
@@ -4,7 +4,7 @@
In this example, we look at granting (or denying) principals (or
roles) to principals.
-To make grants, we visit grant.html. This doesn't display any
+To make grants, we visit grant.html. This doesn't display any
grant information until we select a principal.
>>> print http(r"""
@@ -24,7 +24,7 @@
... Content-Length: 117
... Content-Type: application/x-www-form-urlencoded
... Referer: http://localhost:8081/@@grant.html
- ...
+ ...
... field.principal.displayed=y"""
... "&field.principal.MA__.searchstring="
... "&field.principal.MA__.search=Search")
@@ -42,7 +42,7 @@
... Content-Length: 62415
... Content-Type: application/x-www-form-urlencoded
... Referer: http://localhost:8081/@@grant.html
- ...
+ ...
... field.principal.displayed=y"""
... """&field.principal.MA__.searchstring="""
... """&field.principal.MA__.selection=em9wZS5tZ3I_"""
@@ -102,8 +102,8 @@
role to the test manager:
>>> root = getRootFolder()
- >>> import zope.app.securitypolicy.interfaces
- >>> grants = zope.app.securitypolicy.interfaces.IGrantInfo(root)
+ >>> import zope.securitypolicy.interfaces
+ >>> grants = zope.securitypolicy.interfaces.IGrantInfo(root)
>>> grants.principalPermissionGrant('zope.mgr', 'zope.ManageCode')
PermissionSetting: Unset
>>> list(grants.getRolesForPrincipal('zope.mgr'))
@@ -120,7 +120,7 @@
... Content-Length: 62437
... Content-Type: application/x-www-form-urlencoded
... Referer: http://localhost:8081/@@grant.html
- ...
+ ...
... field.principal=em9wZS5tZ3I_"""
... """&field.principal.displayed=y"""
... """&field.principal.MA__.searchstring="""
@@ -181,7 +181,7 @@
And, if we check the grants, we see the changes:
- >>> grants = zope.app.securitypolicy.interfaces.IGrantInfo(root)
+ >>> grants = zope.securitypolicy.interfaces.IGrantInfo(root)
>>> grants.principalPermissionGrant('zope.mgr', 'zope.ManageCode')
PermissionSetting: Deny
@@ -190,6 +190,6 @@
>>> role_grants.sort()
>>> role_grants
... # doctest: +NORMALIZE_WHITESPACE
- [('zope.Manager', PermissionSetting: Allow),
+ [('zope.Manager', PermissionSetting: Allow),
('zope.Member', PermissionSetting: Allow)]
-
+
Copied: zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/tests/test_functional.py (from rev 80503, zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/ftests.py)
===================================================================
--- zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/tests/test_functional.py (rev 0)
+++ zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/browser/tests/test_functional.py 2007-10-31 19:53:46 UTC (rev 81329)
@@ -0,0 +1,155 @@
+##############################################################################
+#
+# Copyright (c) 2003, 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""Functional tests for Security Policy's Grant screens.
+
+$Id$
+"""
+
+import re
+import unittest
+
+import zope.component
+from zope.testing import renormalizing
+from zope.security.interfaces import IPermission
+from zope.security.permission import Permission
+from zope.securitypolicy.role import Role
+from zope.securitypolicy.interfaces import IRole
+
+from zope.app.testing import functional
+from zope.app.securitypolicy.testing import SecurityPolicyLayer
+
+
+class RolePermissionsTest(functional.BrowserTestCase):
+
+ def testAllRolePermissionsForm(self):
+ response = self.publish(
+ '/++etc++site/@@AllRolePermissions.html',
+ basic='mgr:mgrpw')
+ self.assertEqual(response.getStatus(), 200)
+ body = response.getBody()
+ self.assert_('Permissions' in body)
+ self.assert_('Manage Content' in body)
+ self.assert_('Manage Site' in body)
+ self.assert_('Roles' in body)
+ self.assert_('Site Manager' in body)
+ self.assert_('Site Member' in body)
+ self.failIf(_result in body)
+ self.checkForBrokenLinks(body,
+ '/++etc++site/@@AllRolePermissions.html',
+ 'mgr:mgrpw')
+
+ def testAllRolePermissions(self):
+ response = self.publish(
+ '/++etc++site/@@AllRolePermissions.html',
+ form={'p0r0': 'Allow',
+ 'p0': 'zope.ManageContent',
+ 'r0': 'zope.Manager',
+ 'SUBMIT': 'Save Changes'},
+ basic='mgr:mgrpw')
+ self.assertEqual(response.getStatus(), 200)
+ body = response.getBody()
+ self.assert_('<p>Settings changed' in body)
+ self.assert_(_result in body)
+
+ def testRolesWithPermissionsForm(self):
+ response = self.publish(
+ '/++etc++site/@@RolesWithPermissions.html'
+ '?permission_to_manage=zope.View',
+ basic='mgr:mgrpw')
+ self.assertEqual(response.getStatus(), 200)
+ body = response.getBody()
+ self.assert_('Roles assigned to the permission' in body)
+ self.assert_('Role' in body)
+ self.assert_('Setting' in body)
+ self.assert_('"Save Changes"' in body)
+ self.checkForBrokenLinks(body, '/@@RolesWithPermissions.html',
+ 'mgr:mgrpw')
+
+ def testRolesWithPermissionsForm(self):
+ response = self.publish(
+ '/++etc++site/@@RolePermissions.html?role_to_manage=zope.Manager',
+ basic='mgr:mgrpw')
+ self.assertEqual(response.getStatus(), 200)
+ body = response.getBody()
+ self.assert_(
+ 'This page shows the permissions allowed and denied the role'
+ in body)
+ self.assert_('Allow' in body)
+ self.assert_('Deny' in body)
+ self.checkForBrokenLinks(body, '/++etc++site/@@RolesPermissions.html',
+ 'mgr:mgrpw')
+
+ def testAllRolePermissionsFormForLocalRoles(self):
+ role = Role(u"id", u"Local Role")
+ zope.component.provideUtility(role, IRole)
+ self.testAllRolePermissions()
+
+ response = self.publish(
+ '/++etc++site/@@AllRolePermissions.html',
+ basic='mgr:mgrpw')
+ body = response.getBody()
+ self.assert_('Local Role' in body)
+
+ def testAllRolePermissionsFormForLocalPermissions(self):
+ permission = Permission(u"id", u"Local Permission")
+ zope.component.provideUtility(permission, IPermission)
+ self.testAllRolePermissions()
+
+ response = self.publish(
+ '/++etc++site/@@AllRolePermissions.html',
+ basic='mgr:mgrpw')
+ body = response.getBody()
+ self.assert_('Local Permission' in body)
+
+ def testRolesWithPermissionsFormForLocalPermission(self):
+ permission = Permission(u"id", u"Local Permission")
+ zope.component.provideUtility(permission, IPermission, 'id')
+
+ response = self.publish(
+ '/++etc++site/@@AllRolePermissions.html',
+ form={'role_id': 'zope.Manager',
+ 'Allow': ['id'],
+ 'Deny': ['id'],
+ 'SUBMIT_ROLE': 'Save Changes'},
+ basic='mgr:mgrpw',
+ handle_errors=True)
+ body = response.getBody()
+ self.assert_('You choose both allow and deny for permission'
+ ' "Local Permission". This is not allowed.' in body)
+
+_result = '''\
+ <option value="Unset"> </option>
+ <option value="Allow" selected="selected">+</option>
+ <option value="Deny">-</option>
+'''
+
+
+checker = renormalizing.RENormalizing([
+ (re.compile(r"HTTP/1\.1 (\d\d\d) .*"), r"HTTP/1.1 \1 <MESSAGE>"),
+ ])
+
+
+def test_suite():
+ RolePermissionsTest.layer = SecurityPolicyLayer
+ granting = functional.FunctionalDocFileSuite(
+ '../granting_ftest.txt', checker=checker)
+ granting.layer = SecurityPolicyLayer
+ return unittest.TestSuite((
+ unittest.makeSuite(RolePermissionsTest),
+ granting,
+ ))
+
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Modified: zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/ftesting.zcml
===================================================================
--- zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/ftesting.zcml 2007-10-31 19:41:26 UTC (rev 81328)
+++ zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/ftesting.zcml 2007-10-31 19:53:46 UTC (rev 81329)
@@ -14,13 +14,14 @@
<include package="zope.app.securitypolicy" />
<securityPolicy
- component="zope.app.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
+ component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
<role id="zope.Manager" title="Site Manager" />
<role id="zope.Member" title="Site Member" />
<grantAll role="zope.Manager" />
- <include package="zope.app.securitypolicy.browser.tests" file="functional.zcml" />
+ <include package="zope.app.securitypolicy.browser.tests"
+ file="functional.zcml" />
<!-- Principal that tests generally run as -->
<principal
Modified: zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/principalpermission.py
===================================================================
--- zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/principalpermission.py 2007-10-31 19:41:26 UTC (rev 81328)
+++ zope.app.securitypolicy/trunk/src/zope/app/securitypolicy/principalpermission.py 2007-10-31 19:53:46 UTC (rev 81329)
@@ -19,8 +19,8 @@
import zope.deferredimport
zope.deferredimport.deprecated(
- "It has moved to zope.securitypolicy.principalpermission This reference will be "
- "removed somedays",
+ "It has moved to zope.securitypolicy.principalpermission This reference "
+ "will be removed somedays",
AnnotationPrincipalPermissionManager = 'zope.securitypolicy.principalpermission:AnnotationPrincipalPermissionManager',
PrincipalPermissionManager = 'zope.securitypolicy.principalpermission:PrincipalPermissionManager',
principalPermissionManager = 'zope.securitypolicy.principalpermission:principalPermissionManager',
More information about the Checkins
mailing list