changeset 4818:66b7c4fe0265

Groups2009: Right exception handling for a group retrieval from the config_groups backend. If group does not exist GroupDoesNotExistError is raised. Test for acl added where in the acl definition not existing group is used.
author Dmitrijs Milajevs <dimazest@gmail.com>
date Wed, 24 Jun 2009 20:03:29 +0200
parents 9a305dadab7a
children 05a605c107ed
files MoinMoin/groups/backends/_tests/__init__.py MoinMoin/groups/backends/config_groups.py
diffstat 2 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/groups/backends/_tests/__init__.py	Wed Jun 24 19:36:32 2009 +0200
+++ b/MoinMoin/groups/backends/_tests/__init__.py	Wed Jun 24 20:03:29 2009 +0200
@@ -97,7 +97,7 @@
         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'
 
-    def test_wiki_backend_page_acl_with_all(self):
+    def test_backend_acl_with_all(self):
         request = self.request
 
         acl_rights = ["EditorGroup:read,write,delete,admin All:read"]
@@ -115,6 +115,14 @@
         assert not acl.may(request, u"Someone", "delete")
         assert not acl.may(request, u"Someone", "admin")
 
+    def test_backend_acl_not_existing_group(self):
+        request = self.request
+        assert u'NotExistingGroup' not in request.groups
+
+        acl_rights = ["NotExistingGroup:read,write,delete,admin All:read"]
+        acl = security.AccessControlList(request.cfg, acl_rights)
+
+        assert not acl.may(request, u"Someone", "write")
 
 coverage_modules = ['MoinMoin.groups.backends.config_group']
 
--- a/MoinMoin/groups/backends/config_groups.py	Wed Jun 24 19:36:32 2009 +0200
+++ b/MoinMoin/groups/backends/config_groups.py	Wed Jun 24 20:03:29 2009 +0200
@@ -33,11 +33,11 @@
         return self._groups.iterkeys()
 
     def __getitem__(self, group_name):
+        return Group(request=self.request, name=group_name, backend=self)
+
+    def _retrieve_members(self, group_name):
         try:
-            return Group(request=self.request, name=group_name, backend=self)
+            return self._groups[group_name]
         except KeyError:
             raise GroupDoesNotExistError(group_name)
 
-    def _retrieve_members(self, group_name):
-        return self._groups[group_name]
-