summaryrefslogtreecommitdiffstats
path: root/TwoStepsAuthenticator.UnitTests
diff options
context:
space:
mode:
authorGuillaume Lacasa <guillaumelacasa@hotmail.com>2014-03-17 18:01:40 +0100
committerGuillaume Lacasa <guillaumelacasa@hotmail.com>2014-03-17 18:01:40 +0100
commit6f71d431c921e8b9aab0bbe89b3293671b81563e (patch)
tree108abd109f4dfe6744557711494ede9c81124867 /TwoStepsAuthenticator.UnitTests
parent0d73b105daca5ccca439d0e04692d773c33d274a (diff)
downloadTwoStepsAuthenticator-1.0.zip
TwoStepsAuthenticator-1.0.tar.gz
TwoStepsAuthenticator-1.0.tar.bz2
The UsedCodeManager needs to have an user object, in order to avoid a user to block a temp code for every other usersv1.0
Diffstat (limited to 'TwoStepsAuthenticator.UnitTests')
-rw-r--r--TwoStepsAuthenticator.UnitTests/MockUsedCodesManager.cs6
-rw-r--r--TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs4
-rw-r--r--TwoStepsAuthenticator.UnitTests/UsedCodesManagerTests.cs6
3 files changed, 8 insertions, 8 deletions
diff --git a/TwoStepsAuthenticator.UnitTests/MockUsedCodesManager.cs b/TwoStepsAuthenticator.UnitTests/MockUsedCodesManager.cs
index cb0065f..3ed8ba8 100644
--- a/TwoStepsAuthenticator.UnitTests/MockUsedCodesManager.cs
+++ b/TwoStepsAuthenticator.UnitTests/MockUsedCodesManager.cs
@@ -1,15 +1,15 @@
namespace TwoStepsAuthenticator.UnitTests
{
internal class MockUsedCodesManager : IUsedCodesManager {
- public ulong? LastChallenge { get; private set; }
+ public long? LastChallenge { get; private set; }
public string LastCode { get; private set; }
- public void AddCode(ulong challenge, string code) {
+ public void AddCode(long challenge, string code, object user) {
this.LastChallenge = challenge;
this.LastCode = code;
}
- public bool IsCodeUsed(ulong challenge, string code) {
+ public bool IsCodeUsed(long challenge, string code, object user) {
return false;
}
}
diff --git a/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs b/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
index 99d1957..8aacfe1 100644
--- a/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
+++ b/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
@@ -46,7 +46,7 @@ namespace TwoStepsAuthenticator.UnitTests
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 authenticator = new TimeAuthenticator(usedCodesManager, () => date);
var secret = Authenticator.GenerateKey();
var code = authenticator.GetCode(secret);
@@ -76,7 +76,7 @@ namespace TwoStepsAuthenticator.UnitTests
DateTime usedTime;
- Assert.True(authenticator.CheckCode("H22Q7WAMQYFZOJ2Q", "696227", out usedTime));
+ Assert.True(authenticator.CheckCode("H22Q7WAMQYFZOJ2Q", "696227", null, out usedTime));
// 17:23:50 - 30s
Assert.AreEqual(usedTime.Hour, 17);
diff --git a/TwoStepsAuthenticator.UnitTests/UsedCodesManagerTests.cs b/TwoStepsAuthenticator.UnitTests/UsedCodesManagerTests.cs
index d72474c..ffe40ae 100644
--- a/TwoStepsAuthenticator.UnitTests/UsedCodesManagerTests.cs
+++ b/TwoStepsAuthenticator.UnitTests/UsedCodesManagerTests.cs
@@ -14,9 +14,9 @@ namespace TwoStepsAuthenticator.UnitTests {
public void Can_add_codes() {
var manager = new UsedCodesManager();
- Assert.IsFalse(manager.IsCodeUsed(42L, "def"));
- manager.AddCode(42L, "def");
- Assert.IsTrue(manager.IsCodeUsed(42L, "def"));
+ Assert.IsFalse(manager.IsCodeUsed(42L, "def","u"));
+ manager.AddCode(42L, "def", "u");
+ Assert.IsTrue(manager.IsCodeUsed(42L, "def", "u"));
}
}