public void ChangeEmail() { var apiRepository = new ApiMongoRepository(CONNECTION); var repository = new MongoRepository(CONNECTION, apiRepository); var manager = repository.CreateManager("test", "test"); var domain = repository.CreateDomain("test", manager); var user = apiRepository.CreateUser(domain.Key, "test", "test", "*****@*****.**"); user = apiRepository.Authenticate(domain.Key, "test", "test"); var result = apiRepository .ChangeEmail(domain.Key, user.AuthToken, "*****@*****.**"); Assert.True(result); user = apiRepository.Validate(user.AuthToken, domain.Key); Assert.AreEqual(user.Email, "*****@*****.**"); repository.DeleteDomain(domain.Id); repository.DeleteManager(manager.Id, "test"); }
public void AddAdministrator() { 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 admin = repository.CreateManager(userName + "2", secret); var domain = repository.CreateDomain("test", manager); admin = repository.AddAdministrator(domain.Id, userName + "2"); Assert.AreEqual(userName + "2", admin.UserName); repository.DeleteManager(manager.Id, secret); repository.DeleteManager(admin.Id, secret); }
public void CreateManager() { var apiRepository = new ApiMongoRepository(CONNECTION_STRING); var repository = new MongoRepository(CONNECTION_STRING, apiRepository); var userName = "******"; var secret = "test"; var manager = repository.CreateManager(userName, secret); Assert.AreEqual(manager.UserName, userName); repository.DeleteManager(manager.Id, secret); }
public void DeleteManager() { 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 id = manager.Id; repository.DeleteManager(manager.Id, secret); manager = repository.GetManager(id); Assert.IsNull(manager); }
public void ForgotPassword() { 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 newPassword = repository.ForgotPassword(userName); //implicit assert, would fail if password didn't change repository.DeleteManager(manager.Id, newPassword); }
public void ValidateDomainKey() { var apiRepository = new ApiMongoRepository(CONNECTION); var repository = new MongoRepository(CONNECTION, apiRepository); var manager = repository.CreateManager("test", "test"); var domain = repository.CreateDomain("test", manager); var result = apiRepository.ValidateDomainKey("test", domain.Key); Assert.True(result); repository.DeleteDomain(domain.Id); repository.DeleteManager(manager.Id, "test"); }
public void ChangeEmail() { var apiRepository = new ApiMongoRepository(CONNECTION_STRING); var repository = new MongoRepository(CONNECTION_STRING, apiRepository); var userName = "******"; var secret = "test"; var manager = repository.CreateManager(userName, secret); repository.ChangeEmail(manager.Id, secret, "*****@*****.**"); manager = repository.GetManager(manager.Id); Assert.AreEqual(manager.UserName, "*****@*****.**"); repository.DeleteManager(manager.Id, secret); }
public void IpAllowed() { var apiRepository = new ApiMongoRepository(CONNECTION); var repository = new MongoRepository(CONNECTION, apiRepository); var manager = repository.CreateManager("test", "test"); var domain = repository.CreateDomain("test", manager); var result = apiRepository.IpAllowed(domain.Key, "127.0.0.1"); Assert.True(result); repository.DeleteDomain(domain.Id); repository.DeleteManager(manager.Id, "test"); }
public void CreateUser() { var apiRepository = new ApiMongoRepository(CONNECTION); var repository = new MongoRepository(CONNECTION, apiRepository); var manager = repository.CreateManager("test", "test"); var domain = repository.CreateDomain("test", manager); var user = apiRepository.CreateUser(domain.Key, "test", "test", "*****@*****.**"); Assert.AreEqual("*****@*****.**", user.Email); repository.DeleteDomain(domain.Id); repository.DeleteManager(manager.Id, "test"); }
public void ChangePassword() { 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 pass = manager.Secret; repository.ChangePassword(manager.Id, secret, "password", "password"); manager = repository.GetManager(manager.Id); //Assert.AreEqual(manager.Secret, pass); //implicit assert, would fail if password didn't change repository.DeleteManager(manager.Id, "password"); }
public void CreateRole() { 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"); Assert.AreEqual("test", role.Name); repository.DeleteManager(manager.Id, secret); }
public void UpdateDomain() { 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); Assert.True(domain.Enabled); domain.Enabled = false; domain = repository.UpdateDomain(domain); Assert.False(domain.Enabled); repository.DeleteManager(manager.Id, secret); }
public void GetDomainUsers() { 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 users = repository.GetDomainUsers(domain.Id); Assert.AreEqual(1, users.Length); repository.DeleteManager(manager.Id, secret); }
public void GetUserInDomain() { 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", "*****@*****.**"); user = repository.GetUser(domain.Id, "user1"); Assert.NotNull(user); repository.DeleteManager(manager.Id, secret); }
public void DeleteDomain() { 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.DeleteDomain(domain.Id); domain = repository.GetDomain(domain.Id); Assert.IsNull(domain); repository.DeleteManager(manager.Id, secret); }
public void GetOwnerName() { 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 result = repository.GetOwnerName(domain); Assert.AreEqual(result, manager.UserName); repository.DeleteManager(manager.Id, secret); }
public void HasAccess() { 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 result = repository.HasAccess(domain, manager); Assert.True(result); repository.DeleteManager(manager.Id, secret); }
public void GetDomains() { var apiRepository = new ApiMongoRepository(CONNECTION_STRING); var repository = new MongoRepository(CONNECTION_STRING, apiRepository); var userName = "******"; var secret = "test"; var manager = repository.CreateManager(userName, secret); repository.CreateDomain("test", manager); repository.CreateDomain("test2", manager); var domains = repository.GetDomains(manager.Id); Assert.AreEqual(2, domains.Length); repository.DeleteManager(manager.Id, secret); }
public void Forgot() { var apiRepository = new ApiMongoRepository(CONNECTION); var repository = new MongoRepository(CONNECTION, apiRepository); var manager = repository.CreateManager("test", "test"); var domain = repository.CreateDomain("test", manager); apiRepository.CreateUser(domain.Key, "test", "test", "*****@*****.**"); var result = apiRepository .Forgot(domain.Key, "*****@*****.**"); Assert.True(result.Length > 0); repository.DeleteDomain(domain.Id); repository.DeleteManager(manager.Id, "test"); }
public void Disable() { var apiRepository = new ApiMongoRepository(CONNECTION); var repository = new MongoRepository(CONNECTION, apiRepository); var manager = repository.CreateManager("test", "test"); var domain = repository.CreateDomain("test", manager); var user = apiRepository.CreateUser(domain.Key, "test", "test", "*****@*****.**"); user = apiRepository.Authenticate(domain.Key, "test", "test"); bool result = apiRepository.Disable(user.AuthToken, domain.Key); Assert.True(result); repository.DeleteDomain(domain.Id); repository.DeleteManager(manager.Id, "test"); }
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); }