예제 #1
0
        public void Validate()
        {
            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");

            user = apiRepository.Validate(user.AuthToken, domain.Key);

            Assert.NotNull(user);

            repository.DeleteDomain(domain.Id);
            repository.DeleteManager(manager.Id, "test");
        }
예제 #2
0
        public void GetAdministrators()
        {
            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");
            var result = repository.GetAdministrators(domain.Id);

            Assert.AreEqual(1, result.Length);

            repository.DeleteManager(manager.Id, secret);
            repository.DeleteManager(admin.Id, secret);
        }
예제 #3
0
        public void ChangePassword()
        {
            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
                         .ChangePassword(domain.Key, user.AuthToken, "test1");

            Assert.True(result);

            repository.DeleteDomain(domain.Id);
            repository.DeleteManager(manager.Id, "test");
        }
예제 #4
0
        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);
        }
예제 #5
0
        public void GetUsersWithClaim()
        {
            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.Claims.Add("claim1");
            user.Claims.Add("claim2");

            repository.UpdateUser(user);

            var users = repository.GetUsersWithClaim(domain.Id, "claim1");

            Assert.AreEqual(1, users.Length);
            repository.DeleteManager(manager.Id, secret);
        }