public void GetRoles() { var apiRepository = new ApiMongoRepository(CONNECTION_STRING); var repository = new MongoRepository(CONNECTION_STRING, apiRepository); var userName = "******"; var secret = "test"; var manager = repository.CreateManager(userName, secret); var domain = repository.CreateDomain("test", manager); repository.CreateRole(domain.Id, "test"); repository.CreateRole(domain.Id, "test2"); var roles = repository.GetRoles(domain.Id); Assert.AreEqual(2, roles.Length); repository.DeleteManager(manager.Id, secret); }
public void DeleteRole() { var apiRepository = new ApiMongoRepository(CONNECTION_STRING); var repository = new MongoRepository(CONNECTION_STRING, apiRepository); var userName = "******"; var secret = "test"; var manager = repository.CreateManager(userName, secret); var domain = repository.CreateDomain("test", manager); var role = repository.CreateRole(domain.Id, "test"); repository.DeleteRole(role); role = repository.GetRole(domain.Id, "test"); Assert.IsNull(role); repository.DeleteManager(manager.Id, secret); }
public void GetRolesWithClaim() { var apiRepository = new ApiMongoRepository(CONNECTION_STRING); var repository = new MongoRepository(CONNECTION_STRING, apiRepository); var userName = "******"; var secret = "test"; var manager = repository.CreateManager(userName, secret); var domain = repository.CreateDomain("test", manager); var role = repository.CreateRole(domain.Id, "test"); role.Claims.Add("claim1"); repository.UpdateRole(role); var roles = repository.GetRolesWithClaim(domain.Id, "claim1"); Assert.AreEqual(1, roles.Length); repository.DeleteManager(manager.Id, secret); }
public void GetUsersInRole() { var apiRepository = new ApiMongoRepository(CONNECTION_STRING); var repository = new MongoRepository(CONNECTION_STRING, apiRepository); var userName = "******"; var secret = "test"; var manager = repository.CreateManager(userName, secret); var domain = repository.CreateDomain("test", manager); var user = apiRepository.CreateUser(domain.Key, "user1", "test", "*****@*****.**"); var role = repository.CreateRole(domain.Id, "test"); user.AddRole(role); repository.UpdateUser(user); var users = repository.GetUsersInRole(role); Assert.AreEqual(1, users.Length); repository.DeleteManager(manager.Id, secret); }