annotate MoinMoin/groups/backends/_tests/__init__.py @ 4800:3b05bf18c0d1

Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
author Dmitrijs Milajevs <dimazest@gmail.com>
date Wed, 10 Jun 2009 20:32:42 +0200
parents
children 167db6117bb4
rev   line source
4800
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
2 """
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
3 MoinMoin - MoinMoin.groups.backends base test classes.
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
4
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
5 @copyright: 2003-2004 by Juergen Hermann <jh@web.de>,
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
6 2007 by MoinMoin:ThomasWaldmann
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
7 2008 by MoinMoin:MelitaMihaljevic
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
8 2009 by MoinMoin:DmitrijsMilajevs
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
9 @license: GNU GPL, see COPYING for details.
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
10
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
11 """
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
12
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
13 from py.test import raises
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
14
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
15 from MoinMoin import security
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
16 from MoinMoin._tests import wikiconfig
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
17
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
18 class Config(wikiconfig.Config):
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
19 # Simply drop the "Group" postfix for group names given to a backend.
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
20 # Note: in the real world, this would not work good enough:
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
21 to_backend_name = lambda self, group_name: group_name[:-5]
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
22 # Add "Group" postfix for group names received from a backend.
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
23 # Note: in the real world, this would not work good enough:
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
24 to_group_name = lambda self, backend_name:'%sGroup' % backend_name
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
25
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
26 class BackendTest(object):
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
27
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
28 test_groups = {u'EditorGroup': [u'AdminGroup', u'John', u'JoeDoe', u'Editor1'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
29 u'AdminGroup': [u'Admin1', u'Admin2', u'John'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
30 u'OtherGroup': [u'SomethingOther'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
31 u'RecursiveGroup': [u'Something', u'OtherRecursiveGroup'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
32 u'OtherRecursiveGroup': [u'RecursiveGroup', u'Anything'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
33 u'ThirdRecursiveGroup': [u'ThirdRecursiveGroup', u'Banana']}
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
34
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
35 expanded_groups = {u'EditorGroup': [u'Admin1', u'Admin2', u'John',
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
36 u'JoeDoe', u'Editor1'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
37 u'AdminGroup': [u'Admin1', u'Admin2', u'John'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
38 u'OtherGroup': [u'SomethingOther'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
39 u'RecursiveGroup': [u'Anything', u'Something'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
40 u'OtherRecursiveGroup': [u'Anything', u'Something'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
41 u'ThirdRecursiveGroup': [u'Banana']}
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
42
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
43 # These backend group names do not follow moin convention:
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
44 mapped_groups = {u'Editor': [u'Admin', u'John', u'JoeDoe', u'Editor1'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
45 u'Admin': [u'Admin1', u'Admin2', u'John'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
46 u'Other': [u'SomethingOther'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
47 u'Recursive': [u'Something', u'OtherRecursive'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
48 u'OtherRecursive': [u'Recursive', u'Anything'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
49 u'ThirdRecursive': [u'ThirdRecursive', u'Banana']}
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
50
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
51 def test_contains(self):
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
52 """
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
53 Test group_wiki Backend and Group containment methods.
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
54 """
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
55 groups = self.request.groups
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
56
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
57 for (group, members) in self.expanded_groups.iteritems():
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
58 print group
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
59 assert group in groups
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
60 for member in members:
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
61 assert member in groups[group]
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
62
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
63 raises(KeyError, lambda: groups[u'NotExistingGroup'])
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
64
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
65 def test_iter(self):
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
66 groups = self.request.groups
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
67
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
68 for (group, members) in self.expanded_groups.iteritems():
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
69 returned_members = [x for x in groups[group]]
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
70 assert len(returned_members) == len(members)
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
71 for member in members:
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
72 assert member in returned_members
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
73
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
74 def test_membergroups(self):
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
75 groups = self.request.groups
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
76
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
77 john_groups = groups.membergroups(u'John')
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
78 assert 2 == len(john_groups)
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
79 assert u'EditorGroup' in john_groups
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
80 assert u'AdminGroup' in john_groups
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
81 assert u'ThirdGroup' not in john_groups
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
82
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
83 def test_backend_acl_allow(self):
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
84 """
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
85 Test if the wiki group backend works with acl code.
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
86 Check user which has rights.
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
87 """
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
88 request = self.request
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
89
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
90 acl_rights = ["AdminGroup:admin,read,write"]
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
91 acl = security.AccessControlList(request.cfg, acl_rights)
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
92
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
93 allow = acl.may(request, u"Admin1", "admin")
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
94
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
95 assert allow, 'Admin has read rights because he is member of AdminGroup'
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
96
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
97 def test_backend_acl_deny(self):
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
98 """
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
99 Test if the wiki group backend works with acl code.
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
100 Check user which does not have rights.
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
101 """
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
102 request = self.request
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
103
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
104 acl_rights = ["AdminGroup:read,write"]
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
105 acl = security.AccessControlList(request.cfg, acl_rights)
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
106
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
107 other_user_allow = acl.may(request, u"OtherUser", "admin")
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
108 some_user_allow = acl.may(request, u"SomeUser", "read")
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
109
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
110 assert not other_user_allow, 'OtherUser does not have admin rights because it is not listed in acl'
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
111 assert not some_user_allow, 'SomeUser does not have admin read right because he is not listed in the AdminGroup'
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
112
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
113 def test_wiki_backend_page_acl_with_all(self):
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
114 request = self.request
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
115
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
116 acl_rights = ["EditorGroup:read,write,delete,admin All:read"]
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
117 acl = security.AccessControlList(request.cfg, acl_rights)
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
118
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
119
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
120 for member in self.expanded_groups[u'EditorGroup']:
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
121 assert acl.may(request, member, "read")
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
122 assert acl.may(request, member, "write")
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
123 assert acl.may(request, member, "delete")
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
124 assert acl.may(request, member, "admin")
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
125
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
126 assert acl.may(request, u"Someone", "read")
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
127 assert not acl.may(request, u"Someone", "write")
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
128 assert not acl.may(request, u"Someone", "delete")
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
129 assert not acl.may(request, u"Someone", "admin")
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
130
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
131 class BackendTestMapping(BackendTest):
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
132 """
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
133 Test group name mapping:
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
134 moin -> backend (e.g. "AdminGroup" -> "ImportantAdminGroup")
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
135 backend -> moin (e.g. "ImportantAdminGroup" -> "AdminGroup")
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
136
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
137 Moin expects group names to match the page_group_regex (e.g. "AdminGroup"),
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
138 but a backend might want to use different group names (e.g. just "ImportantAdminGroup").
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
139 """
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
140 test_groups = {u'ImportantEditorGroup': [u'ImportantAdminGroup', u'John',
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
141 u'JoeDoe', u'Editor'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
142 u'ImportantAdminGroup': [u'Admin', u'Admin2', u'John'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
143 u'ImportantOtherGroup': [u'SomethingOther'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
144 u'ImportantRecursiveGroup': [u'Something', u'ImportantOtherRecursiveGroup'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
145 u'ImportantOtherRecursiveGroup': [u'ImportantRecursiveGroup', u'Anything'],
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
146 u'ImportantThirdRecursiveGroup': [u'ImportantThirdRecursiveGroup', u'Banana']}
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
147
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
148
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
149 coverage_modules = ['MoinMoin.groups.backends.config_group']
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
150