view MoinMoin/groups/_tests/ @ 4802:878b5a87ba3b

Groups2009: BackendManager was killed. GroupManager tests updated to use config_group.
author Dmitrijs Milajevs <>
date Wed, 10 Jun 2009 20:32:42 +0200
parents 1b84b35fbe91
children 167db6117bb4
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
MoinMoin.groups.GroupManager ACL Tests

@copyright: 2009 MoinMoin:DmitrijsMilajevs
            2008 MoinMoin:MelitaMihaljevic
@license: GPL, see COPYING for details

from MoinMoin import security
from MoinMoin.groups import GroupManager
from MoinMoin.groups.backends import config_group

class TestGroupManagerACL:
    Test how GroupManager works with the acl code.

    from MoinMoin._tests import wikiconfig
    class Config(wikiconfig.Config):
        def group_manager_init(self, request):
            groups = {u'FirstGroup': frozenset([u"ExampleUser", u"SecondUser", u"JoeDoe"]),
                      u'SecondGroup': frozenset([u"ExampleUser", u"ThirdUser"])}

            return GroupManager(backends=[config_group.Backend(request, groups)])

    def testConfigBackendAcl(self):
        test if the group config backend works with acl code
        # define acl rights for FirstGroup, members of group can read and write
        acl_rights = ["FirstGroup:admin,read,write"]
        acl = security.AccessControlList(self.request.cfg, acl_rights)

        allow = acl.may(self.request, u"JoeDoe", "admin")
        # JoeDoe has admin rights because he is a member of group FirstGroup
        assert allow

        allow = acl.may(self.request, u"AnotherUser", "admin")
        # AnotherUser has no read rights because he is not a member of group FirstGroup
        assert not allow

coverage_modules = ['MoinMoin.groups']