summaryrefslogtreecommitdiffstats
path: root/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
diff options
context:
space:
mode:
authorGuillaume Lacasa <guillaume.lacasa@ucaya.com>2013-12-06 17:33:34 +0100
committerGuillaume Lacasa <guillaume.lacasa@ucaya.com>2013-12-06 17:33:34 +0100
commitcb801c254bfbafe80a1f3cd093a3dfe1d01538cb (patch)
tree4966d374878163c4a5c894c25f9cb8c0e61f11f1 /TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
parent93adb5b673c1cf6d3abdb287d349ffad11ed7665 (diff)
parent57f740845da867fc270d9b185508bc5761aa7d45 (diff)
downloadTwoStepsAuthenticator-cb801c254bfbafe80a1f3cd093a3dfe1d01538cb.zip
TwoStepsAuthenticator-cb801c254bfbafe80a1f3cd093a3dfe1d01538cb.tar.gz
TwoStepsAuthenticator-cb801c254bfbafe80a1f3cd093a3dfe1d01538cb.tar.bz2
Merge branch 'master' of https://github.com/dusk0r/TwoStepsAuthenticator
Conflicts: README.md TwoStepsAuthenticator.UnitTests/UsedCodesManagerTests.cs TwoStepsAuthenticator/CounterAuthenticator.cs
Diffstat (limited to 'TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs')
-rw-r--r--TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs13
1 files changed, 13 insertions, 0 deletions
diff --git a/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs b/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
index 55be883..99d1957 100644
--- a/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
+++ b/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
@@ -37,10 +37,23 @@ namespace TwoStepsAuthenticator.UnitTests
var code = authenticator.GetCode(secret);
authenticator.CheckCode(secret, code);
+
Assert.AreEqual(mockUsedCodesManager.LastChallenge, 0uL);
Assert.AreEqual(mockUsedCodesManager.LastCode, code);
}
+ [Test]
+ public void Prevent_code_reuse() {
+ var date = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+ var usedCodesManager = new UsedCodesManager();
+ var authenticator = new TimeAuthenticator(() => date, usedCodeManager: usedCodesManager);
+ var secret = Authenticator.GenerateKey();
+ var code = authenticator.GetCode(secret);
+
+ Assert.IsTrue(authenticator.CheckCode(secret, code));
+ Assert.IsFalse(authenticator.CheckCode(secret, code));
+ }
+
// Test Vectors from http://tools.ietf.org/html/rfc6238#appendix-B have all length 8. We want a length of 6.
// This Test Vectors are from a Ruby implementation. They work with the Google Authentificator app.
[TestCase("DRMK64PPMMC7TDZF", "2013-12-04 18:33:01 +0100", "661188")]