Beispiel #1
0
    def test_create_role(self):
        new_role = Role("foo-role")

        self.assertEqual(new_role.role_name(), "foo-role")

        new_role.add_role_name("admin")
        self.assertIn("admin", new_role.role_names())
Beispiel #2
0
    def test_privileges(self):
        role = Role("foo-role")

        role.add_privilege("bar-priv", "execute")
        role.add_privilege("baz-priv", "execute")

        self.assertEqual(2, len(role.privileges()))
        self.assertEqual("execute|bar-priv", role.privileges()[0])
Beispiel #3
0
    def test_roles(self):
        role = Role("foo-role")

        role.add_role_name("bar-role")
        role.add_role_name("baz-role")

        self.assertEqual(2, len(role.role_names()))
        self.assertTrue("bar-role" in role.role_names())
        self.assertTrue("baz-role" in role.role_names())
Beispiel #4
0
    def test_add_privilege(self):
        role = Role("foo-role")

        name = "foodle"
        action = "http://marklogic.com/xdmp/privileges/foodle"
        kind = "execute"

        role.add_privilege(name, kind)

        priv = role.privileges()[0]
        assert "execute|foodle" == priv
Beispiel #5
0
    def test_create_remove_role(self):
        connection = Connection.make_connection(tc.hostname, tc.admin, tc.password)
        role = Role("foo-role")

        role.create(connection)

        the_role = Role.lookup(connection, "foo-role")
        self.assertIsNotNone(the_role)

        the_role.delete(connection)
        the_role = Role.lookup(connection, "foo-role")
        self.assertIsNone(the_role)
Beispiel #6
0
    def test_save_role(self):
        connection = Connection.make_connection(tc.hostname, tc.admin, tc.password)
        role = Role("foo-role")

        self.assertIsNone(role.create(connection).description())
        role.set_description("This is the foo role")

        role.update(connection)

        role = Role.lookup(connection, "foo-role")
        self.assertEqual("This is the foo role", role.description())

        role.delete(connection)
Beispiel #7
0
    def test_add_privilege(self):
        role = Role("foo-role")

        name = "foodle"
        action = "http://marklogic.com/xdmp/privileges/foodle"
        kind = "execute"

        role.add_privilege(name, action, kind)

        priv = role.privileges()[0]
        self.assertEqual(priv['privilege-name'], name)
        self.assertEqual(priv['action'], action)
        self.assertEqual(priv['kind'], kind)
Beispiel #8
0
    def test_privileges(self):
        role = Role("foo-role")

        role.add_privilege("bar-priv", "http://foo.bar.com/add", "execute")
        role.add_privilege("baz-priv", "http://foo.bar.com/update", "execute")

        self.assertEqual(2, len(role.privileges()))
        self.assertEqual("bar-priv", role.privileges()[0]['privilege-name'])
        self.assertEqual('http://foo.bar.com/add', role.privileges()[0]['action'])
        self.assertEqual('execute', role.privileges()[0]['kind'])
Beispiel #9
0
    def test_lookup(self):
        connection = Connection.make_connection(tc.hostname, tc.admin, tc.password)

        role = Role.lookup(connection, "admin")

        self.assertIsNotNone(role)
        self.assertEqual(role.role_name(), "admin")
Beispiel #10
0
    def test_list(self):
        connection = Connection.make_connection(tc.hostname, tc.admin, tc.password)

        names = Role.list(connection)

        self.assertGreater(len(names), 65)
        self.assertIn("admin", names)
Beispiel #11
0
    def test_lookup(self):
        connection = Connection.make_connection(tc.hostname, tc.admin,
                                                tc.password)

        role = Role.lookup(connection, "admin")

        self.assertIsNotNone(role)
        self.assertEqual(role.role_name(), "admin")
Beispiel #12
0
    def test_list(self):
        connection = Connection.make_connection(tc.hostname, tc.admin, tc.password)

        roles = Role.list_roles(connection)

        names = [role.name() for role in roles]
        self.assertGreater(len(names), 65)
        self.assertIn("admin", names)
Beispiel #13
0
    def test_list(self):
        connection = Connection.make_connection(tc.hostname, tc.admin,
                                                tc.password)

        names = Role.list(connection)

        self.assertGreater(len(names), 65)
        self.assertIn("admin", names)
Beispiel #14
0
    def test_create_role(self):
        new_role = Role("foo-role")

        self.assertEqual(new_role.role_name(), "foo-role")

        new_role.add_role_name("admin")
        self.assertIn("admin", new_role.role_names())
Beispiel #15
0
    def test_create_role(self):
        new_role = Role("foo-role")

        assert "foo-role" == new_role.role_name()

        new_role.add_role_name("admin")
        assert "admin" in new_role.role_names()
Beispiel #16
0
    def test_privileges(self):
        role = Role("foo-role")

        role.add_privilege("bar-priv", "execute")
        role.add_privilege("baz-priv", "execute")

        assert 2 == len(role.privileges())
        assert "execute|bar-priv" == role.privileges()[0]
Beispiel #17
0
    def test_privileges(self):
        role = Role("foo-role")

        role.add_privilege("bar-priv", "execute")
        role.add_privilege("baz-priv", "execute")

        self.assertEqual(2, len(role.privileges()))
        self.assertEqual("execute|bar-priv", role.privileges()[0])
Beispiel #18
0
    def test_roles(self):
        role = Role("foo-role")

        role.add_role_name("bar-role")
        role.add_role_name("baz-role")

        assert 2 == len(role.role_names())
        assert "bar-role" in role.role_names()
        assert "baz-role" in role.role_names()
Beispiel #19
0
    def test_roles(self):
        role = Role("foo-role")

        role.add_role_name("bar-role")
        role.add_role_name("baz-role")

        self.assertEqual(2, len(role.role_names()))
        self.assertTrue("bar-role" in role.role_names())
        self.assertTrue("baz-role" in role.role_names())
Beispiel #20
0
    def test_create_remove_role(self):
        role = Role("foo-role")

        role.create(self.connection)

        the_role = Role.lookup(self.connection, "foo-role")
        assert the_role is not None

        the_role.delete(self.connection)
        the_role = Role.lookup(self.connection, "foo-role")
        assert the_role is None
Beispiel #21
0
    def test_create_remove_role(self):
        connection = Connection.make_connection(tc.hostname, tc.admin,
                                                tc.password)
        role = Role("foo-role")

        role.create(connection)

        the_role = Role.lookup(connection, "foo-role")
        self.assertIsNotNone(the_role)

        the_role.delete(connection)
        the_role = Role.lookup(connection, "foo-role")
        self.assertIsNone(the_role)
Beispiel #22
0
    def test_save_role(self):
        role = Role("foo-role")

        assert role.create(self.connection).description() is None
        role.set_description("This is the foo role")

        role.update(self.connection)

        role = Role.lookup(self.connection, "foo-role")
        assert "This is the foo role" == role.description()

        role.delete(self.connection)
Beispiel #23
0
    def test_description(self):
        role = Role("foo-role")
        role.set_description("This is the foo role")

        assert "This is the foo role" == role.description()
Beispiel #24
0
    def test_description(self):
        role = Role("foo-role")
        role.set_description("This is the foo role")

        self.assertEqual(role.description(), "This is the foo role")
Beispiel #25
0
    def test_lookup(self):
        role = Role.lookup(self.connection, "admin")

        assert role is not None
        assert "admin" == role.role_name()
Beispiel #26
0
    def test_list(self):
        names = Role.list(self.connection)

        assert len(names) > 65
        assert "admin" in names
Beispiel #27
0
    def test_description(self):
        role = Role("foo-role")
        role.set_description("This is the foo role")

        self.assertEqual(role.description(), "This is the foo role")
Beispiel #28
0
    def test_save_role(self):
        connection = Connection.make_connection(tc.hostname, tc.admin,
                                                tc.password)
        role = Role("foo-role")

        self.assertIsNone(role.create(connection).description())
        role.set_description("This is the foo role")

        role.update(connection)

        role = Role.lookup(connection, "foo-role")
        self.assertEqual("This is the foo role", role.description())

        role.delete(connection)