diff options
Diffstat (limited to 'TwoStepsAuthenticator.UnitTests')
-rw-r--r-- | TwoStepsAuthenticator.UnitTests/CounterAuthenticatorTests.cs | 12 | ||||
-rw-r--r-- | TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs | 15 |
2 files changed, 27 insertions, 0 deletions
diff --git a/TwoStepsAuthenticator.UnitTests/CounterAuthenticatorTests.cs b/TwoStepsAuthenticator.UnitTests/CounterAuthenticatorTests.cs index 4738ba1..ecb96c0 100644 --- a/TwoStepsAuthenticator.UnitTests/CounterAuthenticatorTests.cs +++ b/TwoStepsAuthenticator.UnitTests/CounterAuthenticatorTests.cs @@ -38,5 +38,17 @@ namespace TwoStepsAuthenticator.UnitTests { } + [Test] + public void VerifyUsedCounter() { + var authenticator = new CounterAuthenticator(); + + // Test Values from http://www.ietf.org/rfc/rfc4226.txt - Appendix D + var base32Secret = Base32Encoding.ToString(Encoding.ASCII.GetBytes("12345678901234567890")); + + long usedCounter; + Assert.True(authenticator.CheckCode(base32Secret, "520489", 0L, out usedCounter)); + + Assert.AreEqual(usedCounter, 9L); + } } } diff --git a/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs b/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs index 3d19ea2..3dc6d86 100644 --- a/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs +++ b/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs @@ -30,5 +30,20 @@ namespace TwoStepsAuthenticator.UnitTests { Assert.IsTrue(authenticator.CheckCode(secret, code)); } + + [Test] + public void VerifyUsedTime() { + var date = DateTime.Parse("2013-12-05 17:23:50 +0100"); + var authenticator = new TimeAuthenticator(() => date); + + DateTime usedTime; + + Assert.True(authenticator.CheckCode("H22Q7WAMQYFZOJ2Q", "696227", out usedTime)); + + // 17:23:50 - 30s + Assert.AreEqual(usedTime.Hour, 17); + Assert.AreEqual(usedTime.Minute, 23); + Assert.AreEqual(usedTime.Second, 20); + } } } |