[InlineData("992085")] // +3 public static void FailToVerifyPasswordGeneratedOutsideTheServerTimeStepAndTheDefaultBackwardAndForwardTimeSteps(string password) { var unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); var now = unixEpoch.AddSeconds(1234567890); var authenticator = new Authenticator(); var verifier = new PasswordVerifier(authenticator); var(isVerified, timeStepDrift) = verifier.VerifyTimeBasedPassword(password, Secret, () => now); Assert.False(isVerified); }
public static void SuccessfullyVerifyPasswordGeneratedWithinTheServerTimeStepOrTheDefaultBackwardAndForwardTimeSteps(string password, int drift) { var unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); var now = unixEpoch.AddSeconds(1234567890); var authenticator = new Authenticator(); var verifier = new PasswordVerifier(authenticator); var(isVerified, timeStepDrift) = verifier.VerifyTimeBasedPassword(password, Secret, () => now); Assert.True(isVerified && timeStepDrift == drift); }
[InlineData(2, 0, "992085")] // +3 public static void FailToVerifyPasswordGeneratedOutsideTheServerTimeStepAndTheConfiguredBackwardAndForwardTimeSteps(uint backStep, uint foreStep, string password) { var unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); var now = unixEpoch.AddSeconds(1234567890); var authenticator = new Authenticator(); var verifier = new PasswordVerifier(authenticator, options => { options.NumberOfBackwardTimeSteps = backStep; options.NumberOfForwardTimeSteps = foreStep; }); var(isVerified, timeStepDrift) = verifier.VerifyTimeBasedPassword(password, Secret, () => now); Assert.False(isVerified); }