public void When_Generate_HOTP(int counter, long expectedOtp) { // ACT var user = new OAuthUser(); user.ResetOtp(secret, counter); var options = new OAuth.Options.OAuthHostOptions(); var opts = Microsoft.Extensions.Options.Options.Create(options); var authenticator = new HOTPAuthenticator(opts); // ARRANGE var otp = authenticator.GenerateOtp(user); // ASSERT Assert.Equal(expectedOtp, otp); }
// [Fact] public void When_Generate_TOTP() { // ACT var user = new OAuthUser(); user.ResetOtp(secret); var options = new OAuth.Options.OAuthHostOptions(); var opts = Microsoft.Extensions.Options.Options.Create(options); var authenticator = new TOTPAuthenticator(opts); var date = DateTime.Parse("12-07-21 20:07:56"); // ARRANGE var otp = authenticator.GenerateOtp(user, date); // ASSERT Assert.Equal(102892, otp); }