summaryrefslogtreecommitdiffstats
path: root/src/DotNetOAuth.Test/Mocks
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOAuth.Test/Mocks')
-rw-r--r--src/DotNetOAuth.Test/Mocks/InMemoryTokenManager.cs107
-rw-r--r--src/DotNetOAuth.Test/Mocks/MockReplayProtectionBindingElement.cs48
-rw-r--r--src/DotNetOAuth.Test/Mocks/MockSigningBindingElement.cs48
-rw-r--r--src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs55
-rw-r--r--src/DotNetOAuth.Test/Mocks/TestBadChannel.cs54
-rw-r--r--src/DotNetOAuth.Test/Mocks/TestBaseMessage.cs56
-rw-r--r--src/DotNetOAuth.Test/Mocks/TestChannel.cs35
-rw-r--r--src/DotNetOAuth.Test/Mocks/TestDerivedMessage.cs33
-rw-r--r--src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs43
-rw-r--r--src/DotNetOAuth.Test/Mocks/TestExpiringMessage.cs35
-rw-r--r--src/DotNetOAuth.Test/Mocks/TestMessage.cs63
-rw-r--r--src/DotNetOAuth.Test/Mocks/TestMessageTypeProvider.cs56
-rw-r--r--src/DotNetOAuth.Test/Mocks/TestReplayProtectedMessage.cs30
-rw-r--r--src/DotNetOAuth.Test/Mocks/TestSignedDirectedMessage.cs33
-rw-r--r--src/DotNetOAuth.Test/Mocks/TestWebRequestHandler.cs46
15 files changed, 0 insertions, 742 deletions
diff --git a/src/DotNetOAuth.Test/Mocks/InMemoryTokenManager.cs b/src/DotNetOAuth.Test/Mocks/InMemoryTokenManager.cs
deleted file mode 100644
index a39fd81..0000000
--- a/src/DotNetOAuth.Test/Mocks/InMemoryTokenManager.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="InMemoryTokenManager.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using DotNetOAuth.OAuth.ChannelElements;
- using DotNetOAuth.OAuth.Messages;
- using DotNetOAuth.Test.OAuth;
-
- internal class InMemoryTokenManager : ITokenManager {
- private Dictionary<string, string> consumersAndSecrets = new Dictionary<string, string>();
- private Dictionary<string, string> tokensAndSecrets = new Dictionary<string, string>();
-
- /// <summary>
- /// Request tokens that have been issued, and whether they have been authorized yet.
- /// </summary>
- private Dictionary<string, bool> requestTokens = new Dictionary<string, bool>();
-
- /// <summary>
- /// Access tokens that have been issued and have not yet expired.
- /// </summary>
- private List<string> accessTokens = new List<string>();
-
- #region ITokenManager Members
-
- public string GetConsumerSecret(string consumerKey) {
- return this.consumersAndSecrets[consumerKey];
- }
-
- public string GetTokenSecret(string token) {
- return this.tokensAndSecrets[token];
- }
-
- public void StoreNewRequestToken(UnauthorizedTokenRequest request, ITokenSecretContainingMessage response) {
- this.tokensAndSecrets[response.Token] = response.TokenSecret;
- this.requestTokens.Add(response.Token, false);
- }
-
- /// <summary>
- /// Checks whether a given request token has already been authorized
- /// by some user for use by the Consumer that requested it.
- /// </summary>
- /// <param name="requestToken">The Consumer's request token.</param>
- /// <returns>
- /// True if the request token has already been fully authorized by the user
- /// who owns the relevant protected resources. False if the token has not yet
- /// been authorized, has expired or does not exist.
- /// </returns>
- public bool IsRequestTokenAuthorized(string requestToken) {
- return this.requestTokens[requestToken];
- }
-
- public void ExpireRequestTokenAndStoreNewAccessToken(string consumerKey, string requestToken, string accessToken, string accessTokenSecret) {
- // The following line is commented out because consumers don't mark their own tokens
- // as authorized... only the SPs do. And since we multi-purpose this test class for
- // both SPs and Consumers, we won't do this extra check.
- ////Debug.Assert(this.requestTokens[requestToken], "Unauthorized token should not be exchanged for access token.");
- this.requestTokens.Remove(requestToken);
- this.accessTokens.Add(accessToken);
- this.tokensAndSecrets.Remove(requestToken);
- this.tokensAndSecrets[accessToken] = accessTokenSecret;
- }
-
- /// <summary>
- /// Classifies a token as a request token or an access token.
- /// </summary>
- /// <param name="token">The token to classify.</param>
- /// <returns>Request or Access token, or invalid if the token is not recognized.</returns>
- public TokenType GetTokenType(string token) {
- if (this.requestTokens.ContainsKey(token)) {
- return TokenType.RequestToken;
- } else if (this.accessTokens.Contains(token)) {
- return TokenType.AccessToken;
- } else {
- return TokenType.InvalidToken;
- }
- }
-
- #endregion
-
- /// <summary>
- /// Tells a Service Provider's token manager about a consumer and its secret
- /// so that the SP can verify the Consumer's signed messages.
- /// </summary>
- /// <param name="consumerDescription">The consumer description.</param>
- internal void AddConsumer(ConsumerDescription consumerDescription) {
- this.consumersAndSecrets.Add(consumerDescription.ConsumerKey, consumerDescription.ConsumerSecret);
- }
-
- /// <summary>
- /// Marks an existing token as authorized.
- /// </summary>
- /// <param name="requestToken">The request token.</param>
- internal void AuthorizeRequestToken(string requestToken) {
- if (requestToken == null) {
- throw new ArgumentNullException("requestToken");
- }
-
- this.requestTokens[requestToken] = true;
- }
- }
-}
diff --git a/src/DotNetOAuth.Test/Mocks/MockReplayProtectionBindingElement.cs b/src/DotNetOAuth.Test/Mocks/MockReplayProtectionBindingElement.cs
deleted file mode 100644
index ffd6044..0000000
--- a/src/DotNetOAuth.Test/Mocks/MockReplayProtectionBindingElement.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="MockReplayProtectionBindingElement.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using DotNetOAuth.Messaging;
- using DotNetOAuth.Messaging.Bindings;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
-
- internal class MockReplayProtectionBindingElement : IChannelBindingElement {
- private bool messageReceived;
-
- #region IChannelBindingElement Members
-
- MessageProtections IChannelBindingElement.Protection {
- get { return MessageProtections.ReplayProtection; }
- }
-
- bool IChannelBindingElement.PrepareMessageForSending(IProtocolMessage message) {
- var replayMessage = message as IReplayProtectedProtocolMessage;
- if (replayMessage != null) {
- replayMessage.Nonce = "someNonce";
- return true;
- }
-
- return false;
- }
-
- bool IChannelBindingElement.PrepareMessageForReceiving(IProtocolMessage message) {
- var replayMessage = message as IReplayProtectedProtocolMessage;
- if (replayMessage != null) {
- Assert.AreEqual("someNonce", replayMessage.Nonce, "The nonce didn't serialize correctly, or something");
- // this mock implementation passes the first time and fails subsequent times.
- if (this.messageReceived) {
- throw new ReplayedMessageException(message);
- }
- this.messageReceived = true;
- return true;
- }
-
- return false;
- }
-
- #endregion
- }
-}
diff --git a/src/DotNetOAuth.Test/Mocks/MockSigningBindingElement.cs b/src/DotNetOAuth.Test/Mocks/MockSigningBindingElement.cs
deleted file mode 100644
index 97298ad..0000000
--- a/src/DotNetOAuth.Test/Mocks/MockSigningBindingElement.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="MockSigningBindingElement.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using DotNetOAuth.Messaging;
- using DotNetOAuth.Messaging.Bindings;
-
- internal class MockSigningBindingElement : IChannelBindingElement {
- internal const string MessageSignature = "mocksignature";
-
- #region IChannelBindingElement Members
-
- MessageProtections IChannelBindingElement.Protection {
- get { return MessageProtections.TamperProtection; }
- }
-
- bool IChannelBindingElement.PrepareMessageForSending(IProtocolMessage message) {
- ITamperResistantProtocolMessage signedMessage = message as ITamperResistantProtocolMessage;
- if (signedMessage != null) {
- signedMessage.Signature = MessageSignature;
- return true;
- }
-
- return false;
- }
-
- bool IChannelBindingElement.PrepareMessageForReceiving(IProtocolMessage message) {
- ITamperResistantProtocolMessage signedMessage = message as ITamperResistantProtocolMessage;
- if (signedMessage != null) {
- if (signedMessage.Signature != MessageSignature) {
- throw new InvalidSignatureException(message);
- }
- return true;
- }
-
- return false;
- }
-
- #endregion
- }
-}
diff --git a/src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs b/src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs
deleted file mode 100644
index 8ee6036..0000000
--- a/src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="MockTransformationBindingElement.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using DotNetOAuth.Messaging;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
-
- internal class MockTransformationBindingElement : IChannelBindingElement {
- private string transform;
-
- internal MockTransformationBindingElement(string transform) {
- if (transform == null) {
- throw new ArgumentNullException("transform");
- }
-
- this.transform = transform;
- }
-
- #region IChannelBindingElement Members
-
- MessageProtections IChannelBindingElement.Protection {
- get { return MessageProtections.None; }
- }
-
- bool IChannelBindingElement.PrepareMessageForSending(IProtocolMessage message) {
- var testMessage = message as TestMessage;
- if (testMessage != null) {
- testMessage.Name = this.transform + testMessage.Name;
- return true;
- }
-
- return false;
- }
-
- bool IChannelBindingElement.PrepareMessageForReceiving(IProtocolMessage message) {
- var testMessage = message as TestMessage;
- if (testMessage != null) {
- StringAssert.StartsWith(testMessage.Name, this.transform);
- testMessage.Name = testMessage.Name.Substring(this.transform.Length);
- return true;
- }
-
- return false;
- }
-
- #endregion
- }
-}
diff --git a/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs b/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs
deleted file mode 100644
index 781d65b..0000000
--- a/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="TestBadChannel.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using DotNetOAuth.Messaging;
-
- /// <summary>
- /// A Channel derived type that passes null to the protected constructor.
- /// </summary>
- internal class TestBadChannel : Channel {
- internal TestBadChannel(bool badConstructorParam)
- : base(badConstructorParam ? null : new TestMessageTypeProvider()) {
- }
-
- internal new void Create301RedirectResponse(IDirectedProtocolMessage message, IDictionary<string, string> fields) {
- base.Create301RedirectResponse(message, fields);
- }
-
- internal new void CreateFormPostResponse(IDirectedProtocolMessage message, IDictionary<string, string> fields) {
- base.CreateFormPostResponse(message, fields);
- }
-
- internal new void SendIndirectMessage(IDirectedProtocolMessage message) {
- base.SendIndirectMessage(message);
- }
-
- internal new IProtocolMessage Receive(Dictionary<string, string> fields, MessageReceivingEndpoint recipient) {
- return base.Receive(fields, recipient);
- }
-
- internal new IProtocolMessage ReadFromRequest(HttpRequestInfo request) {
- return base.ReadFromRequest(request);
- }
-
- protected override IProtocolMessage RequestInternal(IDirectedProtocolMessage request) {
- throw new NotImplementedException();
- }
-
- protected override IProtocolMessage ReadFromResponseInternal(System.IO.Stream responseStream) {
- throw new NotImplementedException();
- }
-
- protected override Response SendDirectMessageResponse(IProtocolMessage response) {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/DotNetOAuth.Test/Mocks/TestBaseMessage.cs b/src/DotNetOAuth.Test/Mocks/TestBaseMessage.cs
deleted file mode 100644
index c874d23..0000000
--- a/src/DotNetOAuth.Test/Mocks/TestBaseMessage.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="TestBaseMessage.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using System;
- using System.Collections.Generic;
- using System.Runtime.Serialization;
- using DotNetOAuth.Messaging;
- using DotNetOAuth.Messaging.Reflection;
-
- internal interface IBaseMessageExplicitMembers {
- string ExplicitProperty { get; set; }
- }
-
- internal class TestBaseMessage : IProtocolMessage, IBaseMessageExplicitMembers {
- private Dictionary<string, string> extraData = new Dictionary<string, string>();
-
- [MessagePart("age", IsRequired = true)]
- public int Age { get; set; }
-
- [MessagePart]
- public string Name { get; set; }
-
- [MessagePart("explicit")]
- string IBaseMessageExplicitMembers.ExplicitProperty { get; set; }
-
- Version IProtocolMessage.ProtocolVersion {
- get { return new Version(1, 0); }
- }
-
- MessageProtections IProtocolMessage.RequiredProtection {
- get { return MessageProtections.None; }
- }
-
- MessageTransport IProtocolMessage.Transport {
- get { return MessageTransport.Indirect; }
- }
-
- IDictionary<string, string> IProtocolMessage.ExtraData {
- get { return this.extraData; }
- }
-
- internal string PrivatePropertyAccessor {
- get { return this.PrivateProperty; }
- set { this.PrivateProperty = value; }
- }
-
- [MessagePart("private")]
- private string PrivateProperty { get; set; }
-
- void IProtocolMessage.EnsureValidMessage() { }
- }
-}
diff --git a/src/DotNetOAuth.Test/Mocks/TestChannel.cs b/src/DotNetOAuth.Test/Mocks/TestChannel.cs
deleted file mode 100644
index 1f75e3f..0000000
--- a/src/DotNetOAuth.Test/Mocks/TestChannel.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="TestChannel.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using DotNetOAuth.Messaging;
-
- internal class TestChannel : Channel {
- internal TestChannel()
- : this(new TestMessageTypeProvider()) {
- }
-
- internal TestChannel(IMessageTypeProvider messageTypeProvider, params IChannelBindingElement[] bindingElements)
- : base(messageTypeProvider, bindingElements) {
- }
-
- protected override IProtocolMessage RequestInternal(IDirectedProtocolMessage request) {
- throw new NotImplementedException("Request");
- }
-
- protected override IProtocolMessage ReadFromResponseInternal(System.IO.Stream responseStream) {
- throw new NotImplementedException("ReadFromResponse");
- }
-
- protected override Response SendDirectMessageResponse(IProtocolMessage response) {
- throw new NotImplementedException("SendDirectMessageResponse");
- }
- }
-}
diff --git a/src/DotNetOAuth.Test/Mocks/TestDerivedMessage.cs b/src/DotNetOAuth.Test/Mocks/TestDerivedMessage.cs
deleted file mode 100644
index 9d69495..0000000
--- a/src/DotNetOAuth.Test/Mocks/TestDerivedMessage.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="TestDerivedMessage.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using System.Runtime.Serialization;
- using DotNetOAuth.Messaging;
-
- internal class TestDerivedMessage : TestBaseMessage {
- /// <summary>
- /// Gets or sets the first value.
- /// </summary>
- /// <remarks>
- /// This element should appear AFTER <see cref="SecondDerivedElement"/>
- /// due to alphabetical ordering rules, but after all the elements in the
- /// base class due to inheritance rules.
- /// </remarks>
- [MessagePart]
- public string TheFirstDerivedElement { get; set; }
-
- /// <summary>
- /// Gets or sets the second value.
- /// </summary>
- /// <remarks>
- /// This element should appear BEFORE <see cref="TheFirstDerivedElement"/>,
- /// but after all the elements in the base class.
- /// </remarks>
- [MessagePart]
- public string SecondDerivedElement { get; set; }
- }
-}
diff --git a/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs b/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs
deleted file mode 100644
index 39aa6f3..0000000
--- a/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="TestDirectedMessage.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using System;
- using DotNetOAuth.Messaging;
- using DotNetOAuth.OAuth.ChannelElements;
-
- internal class TestDirectedMessage : TestMessage, IOAuthDirectedMessage {
- internal TestDirectedMessage() {
- }
-
- internal TestDirectedMessage(MessageTransport transport) : base(transport) {
- }
-
- #region IDirectedProtocolMessage Members
-
- public Uri Recipient { get; set; }
-
- #endregion
-
- #region IProtocolMessage Properties
-
- MessageProtections IProtocolMessage.RequiredProtection {
- get { return this.RequiredProtection; }
- }
-
- #endregion
-
- #region IOAuthDirectedMessage Members
-
- public HttpDeliveryMethods HttpMethods { get; internal set; }
-
- #endregion
-
- protected virtual MessageProtections RequiredProtection {
- get { return MessageProtections.None; }
- }
- }
-}
diff --git a/src/DotNetOAuth.Test/Mocks/TestExpiringMessage.cs b/src/DotNetOAuth.Test/Mocks/TestExpiringMessage.cs
deleted file mode 100644
index b14d4f2..0000000
--- a/src/DotNetOAuth.Test/Mocks/TestExpiringMessage.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="TestExpiringMessage.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using System;
- using System.Diagnostics;
- using System.Runtime.Serialization;
- using DotNetOAuth.Messaging;
- using DotNetOAuth.Messaging.Bindings;
- using DotNetOAuth.Messaging.Reflection;
-
- internal class TestExpiringMessage : TestSignedDirectedMessage, IExpiringProtocolMessage {
- [DebuggerBrowsable(DebuggerBrowsableState.Never)]
- private DateTime utcCreationDate;
-
- internal TestExpiringMessage() { }
-
- internal TestExpiringMessage(MessageTransport transport)
- : base(transport) {
- }
-
- #region IExpiringProtocolMessage Members
-
- [MessagePart("created_on", IsRequired = true)]
- DateTime IExpiringProtocolMessage.UtcCreationDate {
- get { return this.utcCreationDate; }
- set { this.utcCreationDate = value.ToUniversalTime(); }
- }
-
- #endregion
- }
-}
diff --git a/src/DotNetOAuth.Test/Mocks/TestMessage.cs b/src/DotNetOAuth.Test/Mocks/TestMessage.cs
deleted file mode 100644
index 0cb331c..0000000
--- a/src/DotNetOAuth.Test/Mocks/TestMessage.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="TestMessage.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using System;
- using System.Collections.Generic;
- using System.Runtime.Serialization;
- using DotNetOAuth.Messaging;
- using DotNetOAuth.Messaging.Reflection;
-
- internal class TestMessage : IProtocolMessage {
- private MessageTransport transport;
- private Dictionary<string, string> extraData = new Dictionary<string, string>();
-
- internal TestMessage()
- : this(MessageTransport.Direct) {
- }
-
- internal TestMessage(MessageTransport transport) {
- this.transport = transport;
- }
-
- [MessagePart("age", IsRequired = true)]
- public int Age { get; set; }
- [MessagePart("Name")]
- public string Name { get; set; }
- [MessagePart]
- public string EmptyMember { get; set; }
- [MessagePart(null)] // null name tests that Location is still the name.
- public Uri Location { get; set; }
- [MessagePart(IsRequired = true)]
- public DateTime Timestamp { get; set; }
-
- #region IProtocolMessage Members
-
- Version IProtocolMessage.ProtocolVersion {
- get { return new Version(1, 0); }
- }
-
- MessageProtections IProtocolMessage.RequiredProtection {
- get { return MessageProtections.None; }
- }
-
- MessageTransport IProtocolMessage.Transport {
- get { return this.transport; }
- }
-
- IDictionary<string, string> IProtocolMessage.ExtraData {
- get { return this.extraData; }
- }
-
- void IProtocolMessage.EnsureValidMessage() {
- if (this.EmptyMember != null || this.Age < 0) {
- throw new ProtocolException();
- }
- }
-
- #endregion
- }
-}
diff --git a/src/DotNetOAuth.Test/Mocks/TestMessageTypeProvider.cs b/src/DotNetOAuth.Test/Mocks/TestMessageTypeProvider.cs
deleted file mode 100644
index 85e2b05..0000000
--- a/src/DotNetOAuth.Test/Mocks/TestMessageTypeProvider.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="TestMessageTypeProvider.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using DotNetOAuth.Messaging;
-
- internal class TestMessageTypeProvider : IMessageTypeProvider {
- private bool signedMessages;
- private bool expiringMessages;
- private bool replayMessages;
-
- internal TestMessageTypeProvider()
- : this(false, false, false) {
- }
-
- internal TestMessageTypeProvider(bool signed, bool expiring, bool replay) {
- if ((!signed && expiring) || (!expiring && replay)) {
- throw new ArgumentException("Invalid combination of protection.");
- }
- this.signedMessages = signed;
- this.expiringMessages = expiring;
- this.replayMessages = replay;
- }
-
- #region IMessageTypeProvider Members
-
- public Type GetRequestMessageType(IDictionary<string, string> fields) {
- if (fields.ContainsKey("age")) {
- if (this.signedMessages) {
- if (this.expiringMessages) {
- if (this.replayMessages) {
- return typeof(TestReplayProtectedMessage);
- }
- return typeof(TestExpiringMessage);
- }
- return typeof(TestSignedDirectedMessage);
- }
- return typeof(TestMessage);
- }
- return null;
- }
-
- public Type GetResponseMessageType(IProtocolMessage request, IDictionary<string, string> fields) {
- return this.GetRequestMessageType(fields);
- }
-
- #endregion
- }
-}
diff --git a/src/DotNetOAuth.Test/Mocks/TestReplayProtectedMessage.cs b/src/DotNetOAuth.Test/Mocks/TestReplayProtectedMessage.cs
deleted file mode 100644
index 6467ebc..0000000
--- a/src/DotNetOAuth.Test/Mocks/TestReplayProtectedMessage.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="TestReplayProtectedMessage.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using System.Runtime.Serialization;
- using DotNetOAuth.Messaging;
- using DotNetOAuth.Messaging.Bindings;
- using DotNetOAuth.Messaging.Reflection;
-
- internal class TestReplayProtectedMessage : TestExpiringMessage, IReplayProtectedProtocolMessage {
- internal TestReplayProtectedMessage() { }
-
- internal TestReplayProtectedMessage(MessageTransport transport)
- : base(transport) {
- }
-
- #region IReplayProtectedProtocolMessage Members
-
- [MessagePart("Nonce")]
- string IReplayProtectedProtocolMessage.Nonce {
- get;
- set;
- }
-
- #endregion
- }
-}
diff --git a/src/DotNetOAuth.Test/Mocks/TestSignedDirectedMessage.cs b/src/DotNetOAuth.Test/Mocks/TestSignedDirectedMessage.cs
deleted file mode 100644
index 0cb880d..0000000
--- a/src/DotNetOAuth.Test/Mocks/TestSignedDirectedMessage.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="TestSignedDirectedMessage.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using DotNetOAuth.Messaging;
- using DotNetOAuth.Messaging.Bindings;
- using DotNetOAuth.Messaging.Reflection;
-
- internal class TestSignedDirectedMessage : TestDirectedMessage, ITamperResistantProtocolMessage {
- internal TestSignedDirectedMessage() { }
-
- internal TestSignedDirectedMessage(MessageTransport transport)
- : base(transport) {
- }
-
- #region ISignedProtocolMessage Members
-
- [MessagePart]
- public string Signature {
- get;
- set;
- }
-
- #endregion
-
- protected override MessageProtections RequiredProtection {
- get { return MessageProtections.TamperProtection; }
- }
- }
-}
diff --git a/src/DotNetOAuth.Test/Mocks/TestWebRequestHandler.cs b/src/DotNetOAuth.Test/Mocks/TestWebRequestHandler.cs
deleted file mode 100644
index f0e1b62..0000000
--- a/src/DotNetOAuth.Test/Mocks/TestWebRequestHandler.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="TestWebRequestHandler.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.Test.Mocks {
- using System;
- using System.IO;
- using System.Net;
- using System.Text;
- using DotNetOAuth.Messaging;
- using DotNetOAuth.OAuth.ChannelElements;
-
- internal class TestWebRequestHandler : IWebRequestHandler {
- private StringBuilder postEntity;
-
- internal Func<HttpWebRequest, Response> Callback { get; set; }
-
- internal Stream RequestEntityStream {
- get {
- if (this.postEntity == null) {
- return null;
- }
- return new MemoryStream(Encoding.UTF8.GetBytes(this.postEntity.ToString()));
- }
- }
-
- #region IWebRequestHandler Members
-
- public TextWriter GetRequestStream(HttpWebRequest request) {
- this.postEntity = new StringBuilder();
- return new StringWriter(this.postEntity);
- }
-
- public Response GetResponse(HttpWebRequest request) {
- if (this.Callback == null) {
- throw new InvalidOperationException("Set the Callback property first.");
- }
-
- return this.Callback(request);
- }
-
- #endregion
- }
-}