Пример #1
0
    def testACL(self):
        block = self._createTestBlocking()
        grp = Group()
        grp.setName('Test')
        GroupHolder().add(grp)

        self.assertFalse(block.canOverride(self._avatar1))
        self.assertTrue(block.canOverride(self._avatar2))
        self.assertFalse(block.canOverride(self._avatar3))
        self.assertTrue(block.canOverride(self._avatar4))
        # Add user to acl
        block.addAllowed(self._avatar1)
        self.assertTrue(block.canOverride(self._avatar1))
        # Add empty group to acl
        block.addAllowed(grp)
        self.assertTrue(block.canOverride(self._avatar1))
        self.assertTrue(block.canOverride(self._avatar2))
        self.assertFalse(block.canOverride(self._avatar3))
        self.assertTrue(block.canOverride(self._avatar4))
        # Add user to group
        grp.addMember(self._avatar3)
        self.assertTrue(block.canOverride(self._avatar3))
        # Remove user from acl
        block.delAllowed(self._avatar1)
        self.assertFalse(block.canOverride(self._avatar1))
        # But add him to a permitted group!
        grp.addMember(self._avatar1)
        self.assertTrue(block.canOverride(self._avatar1))
        # Remove users from group
        for m in list(grp.getMemberList()):
            grp.removeMember(m)
        self.assertFalse(block.canOverride(self._avatar1))
        self.assertTrue(block.canOverride(self._avatar2))
        self.assertFalse(block.canOverride(self._avatar3))
        self.assertTrue(block.canOverride(self._avatar4))
Пример #2
0
    def setUp(self):
        super(TestAuthentication, self).setUp()

        with self._context("database"):
            # Create few users and groups
            gh = GroupHolder()
            ah = AvatarHolder()
            self._authMgr = AuthenticatorMgr()

            for i in xrange(1, 3):
                group = Group()
                group.setName("fake-group-%d" % i)
                group.setDescription("fake")
                group.setEmail("*****@*****.**" % i)
                group.setId("fake-group-%d" % i)
                avatar = Avatar()
                avatar.setName("fake-%d" % i)
                avatar.setSurName("fake")
                avatar.setOrganisation("fake")
                avatar.setLang("en_GB")
                avatar.setEmail("*****@*****.**" % i)
                avatar.setId("fake-%d" % i)
                avatar.activateAccount()
                group.addMember(avatar)
                ah.add(avatar)
                gh.add(group)
                identity = self._authMgr.createIdentity(LoginInfo("fake-%d" % i, "fake-%d" % i), avatar, "Local")
                self._authMgr.add(identity)
Пример #3
0
    def setUp(self):
        super(TestAuthentication, self).setUp()

        with self._context("database"):
            # Create few users and groups
            gh = GroupHolder()
            ah = AvatarHolder()
            self._authMgr = AuthenticatorMgr()

            for i in xrange(1, 3):
                group = Group()
                group.setName("fake-group-%d" % i)
                group.setDescription("fake")
                group.setEmail("*****@*****.**" % i)
                group.setId("fake-group-%d" % i)
                avatar = Avatar()
                avatar.setName("fake-%d" % i)
                avatar.setSurName("fake")
                avatar.setOrganisation("fake")
                avatar.setLang("en_GB")
                avatar.setEmail("*****@*****.**" % i)
                avatar.setId("fake-%d" % i)
                avatar.activateAccount()
                group.addMember(avatar)
                ah.add(avatar)
                gh.add(group)
                identity = self._authMgr.createIdentity(
                    LoginInfo("fake-%d" % i, "fake-%d" % i), avatar, "Local")
                self._authMgr.add(identity)
Пример #4
0
    def testACL(self):
        block = self._createTestBlocking()
        grp = Group()
        grp.setName('Test')
        GroupHolder().add(grp)

        self.assertFalse(block.canOverride(self._avatar1))
        self.assertTrue(block.canOverride(self._avatar2))
        self.assertFalse(block.canOverride(self._avatar3))
        self.assertTrue(block.canOverride(self._avatar4))
        # Add user to acl
        block.addAllowed(self._avatar1)
        self.assertTrue(block.canOverride(self._avatar1))
        # Add empty group to acl
        block.addAllowed(grp)
        self.assertTrue(block.canOverride(self._avatar1))
        self.assertTrue(block.canOverride(self._avatar2))
        self.assertFalse(block.canOverride(self._avatar3))
        self.assertTrue(block.canOverride(self._avatar4))
        # Add user to group
        grp.addMember(self._avatar3)
        self.assertTrue(block.canOverride(self._avatar3))
        # Remove user from acl
        block.delAllowed(self._avatar1)
        self.assertFalse(block.canOverride(self._avatar1))
        # But add him to a permitted group!
        grp.addMember(self._avatar1)
        self.assertTrue(block.canOverride(self._avatar1))
        # Remove users from group
        for m in list(grp.getMemberList()):
            grp.removeMember(m)
        self.assertFalse(block.canOverride(self._avatar1))
        self.assertTrue(block.canOverride(self._avatar2))
        self.assertFalse(block.canOverride(self._avatar3))
        self.assertTrue(block.canOverride(self._avatar4))
Пример #5
0
def create_group(name, description, email):
    group = Group()
    group.setName(name)
    group.setDescription(description)
    group.setEmail(email)
    return group
Пример #6
0
def create_group(name, description, email):
    group = Group()
    group.setName(name)
    group.setDescription(description)
    group.setEmail(email)
    return group