[Zope3-checkins] CVS: Zope3/src/zope/products/securitypolicy/tests
- role.zcml:1.1.2.1 role_duplicate.zcml:1.1.2.1
test_rolecontents.py:1.1.2.1 test_roleregistry.py:1.1.2.1
test_roleservice.py:1.1.2.1
test_annotationprincipalrolemanager.py:1.1.2.2
test_annotationrolepermissionmanager.py:1.1.2.2
test_principalrolemanager.py:1.1.2.2
test_rolepermissionmanager.py:1.1.2.2
test_securitydirectives.py:1.1.2.2 test_zopepolicy.py:1.1.2.2
Chris McDonough
chrism at plope.com
Tue Jan 13 20:31:39 EST 2004
Update of /cvs-repository/Zope3/src/zope/products/securitypolicy/tests
In directory cvs.zope.org:/tmp/cvs-serv14028/src/zope/products/securitypolicy/tests
Modified Files:
Tag: steveachrismcd-securitypolicy-branch
test_annotationprincipalrolemanager.py
test_annotationrolepermissionmanager.py
test_principalrolemanager.py test_rolepermissionmanager.py
test_securitydirectives.py test_zopepolicy.py
Added Files:
Tag: steveachrismcd-securitypolicy-branch
role.zcml role_duplicate.zcml test_rolecontents.py
test_roleregistry.py test_roleservice.py
Log Message:
Move more role stuff out of Zope proper and into the securitypolicy product.
=== Added File Zope3/src/zope/products/securitypolicy/tests/role.zcml ===
<configure
xmlns="http://namespaces.zope.org/zope"
i18n_domain="zope"
>
<include package="zope.products.securitypolicy" file="meta.zcml"/>
<role
id="zope.Everyperson"
title="Tout le monde"
description="The common man, woman, person, or thing" />
</configure>
=== Added File Zope3/src/zope/products/securitypolicy/tests/role_duplicate.zcml ===
<configure
xmlns="http://namespaces.zope.org/zope"
i18n_domain="zope">
<include package="zope.products.securitypolicy" file="meta.zcml"/>
<role
id="zope.Everyperson"
title="Tout le monde"
description="The common man, woman, person, or thing" />
<role
id="zope.Everyperson"
title="Tout le monde"
description="The common man, woman, person, or thing" />
</configure>
=== Added File Zope3/src/zope/products/securitypolicy/tests/test_rolecontents.py ===
##############################################################################
#
# 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.
#
##############################################################################
"""
$Id: test_rolecontents.py,v 1.1.2.1 2004/01/14 01:31:38 chrism Exp $
"""
import unittest
from zope.interface import Interface, implements
from zope.products.securitypolicy.browser import Contents
from zope.products.securitypolicy.role import RoleService
from zope.app.browser.container.tests.test_contents \
import BaseTestContentsBrowserView, Principal
from zope.app.content.folder import rootFolder
from zope.app.container.contained import contained
class IDummy(Interface):
pass
class Dummy:
implements(IDummy)
class Test(BaseTestContentsBrowserView, unittest.TestCase):
def _TestView__newContext(self):
root = rootFolder()
container = RoleService()
return contained(container, root, name='sample')
def _TestView__newView(self, container):
from zope.publisher.browser import TestRequest
request = TestRequest()
request.setUser(Principal())
return Contents(container, request)
def test_suite():
loader = unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
if __name__=='__main__':
unittest.main()
=== Added File Zope3/src/zope/products/securitypolicy/tests/test_roleregistry.py ===
##############################################################################
#
# 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 'defineRole' directive """
import unittest
from zope.products.securitypolicy.roleregistry import roleRegistry
from zope.app.interfaces.security import IRole
from zope.interface.verify import verifyObject
from zope.testing.cleanup import CleanUp # Base class w registry cleanup
class Test(CleanUp, unittest.TestCase):
def testEmptyRoles(self):
self.assertEqual(None, roleRegistry.getRole('Foo'))
self.failIf(roleRegistry.definedRole('Foo'))
def testRoleIsAnIRole(self):
r = roleRegistry.defineRole('Foo', 'Foo role')
role = roleRegistry.getRole(r.getId())
self.assertEqual(verifyObject(IRole, role), 1)
def testDefineRole(self):
role = roleRegistry.defineRole('Foo', 'foo role')
self.failUnless(verifyObject(IRole, role))
self.failUnless(roleRegistry.definedRole(role.getId()))
role = roleRegistry.getRole(role.getId())
self.assertEquals(role.getTitle(), 'foo role')
def testDefineRoleWithTitle(self):
eq = self.assertEqual
r = roleRegistry.defineRole('Foo', 'Foo-able')
role = roleRegistry.getRole(r.getId())
eq(role.getTitle(), 'Foo-able')
eq(role.getDescription(), '')
def testDefineRoleWithTitleAndDescription(self):
eq = self.assertEqual
r = roleRegistry.defineRole('Foo', 'Foo-able', 'A foo-worthy role')
role = roleRegistry.getRole(r.getId())
eq(role.getTitle(), 'Foo-able')
eq(role.getDescription(), 'A foo-worthy role')
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
if __name__=='__main__':
unittest.TextTestRunner().run(test_suite())
=== Added File Zope3/src/zope/products/securitypolicy/tests/test_roleservice.py ===
##############################################################################
#
# 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 the Role service.
$Id: test_roleservice.py,v 1.1.2.1 2004/01/14 01:31:38 chrism Exp $
"""
from unittest import TestCase, TestLoader, TextTestRunner
from zope.app.tests import setup
from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.component import getServiceManager
from zope.app.interfaces.security import IRoleService
from zope.products.securitypolicy.roleregistry import roleRegistry
from zope.products.securitypolicy.role import RoleService
from zope.products.securitypolicy.role import Role
class RoleServiceTests(PlacefulSetup, TestCase):
def _Test__new(self):
return RoleService()
def setUp(self):
sm = PlacefulSetup.setUp(self, site=True)
root_sm = getServiceManager(None)
root_sm.defineService("Roles", IRoleService)
self.roleRegistry = roleRegistry
root_sm.provideService("Roles", roleRegistry)
self.rs = setup.addService(sm, 'Roles', RoleService())
def testGetRole(self):
self.roleRegistry.defineRole('zope.Manager', 'Manager', '')
r = Role("zope.Hacker","","")
self.rs["zope.Hacker"] = r
self.assertEqual(self.rs.getRole('zope.Hacker').getId(), 'zope.Hacker')
self.assertEqual(self.rs.getRole('zope.Manager').getId(),
'zope.Manager')
roles = [role.getId() for role in self.rs.getRoles()]
roles.sort()
self.assertEqual(roles,
['zope.Anonymous', 'zope.Hacker', 'zope.Manager'])
def testGetRoleFromLayeredServices(self):
self.roleRegistry.defineRole('zope.Manager', 'Manager', '')
r = Role("zope.Hacker","","")
self.rs["zope.Hacker"] = r
sm1 = self.makeSite('folder1')
rs1 = setup.addService(sm1, 'Roles', RoleService())
r1 = Role("zope.Reviewer",'','')
rs1["zope.Reviewer"] = r1
self.assertEqual(rs1.getRole('zope.Hacker').getId(), 'zope.Hacker')
self.assertEqual(rs1.getRole('zope.Manager').getId(), 'zope.Manager')
self.assertEqual(rs1.getRole('zope.Reviewer').getId(), 'zope.Reviewer')
roles = [role.getId() for role in rs1.getRoles()]
roles.sort()
self.assertEqual(
roles,
['zope.Anonymous', 'zope.Hacker', 'zope.Manager','zope.Reviewer'])
def test_suite():
loader=TestLoader()
return loader.loadTestsFromTestCase(RoleServiceTests)
if __name__=='__main__':
TextTestRunner().run(test_suite())
=== Zope3/src/zope/products/securitypolicy/tests/test_annotationprincipalrolemanager.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/products/securitypolicy/tests/test_annotationprincipalrolemanager.py:1.1.2.1 Tue Jan 13 18:34:21 2004
+++ Zope3/src/zope/products/securitypolicy/tests/test_annotationprincipalrolemanager.py Tue Jan 13 20:31:38 2004
@@ -20,7 +20,7 @@
from zope.app.services.servicenames import Adapters
from zope.app.interfaces.annotation import IAnnotations
from zope.app.attributeannotations import AttributeAnnotations
-from zope.app.security.registries.roleregistry import roleRegistry as rregistry
+from zope.products.securitypolicy.roleregistry import roleRegistry as rregistry
from zope.app.security.registries.principalregistry \
import principalRegistry as pregistry
from zope.products.securitypolicy.principalrole \
=== Zope3/src/zope/products/securitypolicy/tests/test_annotationrolepermissionmanager.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/products/securitypolicy/tests/test_annotationrolepermissionmanager.py:1.1.2.1 Tue Jan 13 18:34:21 2004
+++ Zope3/src/zope/products/securitypolicy/tests/test_annotationrolepermissionmanager.py Tue Jan 13 20:31:38 2004
@@ -21,7 +21,7 @@
from zope.app.services.servicenames import Permissions, Adapters
from zope.app.interfaces.security import IRoleService
from zope.app.interfaces.security import IPermissionService
-from zope.app.security.registries.roleregistry import roleRegistry
+from zope.products.securitypolicy.roleregistry import roleRegistry
from zope.app.security.registries.permissionregistry import permissionRegistry
from zope.app.security.settings import Allow, Deny
from zope.app.services.tests.placefulsetup import PlacefulSetup
=== Zope3/src/zope/products/securitypolicy/tests/test_principalrolemanager.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/products/securitypolicy/tests/test_principalrolemanager.py:1.1.2.1 Tue Jan 13 18:34:21 2004
+++ Zope3/src/zope/products/securitypolicy/tests/test_principalrolemanager.py Tue Jan 13 20:31:38 2004
@@ -21,7 +21,7 @@
from zope.app.interfaces.security import IRoleService
from zope.app.interfaces.security import IAuthenticationService
-from zope.app.security.registries.roleregistry \
+from zope.products.securitypolicy.roleregistry \
import roleRegistry as rregistry
from zope.app.security.registries.principalregistry \
import principalRegistry as pregistry
=== Zope3/src/zope/products/securitypolicy/tests/test_rolepermissionmanager.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/products/securitypolicy/tests/test_rolepermissionmanager.py:1.1.2.1 Tue Jan 13 18:34:21 2004
+++ Zope3/src/zope/products/securitypolicy/tests/test_rolepermissionmanager.py Tue Jan 13 20:31:38 2004
@@ -23,7 +23,7 @@
from zope.app.security.registries.permissionregistry \
import permissionRegistry as pregistry
-from zope.app.security.registries.roleregistry \
+from zope.products.securitypolicy.roleregistry \
import roleRegistry as rregistry
from zope.products.securitypolicy.rolepermission \
import rolePermissionManager as manager
=== Zope3/src/zope/products/securitypolicy/tests/test_securitydirectives.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/products/securitypolicy/tests/test_securitydirectives.py:1.1.2.1 Tue Jan 13 18:34:21 2004
+++ Zope3/src/zope/products/securitypolicy/tests/test_securitydirectives.py Tue Jan 13 20:31:38 2004
@@ -28,13 +28,13 @@
from zope.testing.cleanup import CleanUp # Base class w registry cleanup
-import zope.app.security.tests
+import zope.products.securitypolicy.tests
import zope.products.securitypolicy.tests
from zope.app.security.settings import Allow
from zope.app.security.registries.principalregistry import principalRegistry
from zope.app.security.registries.permissionregistry \
import permissionRegistry as pregistry
-from zope.app.security.registries.roleregistry import roleRegistry as rregistry
+from zope.products.securitypolicy.roleregistry import roleRegistry as rregistry
from zope.products.securitypolicy.rolepermission \
import rolePermissionManager as role_perm_mgr
from zope.products.securitypolicy.principalpermission \
@@ -60,7 +60,8 @@
class TestRoleDirective(TestBase, unittest.TestCase):
def testRegister(self):
- context = xmlconfig.file("role.zcml", zope.app.security.tests)
+ context = xmlconfig.file("role.zcml",
+ zope.products.securitypolicy.tests)
role = rregistry.getRole("zope.Everyperson")
self.failUnless(role.getId().endswith('Everyperson'))
@@ -70,7 +71,8 @@
def testDuplicationRegistration(self):
self.assertRaises(ConfigurationConflictError, xmlconfig.file,
- "role_duplicate.zcml", zope.app.security.tests)
+ "role_duplicate.zcml",
+ zope.products.securitypolicy.tests)
class TestSecurityMapping(TestBase, unittest.TestCase):
=== Zope3/src/zope/products/securitypolicy/tests/test_zopepolicy.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/products/securitypolicy/tests/test_zopepolicy.py:1.1.2.1 Tue Jan 13 18:34:21 2004
+++ Zope3/src/zope/products/securitypolicy/tests/test_zopepolicy.py Tue Jan 13 20:31:38 2004
@@ -33,7 +33,7 @@
from zope.app.security.registries.permissionregistry import permissionRegistry
from zope.app.security.registries.principalregistry import principalRegistry
from zope.app.security.registries.principalregistry import PrincipalBase
-from zope.app.security.registries.roleregistry import roleRegistry
+from zope.products.securitypolicy.roleregistry import roleRegistry
from zope.products.securitypolicy.principalpermission \
import principalPermissionManager
from zope.products.securitypolicy.rolepermission import rolePermissionManager
More information about the Zope3-Checkins
mailing list