Back to index

moin  1.9.0~rc2
Public Member Functions | Static Public Attributes
MoinMoin.datastruct.backends._tests.test_wiki_groups.TestWikiGroupBackend Class Reference
Inheritance diagram for MoinMoin.datastruct.backends._tests.test_wiki_groups.TestWikiGroupBackend:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.datastruct.backends._tests.test_wiki_groups.TestWikiGroupBackend:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setup_class
def teardown_class
def test_rename_group_page
def test_copy_group_page
def test_appending_group_page
def test_user_addition_to_group_page
def test_member_removed_from_group_page
def test_group_page_user_addition_trivial_change
def test_wiki_backend_page_acl_append_page
def test_contains
def test_contains_group
def test_iter
def test_get
def test_groups_with_member
def test_backend_acl_allow
def test_backend_acl_deny
def test_backend_acl_with_all
def test_backend_acl_not_existing_group

Static Public Attributes

dictionary test_groups
dictionary expanded_groups

Detailed Description

Definition at line 23 of file test_wiki_groups.py.


Member Function Documentation

Definition at line 28 of file test_wiki_groups.py.

00028 
00029     def setup_class(self):
00030         become_trusted(self.request)
00031 
00032         for group, members in self.test_groups.iteritems():
00033             page_text = ' * %s' % '\n * '.join(members)
00034             create_page(self.request, group, page_text)

Here is the call graph for this function:

Definition at line 35 of file test_wiki_groups.py.

00035 
00036     def teardown_class(self):
00037         become_trusted(self.request)
00038 
00039         for group in self.test_groups:
00040             nuke_page(self.request, group)

Here is the call graph for this function:

Test scalability by appending a name to a large list of group members.

Definition at line 73 of file test_wiki_groups.py.

00073 
00074     def test_appending_group_page(self):
00075         """
00076         Test scalability by appending a name to a large list of group members.
00077         """
00078         request = self.request
00079         become_trusted(request)
00080 
00081         # long list of users
00082         page_content = [u" * %s" % member for member in create_random_string_list(length=15, count=1234)]
00083         test_user = create_random_string_list(length=15, count=1)[0]
00084         create_page(request, u'UserGroup', "\n".join(page_content))
00085         append_page(request, u'UserGroup', u' * %s' % test_user)
00086         result = test_user in request.groups['UserGroup']
00087         nuke_page(request, u'UserGroup')
00088 
00089         assert result

Here is the call graph for this function:

Test if the wiki group backend works with acl code.
Check user which has rights.

Definition at line 86 of file __init__.py.

00086 
00087     def test_backend_acl_allow(self):
00088         """
00089         Test if the wiki group backend works with acl code.
00090         Check user which has rights.
00091         """
00092         request = self.request
00093 
00094         acl_rights = ["AdminGroup:admin,read,write"]
00095         acl = security.AccessControlList(request.cfg, acl_rights)
00096 
00097         for user in self.expanded_groups['AdminGroup']:
00098             for permission in ["read", "write", "admin"]:
00099                 assert acl.may(request, u"Admin1", permission), '%s must have %s permission because he is member of the AdminGroup' % (user, permission)

Here is the call graph for this function:

Test if the wiki group backend works with acl code.
Check user which does not have rights.

Definition at line 100 of file __init__.py.

00100 
00101     def test_backend_acl_deny(self):
00102         """
00103         Test if the wiki group backend works with acl code.
00104         Check user which does not have rights.
00105         """
00106         request = self.request
00107 
00108         acl_rights = ["AdminGroup:read,write"]
00109         acl = security.AccessControlList(request.cfg, acl_rights)
00110 
00111         assert u"SomeUser" not in request.groups['AdminGroup']
00112         for permission in ["read", "write"]:
00113             assert not acl.may(request, u"SomeUser", permission), 'SomeUser must not have %s permission because he is not listed in the AdminGroup' % permission
00114 
00115         assert u'Admin1' in request.groups['AdminGroup']
00116         assert not acl.may(request, u"Admin1", "admin")

Here is the call graph for this function:

Definition at line 131 of file __init__.py.

00131 
00132     def test_backend_acl_not_existing_group(self):
00133         request = self.request
00134         assert u'NotExistingGroup' not in request.groups
00135 
00136         acl_rights = ["NotExistingGroup:read,write,delete,admin All:read"]
00137         acl = security.AccessControlList(request.cfg, acl_rights)
00138 
00139         assert not acl.may(request, u"Someone", "write")
00140 

Here is the call graph for this function:

Definition at line 117 of file __init__.py.

00117 
00118     def test_backend_acl_with_all(self):
00119         request = self.request
00120 
00121         acl_rights = ["EditorGroup:read,write,delete,admin All:read"]
00122         acl = security.AccessControlList(request.cfg, acl_rights)
00123 
00124         for member in self.expanded_groups[u'EditorGroup']:
00125             for permission in ["read", "write", "delete", "admin"]:
00126                 assert acl.may(request, member, permission)
00127 
00128         assert acl.may(request, u"Someone", "read")
00129         for permission in ["write", "delete", "admin"]:
00130             assert not acl.may(request, u"Someone", permission)

Here is the call graph for this function:

Test group_wiki Backend and Group containment methods.

Definition at line 41 of file __init__.py.

00041 
00042     def test_contains(self):
00043         """
00044         Test group_wiki Backend and Group containment methods.
00045         """
00046         groups = self.request.groups
00047 
00048         for group, members in self.expanded_groups.iteritems():
00049             assert group in groups
00050             for member in members:
00051                 assert member in groups[group]
00052 
00053         raises(GroupDoesNotExistError, lambda: groups[u'NotExistingGroup'])

Reimplemented in MoinMoin.datastruct.backends._tests.test_lazy_config_groups.TestLazyConfigGroups.

Definition at line 54 of file __init__.py.

00054 
00055     def test_contains_group(self):
00056         groups = self.request.groups
00057 
00058         assert u'AdminGroup' in groups[u'EditorGroup']
00059         assert u'EditorGroup' not in groups[u'AdminGroup']

Tests if the groups cache is refreshed after copying a Group page.

Definition at line 56 of file test_wiki_groups.py.

00056 
00057     def test_copy_group_page(self):
00058         """
00059         Tests if the groups cache is refreshed after copying a Group page.
00060         """
00061         request = self.request
00062         become_trusted(request)
00063 
00064         page = create_page(request, u'SomeGroup', u" * ExampleUser")
00065         page.copyPage(u'SomeOtherGroup')
00066 
00067         result = u'ExampleUser' in request.groups[u'SomeOtherGroup']
00068 
00069         nuke_page(request, u'OtherGroup')
00070         nuke_page(request, u'SomeGroup')
00071 
00072         assert result is True

Here is the call graph for this function:

Definition at line 69 of file __init__.py.

00069 
00070     def test_get(self):
00071         groups = self.request.groups
00072 
00073         assert groups.get(u'AdminGroup')
00074         assert u'NotExistingGroup' not in groups
00075         assert groups.get(u'NotExistingGroup') is None
00076         assert groups.get(u'NotExistingGroup', []) == []

Test addition of a user to a group page by trivial change.

Definition at line 136 of file test_wiki_groups.py.

00136 
00137     def test_group_page_user_addition_trivial_change(self):
00138         """
00139         Test addition of a user to a group page by trivial change.
00140         """
00141         request = self.request
00142         become_trusted(request)
00143 
00144         test_user = create_random_string_list(length=15, count=1)[0]
00145         member = u" * %s\n" % test_user
00146         page = create_page(request, u'UserGroup', member)
00147 
00148         # next member saved  as trivial change
00149         test_user = create_random_string_list(length=15, count=1)[0]
00150         member = u" * %s\n" % test_user
00151         page.saveText(member, 0, trivial=1)
00152 
00153         result = test_user in request.groups[u'UserGroup']
00154 
00155         nuke_page(request, u'UserGroup')
00156 
00157         assert result

Here is the call graph for this function:

Definition at line 77 of file __init__.py.

00077 
00078     def test_groups_with_member(self):
00079         groups = self.request.groups
00080 
00081         john_groups = list(groups.groups_with_member(u'John'))
00082         assert 2 == len(john_groups)
00083         assert u'EditorGroup' in john_groups
00084         assert u'AdminGroup' in john_groups
00085         assert u'ThirdGroup' not in john_groups

Definition at line 60 of file __init__.py.

00060 
00061     def test_iter(self):
00062         groups = self.request.groups
00063 
00064         for group, members in self.expanded_groups.iteritems():
00065             returned_members = list(groups[group])
00066             assert len(returned_members) == len(members)
00067             for member in members:
00068                 assert member in returned_members

Tests appending a member to a large list of group members and
recreating the page without the member.

Definition at line 113 of file test_wiki_groups.py.

00113 
00114     def test_member_removed_from_group_page(self):
00115         """
00116         Tests appending a member to a large list of group members and
00117         recreating the page without the member.
00118         """
00119         request = self.request
00120         become_trusted(request)
00121 
00122         # long list of users
00123         page_content = [u" * %s" % member for member in create_random_string_list()]
00124         page_content = "\n".join(page_content)
00125         create_page(request, u'UserGroup', page_content)
00126 
00127         test_user = create_random_string_list(length=15, count=1)[0]
00128         page = append_page(request, u'UserGroup', u' * %s' % test_user)
00129 
00130         # saves the text without test_user
00131         page.saveText(page_content, 0)
00132         result = test_user in request.groups[u'UserGroup']
00133         nuke_page(request, u'UserGroup')
00134 
00135         assert not result

Here is the call graph for this function:

Tests if the groups cache is refreshed after renaming a Group page.

Definition at line 41 of file test_wiki_groups.py.

00041 
00042     def test_rename_group_page(self):
00043         """
00044         Tests if the groups cache is refreshed after renaming a Group page.
00045         """
00046         request = self.request
00047         become_trusted(request)
00048 
00049         page = create_page(request, u'SomeGroup', u" * ExampleUser")
00050         page.renamePage('AnotherGroup')
00051 
00052         result = u'ExampleUser' in request.groups[u'AnotherGroup']
00053         nuke_page(request, u'AnotherGroup')
00054 
00055         assert result is True

Here is the call graph for this function:

Test addition of a username to a large list of group members.

Definition at line 90 of file test_wiki_groups.py.

00090 
00091     def test_user_addition_to_group_page(self):
00092         """
00093         Test addition of a username to a large list of group members.
00094         """
00095         request = self.request
00096         become_trusted(request)
00097 
00098         # long list of users
00099         page_content = [u" * %s" % member for member in create_random_string_list()]
00100         create_page(request, u'UserGroup', "\n".join(page_content))
00101 
00102         new_user = create_random_string_list(length=15, count=1)[0]
00103         append_page(request, u'UserGroup', u' * %s' % new_user)
00104         user = User(request, name=new_user)
00105         if not user.exists():
00106             User(request, name=new_user, password=new_user).save()
00107 
00108         result = new_user in request.groups[u'UserGroup']
00109         nuke_page(request, u'UserGroup')
00110         nuke_user(request, new_user)
00111 
00112         assert result

Here is the call graph for this function:

Test if the wiki group backend works with acl code.
First check acl rights of a user that is not a member of group
then add user member to a page group and check acl rights

Definition at line 158 of file test_wiki_groups.py.

00158 
00159     def test_wiki_backend_page_acl_append_page(self):
00160         """
00161         Test if the wiki group backend works with acl code.
00162         First check acl rights of a user that is not a member of group
00163         then add user member to a page group and check acl rights
00164         """
00165         request = self.request
00166         become_trusted(request)
00167 
00168         create_page(request, u'NewGroup', u" * ExampleUser")
00169 
00170         acl_rights = ["NewGroup:read,write"]
00171         acl = security.AccessControlList(request.cfg, acl_rights)
00172 
00173         has_rights_before = acl.may(request, u"AnotherUser", "read")
00174 
00175         # update page - add AnotherUser to a page group NewGroup
00176         append_page(request, u'NewGroup', u" * AnotherUser")
00177 
00178         has_rights_after = acl.may(request, u"AnotherUser", "read")
00179 
00180         nuke_page(request, u'NewGroup')
00181 
00182         assert not has_rights_before, 'AnotherUser has no read rights because in the beginning he is not a member of a group page NewGroup'
00183         assert has_rights_after, 'AnotherUser must have read rights because after appendage he is member of NewGroup'

Here is the call graph for this function:


Member Data Documentation

Initial value:
{u'EditorGroup': [u'Admin1', u'Admin2', u'John',
                                        u'JoeDoe', u'Editor1'],
                       u'AdminGroup': [u'Admin1', u'Admin2', u'John'],
                       u'OtherGroup': [u'SomethingOther'],
                       u'RecursiveGroup': [u'Anything', u'Something', u'NotExistingGroup'],
                       u'OtherRecursiveGroup': [u'Anything', u'Something', u'NotExistingGroup'],
                       u'ThirdRecursiveGroup': [u'Banana'],
                       u'EmptyGroup': [],
                       u'CheckNotExistingGroup': [u'NotExistingGroup']}

Reimplemented in MoinMoin.datastruct.backends._tests.test_lazy_config_groups.TestLazyConfigGroups.

Definition at line 31 of file __init__.py.

Initial value:
{u'EditorGroup': [u'AdminGroup', u'John', u'JoeDoe', u'Editor1', u'John'],
                   u'AdminGroup': [u'Admin1', u'Admin2', u'John'],
                   u'OtherGroup': [u'SomethingOther'],
                   u'RecursiveGroup': [u'Something', u'OtherRecursiveGroup'],
                   u'OtherRecursiveGroup': [u'RecursiveGroup', u'Anything', u'NotExistingGroup'],
                   u'ThirdRecursiveGroup': [u'ThirdRecursiveGroup', u'Banana'],
                   u'EmptyGroup': [],
                   u'CheckNotExistingGroup': [u'NotExistingGroup']}

Reimplemented in MoinMoin.datastruct.backends._tests.test_lazy_config_groups.TestLazyConfigGroups.

Definition at line 21 of file __init__.py.


The documentation for this class was generated from the following file: