public IdentityApplicationService(AuthenticationService authenticationService,
     GroupMemberService groupMemberService, TenantProvisioningService tenantProvisioningService,
     ITenantRepository tenantRepository, IGroupRepository groupRepository, IUserRepository userRepository)
 {
     this._authenticationService = authenticationService;
     this._groupMemberService = groupMemberService;
     this._groupRepository = groupRepository;
     this._tenantProvisioningService = tenantProvisioningService;
     this._tenantRepository = tenantRepository;
     this._userRepository = userRepository;
 }
        public void TestAuthenticationTenantFailure()
        {
            Tenant tenant = this.CreateTenant();
            User user = this.CreateUser(tenant);

            Mock<ITenantRepository> tenantRepository = new Mock<ITenantRepository>();
            Mock<IUserRepository> userRepository = new Mock<IUserRepository>();
            Mock<IEncryptionService> encryptionService = new Mock<IEncryptionService>();

            AuthenticationService service = new AuthenticationService(tenantRepository.Object, userRepository.Object,
                encryptionService.Object);

            UserDescriptor userDescriptor = service.Authenticate(new TenantId(Guid.NewGuid().ToString()),
                user.UserName, _password);

            Assert.NotNull(userDescriptor);
            Assert.IsTrue(userDescriptor.IsNullDescriptor());
        }
        public void TestAuthenticationPasswordFailure()
        {
            Tenant tenant = this.CreateTenant();
            User user = this.CreateUser(tenant);

            Mock<ITenantRepository> tenantRepository = new Mock<ITenantRepository>();
            tenantRepository.Setup(r => r.Get(tenant.TenantId)).Returns(tenant);
            Mock<IUserRepository> userRepository = new Mock<IUserRepository>();
            userRepository.Setup(r => r.UserFromAuthenticCredentials(tenant.TenantId, user.UserName, _password)).Returns(user);
            Mock<IEncryptionService> encryptionService = new Mock<IEncryptionService>();
            encryptionService.Setup(s => s.EncryptedValue(_password)).Returns(_password);

            AuthenticationService service = new AuthenticationService(tenantRepository.Object, userRepository.Object,
                encryptionService.Object);
            UserDescriptor userDescriptor = service.Authenticate(user.TenantId, user.UserName, _password+"-");

            Assert.NotNull(userDescriptor);
            Assert.IsTrue(userDescriptor.IsNullDescriptor());
        }
        protected override void SetUp()
        {
            base.SetUp();

            this._tenantRepository = new Mock<ITenantRepository>();
            this._groupRepository = new Mock<IGroupRepository>();
            this._userRepository = new Mock<IUserRepository>();
            this._roleRepository = new Mock<IRoleRepository>();

            this._authenticationService = new AuthenticationService(_tenantRepository.Object, _userRepository.Object,
                ServiceLocator.GetService<IEncryptionService>());
            this._groupMemberService = new GroupMemberService(this._userRepository.Object, this._groupRepository.Object);
            this._tenantProvisioningService = new TenantProvisioningService(_tenantRepository.Object,
                _userRepository.Object, _roleRepository.Object);

            this._identityApplicationService = new IdentityApplicationService(this._authenticationService,
                this._groupMemberService, this._tenantProvisioningService, this._tenantRepository.Object,
                this._groupRepository.Object, this._userRepository.Object);
        }