private Credentials CreateCredentialsFromPassword(UnhashedPassword newPassword) { return (new Credentials( new HashedPassword( newPassword, passwordHashGenerator))); }
public void IsPasswordCorrect_NullPassword_Throws() { var authenticator = CreateAuthenticator(); UnhashedPassword nullPassword = null; var exception = Assert.Catch <ArgumentNullException>( () => authenticator.IsPasswordCorrect(nullPassword)); }
private void SetDefaultPassword(DbContext context) { var defaultPassword = new UnhashedPassword("admin"); context.Add( new Credentials( new HashedPassword(defaultPassword, passwordHashGenerator))); }
public void Constructor_NullPassword_Throws() { var stubHashGenerator = Substitute.For <IPasswordHashGenerator>(); UnhashedPassword nullPassword = null; var exception = Assert.Throws <ArgumentNullException>( () => new HashedPassword(nullPassword, stubHashGenerator)); }
public bool AreMatching( HashedPassword hashedPassword, UnhashedPassword unhashedPassword) { return(BCrypt.Net.BCrypt .Verify( unhashedPassword.Value, hashedPassword.Value)); }
public string Generate(UnhashedPassword unhashedPassword) { int workFactor = 12; return (BCrypt.Net.BCrypt.HashPassword( unhashedPassword.Value, workFactor)); }
public bool IsPasswordCorrect(UnhashedPassword passwordToTest) { if (passwordToTest == null) { throw new ArgumentNullException(nameof(passwordToTest)); } return(ActualPassword() .MatchWith(passwordToTest, passwordHashComparer)); }
private void DefineNewPassword() { var newPassword = new UnhashedPassword(txtNewPassword.Password); passwordUpdater.Update(newPassword); }
public void Update(UnhashedPassword newPassword) { credentialsUpdater.Update( CreateCredentialsFromPassword(newPassword)); handler.Handle(new PasswordUpdated()); }