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; }
public void ChangeOwnPassword_returns_success_response_when_request_is_valid([Frozen] IPasswordPolicy policy, [Frozen] IPasswordAuthenticationService authService, [LoggedIn] User currentUser, 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 var result = sut.ChangeOwnPassword(request); // Assert Assert.IsTrue(result.Success); }
public LoginLogoutManager(IPasswordAuthenticationService authenticationService, ILogsUserInOrOut loginLogoutService, ILoginThrottlingService throttlingService) { if (loginLogoutService == null) { throw new ArgumentNullException(nameof(loginLogoutService)); } if (throttlingService == null) { throw new ArgumentNullException(nameof(throttlingService)); } if (authenticationService == null) { throw new ArgumentNullException(nameof(authenticationService)); } this.authenticationService = authenticationService; this.loginLogoutService = loginLogoutService; this.throttlingService = throttlingService; }
public OAuthAuthorizationChecker(IPasswordAuthenticationService authService, LoginRequestCreator loginRequestCreator, IClaimsIdentityFactory claimsIdentityFactory) { if (claimsIdentityFactory == null) { throw new ArgumentNullException(nameof(claimsIdentityFactory)); } if (loginRequestCreator == null) { throw new ArgumentNullException(nameof(loginRequestCreator)); } if (authService == null) { throw new ArgumentNullException(nameof(authService)); } this.authService = authService; this.loginRequestCreator = loginRequestCreator; this.claimsIdentityFactory = claimsIdentityFactory; }
public void ChangeOwnPassword_returns_failure_result_if_new_passwords_do_not_meet_policy([Frozen] IPasswordPolicy policy, [Frozen] IPasswordAuthenticationService authService, [LoggedIn] User currentUser, 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(false); request.ConfirmNewPassword = request.NewPassword; // Act var result = sut.ChangeOwnPassword(request); // Assert Assert.IsFalse(result.Success); }
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()); }
public PasswordAuthController(IPasswordAuthenticationService authenticationService) { _authenticationService = authenticationService ?? throw new ArgumentNullException($"No instance of {nameof(IPasswordAuthenticationService)} provided."); }