changeset 4858:2c31e088e849

Groups2009: Notice in LazyGroup docstring that it cannot consist of other groups. Group tests refinements.
author Dmitrijs Milajevs <dimazest@gmail.com>
date Sat, 18 Jul 2009 16:06:41 +0200
parents 85c15a83b7f2
children 6a7395207387
files MoinMoin/datastruct/backends/__init__.py MoinMoin/datastruct/backends/_tests/__init__.py MoinMoin/datastruct/backends/_tests/test_lazy_config_groups.py
diffstat 3 files changed, 33 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/datastruct/backends/__init__.py	Fri Jul 17 12:40:57 2009 +0200
+++ b/MoinMoin/datastruct/backends/__init__.py	Sat Jul 18 16:06:41 2009 +0200
@@ -100,6 +100,21 @@
     """
     A lazy group does not store members internally, but gets them from
     a backend when needed.
+
+    Lazy group is made only of members. It can not consist of other groups.
+
+    For instance, this is a possible LazyGroup:
+
+     PossibleGroup
+      * OneMember
+      * OtherMember
+
+    This is a group which cannot be LazyGroup:
+
+     NotPossibleGroup
+      * OneMember
+      * OtherMember
+      * OtherGroup
     """
 
     def __init__(self, request, name, backend):
--- a/MoinMoin/datastruct/backends/_tests/__init__.py	Fri Jul 17 12:40:57 2009 +0200
+++ b/MoinMoin/datastruct/backends/_tests/__init__.py	Sat Jul 18 16:06:41 2009 +0200
@@ -92,9 +92,9 @@
         acl_rights = ["AdminGroup:admin,read,write"]
         acl = security.AccessControlList(request.cfg, acl_rights)
 
-        allow = acl.may(request, u"Admin1", "admin")
-
-        assert allow, 'Admin has read rights because he is member of AdminGroup'
+        for user in self.expanded_groups['AdminGroup']:
+            for action in ["read", "write", "admin"]:
+                assert acl.may(request, u"Admin1", action), '%s must have %s right because he is member of the AdminGroup' % (user, action)
 
     def test_backend_acl_deny(self):
         """
@@ -106,11 +106,12 @@
         acl_rights = ["AdminGroup:read,write"]
         acl = security.AccessControlList(request.cfg, acl_rights)
 
-        other_user_allow = acl.may(request, u"OtherUser", "admin")
-        some_user_allow = acl.may(request, u"SomeUser", "read")
+        assert u"SomeUser" not in request.groups['AdminGroup']
+        for action in ["read", "write"]:
+            assert not acl.may(request, u"SomeUser", action), 'SomeUser must not have %s right because he is not listed in the AdminGroup' % action
 
-        assert not other_user_allow, 'OtherUser does not have admin rights because it is not listed in acl'
-        assert not some_user_allow, 'SomeUser does not have admin read right because he is not listed in the AdminGroup'
+        assert u'Admin1' in request.groups['AdminGroup']
+        assert not acl.may(request, u"Admin1", "admin")
 
     def test_backend_acl_with_all(self):
         request = self.request
@@ -118,17 +119,13 @@
         acl_rights = ["EditorGroup:read,write,delete,admin All:read"]
         acl = security.AccessControlList(request.cfg, acl_rights)
 
-
         for member in self.expanded_groups[u'EditorGroup']:
-            assert acl.may(request, member, "read")
-            assert acl.may(request, member, "write")
-            assert acl.may(request, member, "delete")
-            assert acl.may(request, member, "admin")
+            for action in ["read", "write", "delete", "admin"]:
+                assert acl.may(request, member, action)
 
         assert acl.may(request, u"Someone", "read")
-        assert not acl.may(request, u"Someone", "write")
-        assert not acl.may(request, u"Someone", "delete")
-        assert not acl.may(request, u"Someone", "admin")
+        for action in ["write", "delete", "admin"]:
+            assert not acl.may(request, u"Someone", action)
 
     def test_backend_acl_not_existing_group(self):
         request = self.request
--- a/MoinMoin/datastruct/backends/_tests/test_lazy_config_groups.py	Fri Jul 17 12:40:57 2009 +0200
+++ b/MoinMoin/datastruct/backends/_tests/test_lazy_config_groups.py	Sat Jul 18 16:06:41 2009 +0200
@@ -18,8 +18,7 @@
     test_groups = {u'EditorGroup': [u'John', u'JoeDoe', u'Editor1'],
                    u'AdminGroup': [u'Admin1', u'Admin2', u'John'],
                    u'OtherGroup': [u'SomethingOther'],
-                   u'EmptyGroup': [],
-                   u'CheckNotExistingGroup': [u'NotExistingGroup']}
+                   u'EmptyGroup': []}
 
     expanded_groups = test_groups
 
@@ -30,7 +29,11 @@
             return ConfigLazyGroups(request, groups)
 
     def test_contains_group(self):
-        pass
+        """
+        ConfigLazyGroups can not contain other group members.
+
+        This test does not have sense.
+        """
 
 
 class TestCompositeAndLazyConfigGroups(GroupsBackendTest):