summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/Mocks/InMemoryTokenManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Test/Mocks/InMemoryTokenManager.cs')
-rw-r--r--src/DotNetOpenAuth.Test/Mocks/InMemoryTokenManager.cs74
1 files changed, 39 insertions, 35 deletions
diff --git a/src/DotNetOpenAuth.Test/Mocks/InMemoryTokenManager.cs b/src/DotNetOpenAuth.Test/Mocks/InMemoryTokenManager.cs
index f9cf612..5585107 100644
--- a/src/DotNetOpenAuth.Test/Mocks/InMemoryTokenManager.cs
+++ b/src/DotNetOpenAuth.Test/Mocks/InMemoryTokenManager.cs
@@ -14,7 +14,7 @@ namespace DotNetOpenAuth.Test.Mocks {
using DotNetOpenAuth.OAuth.Messages;
internal class InMemoryTokenManager : IConsumerTokenManager, IServiceProviderTokenManager {
- private Dictionary<string, string> consumersAndSecrets = new Dictionary<string, string>();
+ private KeyedCollectionDelegate<string, ConsumerInfo> consumers = new KeyedCollectionDelegate<string, ConsumerInfo>(c => c.Key);
private KeyedCollectionDelegate<string, TokenInfo> tokens = new KeyedCollectionDelegate<string, TokenInfo>(t => t.Token);
/// <summary>
@@ -30,11 +30,11 @@ namespace DotNetOpenAuth.Test.Mocks {
#region IConsumerTokenManager Members
public string ConsumerKey {
- get { return this.consumersAndSecrets.Keys.Single(); }
+ get { return this.consumers.Single().Key; }
}
public string ConsumerSecret {
- get { return this.consumersAndSecrets.Values.Single(); }
+ get { return this.consumers.Single().Secret; }
}
#endregion
@@ -46,7 +46,7 @@ namespace DotNetOpenAuth.Test.Mocks {
}
public void StoreNewRequestToken(UnauthorizedTokenRequest request, ITokenSecretContainingMessage response) {
- this.tokens.Add(new TokenInfo { Token = response.Token, Secret = response.TokenSecret });
+ this.tokens.Add(new TokenInfo { ConsumerKey = request.ConsumerKey, Token = response.Token, Secret = response.TokenSecret });
this.requestTokens.Add(response.Token, false);
}
@@ -94,32 +94,12 @@ namespace DotNetOpenAuth.Test.Mocks {
#region IServiceProviderTokenManager Members
- public string GetConsumerSecret(string consumerKey) {
- return this.consumersAndSecrets[consumerKey];
+ public IConsumerDescription GetConsumer(string consumerKey) {
+ return this.consumers[consumerKey];
}
- public void SetRequestTokenVerifier(string requestToken, string verifier) {
- this.tokens[requestToken].Verifier = verifier;
- }
-
- public string GetRequestTokenVerifier(string requestToken) {
- return this.tokens[requestToken].Verifier;
- }
-
- public void SetRequestTokenCallback(string requestToken, Uri callback) {
- this.tokens[requestToken].Callback = callback;
- }
-
- public Uri GetRequestTokenCallback(string requestToken) {
- return this.tokens[requestToken].Callback;
- }
-
- public void SetTokenConsumerVersion(string token, Version version) {
- this.tokens[token].ConsumerVersion = version;
- }
-
- public Version GetTokenConsumerVersion(string token) {
- return this.tokens[token].ConsumerVersion;
+ public IServiceProviderRequestToken GetRequestToken(string token) {
+ return this.tokens[token];
}
#endregion
@@ -130,7 +110,7 @@ namespace DotNetOpenAuth.Test.Mocks {
/// </summary>
/// <param name="consumerDescription">The consumer description.</param>
internal void AddConsumer(ConsumerDescription consumerDescription) {
- this.consumersAndSecrets.Add(consumerDescription.ConsumerKey, consumerDescription.ConsumerSecret);
+ this.consumers.Add(new ConsumerInfo { Key = consumerDescription.ConsumerKey, Secret = consumerDescription.ConsumerSecret });
}
/// <summary>
@@ -145,12 +125,36 @@ namespace DotNetOpenAuth.Test.Mocks {
this.requestTokens[requestToken] = true;
}
- private class TokenInfo {
- internal string Token;
- internal string Verifier;
- internal string Secret;
- internal Uri Callback;
- internal Version ConsumerVersion;
+ private class TokenInfo : IServiceProviderRequestToken {
+ public string ConsumerKey { get; set; }
+
+ public string Token { get; set; }
+
+ public string VerificationCode { get; set; }
+
+ public Uri Callback { get; set; }
+
+ public Version ConsumerVersion { get; set; }
+
+ internal string Secret { get; set; }
+ }
+
+ private class ConsumerInfo : IConsumerDescription {
+ #region IConsumerDescription Members
+
+ public string Key { get; set; }
+
+ public string Secret { get; set; }
+
+ public System.Security.Cryptography.X509Certificates.X509Certificate2 Certificate { get; set; }
+
+ public Uri Callback { get; set; }
+
+ public DotNetOpenAuth.OAuth.VerificationCodeFormat VerificationCodeFormat { get; set; }
+
+ public int VerificationCodeLength { get; set; }
+
+ #endregion
}
}
}