Exemplo n.º 1
0
        public AddUserController(IUserCreator userCreator,
                                 IGetsUserByUsername userQuery,
                                 IUserPasswordUpdater passwordChanger,
                                 IGetsTransaction transactionCreator)
        {
            if (transactionCreator == null)
            {
                throw new ArgumentNullException(nameof(transactionCreator));
            }
            if (passwordChanger == null)
            {
                throw new ArgumentNullException(nameof(passwordChanger));
            }
            if (userQuery == null)
            {
                throw new ArgumentNullException(nameof(userQuery));
            }
            if (userCreator == null)
            {
                throw new ArgumentNullException(nameof(userCreator));
            }

            this.userCreator        = userCreator;
            this.passwordChanger    = passwordChanger;
            this.userQuery          = userQuery;
            this.transactionCreator = transactionCreator;
        }
Exemplo n.º 2
0
 public PasswordChanger(IPasswordPolicy policy,
                        IPasswordAuthenticationService authService,
                        ICurrentUserReader userReader,
                        IUserPasswordUpdater updater,
                        IGetsTransaction transactionCreator)
 {
     if (transactionCreator == null)
     {
         throw new ArgumentNullException(nameof(transactionCreator));
     }
     if (updater == null)
     {
         throw new ArgumentNullException(nameof(updater));
     }
     if (userReader == null)
     {
         throw new ArgumentNullException(nameof(userReader));
     }
     if (authService == null)
     {
         throw new ArgumentNullException(nameof(authService));
     }
     if (policy == null)
     {
         throw new ArgumentNullException(nameof(policy));
     }
     this.policy             = policy;
     this.authService        = authService;
     this.userReader         = userReader;
     this.updater            = updater;
     this.transactionCreator = transactionCreator;
 }
Exemplo n.º 3
0
 public CommandHandler(
     IMapper mapper,
     UserManager <Domain.Entities.Security.ApplicationUser> userManager,
     IUserRolesUpdater userRolesUpdater,
     IUserIcgsUpdater userIcgsUpdater,
     IUserPasswordUpdater userPasswordUpdater)
 {
     _mapper              = mapper;
     _userManager         = userManager;
     _userRolesUpdater    = userRolesUpdater;
     _userPasswordUpdater = userPasswordUpdater;
     _userIcgsUpdater     = userIcgsUpdater;
 }
Exemplo n.º 4
0
        public void ChangeOwnPassword_stores_updated_password_when_when_request_is_valid([Frozen] IPasswordPolicy policy,
                                                                                         [Frozen] IPasswordAuthenticationService authService,
                                                                                         [LoggedIn] User currentUser,
                                                                                         [Frozen] IUserPasswordUpdater updater,
                                                                                         PasswordChanger sut,
                                                                                         PasswordChangeRequest request)
        {
            // Arrange
            Mock.Get(authService)
            .Setup(x => x.Authenticate(It.IsAny <IPassword>()))
            .Returns(Mock.Of <CSF.Security.Authentication.IAuthenticationResult>(x => x.Success == true));
            Mock.Get(policy)
            .Setup(x => x.IsPasswordOk(request.NewPassword, currentUser))
            .Returns(true);
            request.ConfirmNewPassword = request.NewPassword;

            // Act
            sut.ChangeOwnPassword(request);

            // Assert
            Mock.Get(updater)
            .Verify(x => x.ChangePassword(currentUser, request.NewPassword), Times.Once());
        }