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())
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])
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())
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
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)
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)
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)
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'])
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")
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)
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)
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()
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]
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()
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
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)
def test_description(self): role = Role("foo-role") role.set_description("This is the foo role") assert "This is the foo role" == role.description()
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")
def test_lookup(self): role = Role.lookup(self.connection, "admin") assert role is not None assert "admin" == role.role_name()
def test_list(self): names = Role.list(self.connection) assert len(names) > 65 assert "admin" in names