Ejemplo n.º 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())
Ejemplo n.º 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])
Ejemplo n.º 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())
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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'])
Ejemplo n.º 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")
Ejemplo n.º 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)
Ejemplo n.º 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")
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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())
Ejemplo n.º 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()
Ejemplo n.º 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]
Ejemplo n.º 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])
Ejemplo n.º 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()
Ejemplo n.º 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())
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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()
Ejemplo n.º 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")
Ejemplo n.º 25
0
    def test_lookup(self):
        role = Role.lookup(self.connection, "admin")

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

        assert len(names) > 65
        assert "admin" in names
Ejemplo n.º 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")
Ejemplo n.º 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)