summaryrefslogtreecommitdiffstats
path: root/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
diff options
context:
space:
mode:
authorChristoph Enzmann <christoph.enzmann@confer.ch>2013-12-06 16:50:33 +0100
committerChristoph Enzmann <christoph.enzmann@confer.ch>2013-12-06 16:50:33 +0100
commitea753e7a60e90f94bb9c89d91366e7968e4f4ce8 (patch)
tree653c5eebb2258134ecc95695fe742695eadd0582 /TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
parent41cb13ee263104981850a73d4abf4a583df31941 (diff)
downloadTwoStepsAuthenticator-ea753e7a60e90f94bb9c89d91366e7968e4f4ce8.zip
TwoStepsAuthenticator-ea753e7a60e90f94bb9c89d91366e7968e4f4ce8.tar.gz
TwoStepsAuthenticator-ea753e7a60e90f94bb9c89d91366e7968e4f4ce8.tar.bz2
Removed UsedCodesManager from CounterAuthenticator
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 1a1ffc6..bc2f364 100644
--- a/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
+++ b/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
@@ -32,10 +32,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")]