public static void GenerateCorrectPasswordWithCorrectNumberOfDigitsAsSpecifiedInParameters( string secrect, int digits, DateTime now, AuthenticatorAlgorithm authenticatorAlgorithm, string expectedPassword) { expectedPassword = expectedPassword.Substring(expectedPassword.Length - digits); var authenticator = new Authenticator(options => options.AuthenticatorAlgorithm = authenticatorAlgorithm); var actualPassword = authenticator.GenerateTimeBasedPassword(secrect, () => now, digits, 30); Assert.Equal(expectedPassword, actualPassword); }
public static void GenerateCorrectSixDigitPasswordWith30SecondsStepByDefaultIfDigitsAndTimeStepParametersAreNotSpecified( string secrect, int digits, DateTime now, AuthenticatorAlgorithm authenticatorAlgorithm, string expectedPassword) { expectedPassword = expectedPassword.Substring(expectedPassword.Length - digits); var authenticator = new Authenticator(options => options.AuthenticatorAlgorithm = authenticatorAlgorithm); var actualPassword = authenticator.GenerateTimeBasedPassword(secrect, () => now); Assert.Equal(expectedPassword, actualPassword); }
public static void GenerateCorrectPasswordWithCorrectNumberOfDigitsAsSpecifiedInOptions( string secrect, int digits, DateTime now, AuthenticatorAlgorithm authenticatorAlgorithm, string expectedPassword) { expectedPassword = expectedPassword.Substring(expectedPassword.Length - digits); var authenticator = new Authenticator(options => { options.AuthenticatorAlgorithm = authenticatorAlgorithm; options.NumberOfPasswordDigits = digits; options.SizeOfTimeStep = 30; }); var actualPassword = authenticator.GenerateTimeBasedPassword(secrect, () => now); Assert.Equal(expectedPassword, actualPassword); }
public static void ThrowInvalidOperationExceptionIfAuthenticatorAlgorithmIsNotHMACSHA1(AuthenticatorAlgorithm authenticatorAlgorithm) { var authenticator = new Authenticator(options => options.AuthenticatorAlgorithm = authenticatorAlgorithm); Assert.Throws <InvalidOperationException>(() => authenticator.GenerateCounterBasedPassword(Secret, 9)); }