Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        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");
        }
Ejemplo n.º 3
0
        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");
        }
Ejemplo n.º 4
0
        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");
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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");
        }
Ejemplo n.º 7
0
        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");
        }