コード例 #1
0
ファイル: test_security.py プロジェクト: timgates42/Kotti
    def test_copy_local_groups(self, db_session, root):
        from kotti.security import principals_with_local_roles
        from kotti.security import set_groups

        self.test_principals_with_local_roles(db_session, root)
        child = root["child"]
        assert set(principals_with_local_roles(child)) == {
            "bob",
            "group:bobsgroup",
            "group:franksgroup",
        }

        # We make a copy of 'child', and we expect the local roles set
        # on 'child' to not be copied over:
        child2 = root["child2"] = child.copy()
        db_session.flush()
        assert set(principals_with_local_roles(child2)) == {
            "bob", "group:franksgroup"
        }
        assert len(principals_with_local_roles(child)) == 3

        # When we now change the local roles of 'child', the copy is
        # unaffected:
        set_groups("group:bobsgroup", child, [])
        assert len(principals_with_local_roles(child)) == 2
        assert len(principals_with_local_roles(child2)) == 2
コード例 #2
0
    def test_copy_local_groups(self, db_session, root):
        from kotti.security import principals_with_local_roles
        from kotti.security import set_groups

        self.test_principals_with_local_roles(db_session, root)
        child = root[u'child']
        assert (
            set(principals_with_local_roles(child)) ==
            set(['bob', 'group:bobsgroup', 'group:franksgroup'])
            )

        # We make a copy of 'child', and we expect the local roles set
        # on 'child' to not be copied over:
        child2 = root['child2'] = child.copy()
        db_session.flush()
        assert (
            set(principals_with_local_roles(child2)) ==
            set([u'bob', u'group:franksgroup']))
        assert len(principals_with_local_roles(child)) == 3

        # When we now change the local roles of 'child', the copy is
        # unaffected:
        set_groups('group:bobsgroup', child, [])
        assert len(principals_with_local_roles(child)) == 2
        assert len(principals_with_local_roles(child2)) == 2
コード例 #3
0
ファイル: test_security.py プロジェクト: timgates42/Kotti
    def test_principals_with_local_roles(self, db_session, root):
        from kotti.resources import Node
        from kotti.security import map_principals_with_local_roles
        from kotti.security import principals_with_local_roles
        from kotti.security import set_groups

        child = root["child"] = Node()
        db_session.flush()

        assert principals_with_local_roles(root) == []
        assert principals_with_local_roles(child) == []
        assert map_principals_with_local_roles(root) == []
        assert map_principals_with_local_roles(child) == []

        set_groups("group:bobsgroup", child, ["role:editor"])
        set_groups("bob", root, ["group:bobsgroup"])
        set_groups("group:franksgroup", root, ["role:editor"])

        assert set(principals_with_local_roles(child)) == {
            "bob",
            "group:bobsgroup",
            "group:franksgroup",
        }
        assert set(principals_with_local_roles(
            child, inherit=False)) == {"group:bobsgroup"}
        assert set(
            principals_with_local_roles(root)) == {"bob", "group:franksgroup"}
コード例 #4
0
    def test_principals_with_local_roles(self, db_session, root):
        from kotti.resources import Node
        from kotti.security import map_principals_with_local_roles
        from kotti.security import principals_with_local_roles
        from kotti.security import set_groups

        child = root[u'child'] = Node()
        db_session.flush()

        assert principals_with_local_roles(root) == []
        assert principals_with_local_roles(child) == []
        assert map_principals_with_local_roles(root) == []
        assert map_principals_with_local_roles(child) == []

        set_groups('group:bobsgroup', child, ['role:editor'])
        set_groups('bob', root, ['group:bobsgroup'])
        set_groups('group:franksgroup', root, ['role:editor'])

        assert (set(principals_with_local_roles(child)) == {
            'bob', 'group:bobsgroup', 'group:franksgroup'
        })
        assert (set(principals_with_local_roles(
            child, inherit=False)) == {'group:bobsgroup'})
        assert (set(
            principals_with_local_roles(root)) == {'bob', 'group:franksgroup'})
コード例 #5
0
    def test_principals_with_local_roles(self, db_session, root):
        from kotti.resources import Node
        from kotti.security import map_principals_with_local_roles
        from kotti.security import principals_with_local_roles
        from kotti.security import set_groups

        child = root[u'child'] = Node()
        db_session.flush()

        assert principals_with_local_roles(root) == []
        assert principals_with_local_roles(child) == []
        assert map_principals_with_local_roles(root) == []
        assert map_principals_with_local_roles(child) == []

        set_groups('group:bobsgroup', child, ['role:editor'])
        set_groups('bob', root, ['group:bobsgroup'])
        set_groups('group:franksgroup', root, ['role:editor'])

        assert (
            set(principals_with_local_roles(child)) ==
            set(['bob', 'group:bobsgroup', 'group:franksgroup'])
            )
        assert (
            set(principals_with_local_roles(child, inherit=False)) ==
            set(['group:bobsgroup'])
            )
        assert (
            set(principals_with_local_roles(root)) ==
            set(['bob', 'group:franksgroup'])
            )
コード例 #6
0
ファイル: test_security.py プロジェクト: Doik/Kotti
    def test_copy_local_groups(self):
        from kotti import DBSession
        from kotti.resources import get_root
        from kotti.security import principals_with_local_roles
        from kotti.security import set_groups

        self.test_principals_with_local_roles()
        root = get_root()
        child = root[u'child']
        self.assertEqual(
            set(principals_with_local_roles(child)),
            set(['bob', 'group:bobsgroup', 'group:franksgroup'])
            )

        # We make a copy of 'child', and we expect the local roles set
        # on 'child' to not be copied over:
        child2 = root['child2'] = child.copy()
        DBSession.flush()
        self.assertEqual(
            set(principals_with_local_roles(child2)),
            set([u'bob', u'group:franksgroup']),
            )
        self.assertEqual(len(principals_with_local_roles(child)), 3)

        # When we now change the local roles of 'child', the copy is
        # unaffected:
        set_groups('group:bobsgroup', child, [])
        self.assertEqual(len(principals_with_local_roles(child)), 2)
        self.assertEqual(len(principals_with_local_roles(child2)), 2)
コード例 #7
0
ファイル: test_security.py プロジェクト: Doik/Kotti
    def test_principals_with_local_roles(self):
        from kotti import DBSession
        from kotti.resources import get_root
        from kotti.resources import Node
        from kotti.security import map_principals_with_local_roles
        from kotti.security import principals_with_local_roles
        from kotti.security import set_groups

        root = get_root()
        child = root[u'child'] = Node()
        DBSession.flush()

        self.assertEqual(principals_with_local_roles(root), [])
        self.assertEqual(principals_with_local_roles(child), [])
        self.assertEqual(map_principals_with_local_roles(root), [])
        self.assertEqual(map_principals_with_local_roles(child), [])

        set_groups('group:bobsgroup', child, ['role:editor'])
        set_groups('bob', root, ['group:bobsgroup'])
        set_groups('group:franksgroup', root, ['role:editor'])

        self.assertEqual(
            set(principals_with_local_roles(child)),
            set(['bob', 'group:bobsgroup', 'group:franksgroup'])
            )
        self.assertEqual(
            set(principals_with_local_roles(child, inherit=False)),
            set(['group:bobsgroup'])
            )
        self.assertEqual(
            set(principals_with_local_roles(root)),
            set(['bob', 'group:franksgroup'])
            )
コード例 #8
0
ファイル: test_security.py プロジェクト: Doik/Kotti
    def test_copy_local_groups(self):
        from kotti import DBSession
        from kotti.resources import get_root
        from kotti.security import principals_with_local_roles
        from kotti.security import set_groups

        self.test_principals_with_local_roles()
        root = get_root()
        child = root[u'child']
        self.assertEqual(set(principals_with_local_roles(child)),
                         set(['bob', 'group:bobsgroup', 'group:franksgroup']))

        # We make a copy of 'child', and we expect the local roles set
        # on 'child' to not be copied over:
        child2 = root['child2'] = child.copy()
        DBSession.flush()
        self.assertEqual(
            set(principals_with_local_roles(child2)),
            set([u'bob', u'group:franksgroup']),
        )
        self.assertEqual(len(principals_with_local_roles(child)), 3)

        # When we now change the local roles of 'child', the copy is
        # unaffected:
        set_groups('group:bobsgroup', child, [])
        self.assertEqual(len(principals_with_local_roles(child)), 2)
        self.assertEqual(len(principals_with_local_roles(child2)), 2)
コード例 #9
0
ファイル: test_security.py プロジェクト: Doik/Kotti
    def test_principals_with_local_roles(self):
        from kotti import DBSession
        from kotti.resources import get_root
        from kotti.resources import Node
        from kotti.security import map_principals_with_local_roles
        from kotti.security import principals_with_local_roles
        from kotti.security import set_groups

        root = get_root()
        child = root[u'child'] = Node()
        DBSession.flush()

        self.assertEqual(principals_with_local_roles(root), [])
        self.assertEqual(principals_with_local_roles(child), [])
        self.assertEqual(map_principals_with_local_roles(root), [])
        self.assertEqual(map_principals_with_local_roles(child), [])

        set_groups('group:bobsgroup', child, ['role:editor'])
        set_groups('bob', root, ['group:bobsgroup'])
        set_groups('group:franksgroup', root, ['role:editor'])

        self.assertEqual(set(principals_with_local_roles(child)),
                         set(['bob', 'group:bobsgroup', 'group:franksgroup']))
        self.assertEqual(
            set(principals_with_local_roles(child, inherit=False)),
            set(['group:bobsgroup']))
        self.assertEqual(set(principals_with_local_roles(root)),
                         set(['bob', 'group:franksgroup']))
コード例 #10
0
ファイル: tests.py プロジェクト: djpnewton/Kotti
    def test_principals_with_local_roles(self):
        session = DBSession()
        root = get_root()
        child = root[u'child'] = Node()
        session.flush()

        self.assertEqual(principals_with_local_roles(root), [])
        self.assertEqual(principals_with_local_roles(child), [])
        self.assertEqual(map_principals_with_local_roles(root), [])
        self.assertEqual(map_principals_with_local_roles(child), [])

        set_groups('group:bobsgroup', child, ['role:editor'])
        set_groups('bob', root, ['group:bobsgroup'])
        set_groups('group:franksgroup', root, ['role:editor'])

        self.assertEqual(
            set(principals_with_local_roles(child)),
            set(['bob', 'group:bobsgroup', 'group:franksgroup']))
        self.assertEqual(
            set(principals_with_local_roles(root)),
            set(['bob', 'group:franksgroup']))