diff options
Diffstat (limited to 'src/DotNetOpenAuth.Test/Mocks')
4 files changed, 40 insertions, 12 deletions
diff --git a/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs b/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs index 2e09943..50eff97 100644 --- a/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs +++ b/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs @@ -88,6 +88,11 @@ namespace DotNetOpenAuth.Test.Mocks { private Action<IProtocolMessage> outgoingMessageFilter; /// <summary> + /// The simulated clients cookies. + /// </summary> + private HttpCookieCollection cookies = new HttpCookieCollection(); + + /// <summary> /// Initializes a new instance of the <see cref="CoordinatingChannel"/> class. /// </summary> /// <param name="wrappedChannel">The wrapped channel. Must not be null.</param> @@ -158,15 +163,23 @@ namespace DotNetOpenAuth.Test.Mocks { this.incomingMessageSignal.Set(); } + internal void SaveCookies(HttpCookieCollection cookies) { + Requires.NotNull(cookies, "cookies"); + foreach (string cookieName in cookies) { + var cookie = cookies[cookieName]; + this.cookies.Set(cookie); + } + } + protected internal override HttpRequestBase GetRequestFromContext() { MessageReceivingEndpoint recipient; WebHeaderCollection headers; var messageData = this.AwaitIncomingMessage(out recipient, out headers); CoordinatingHttpRequestInfo result; if (messageData != null) { - result = new CoordinatingHttpRequestInfo(this, this.MessageFactory, messageData, recipient); + result = new CoordinatingHttpRequestInfo(this, this.MessageFactory, messageData, recipient, this.cookies); } else { - result = new CoordinatingHttpRequestInfo(recipient); + result = new CoordinatingHttpRequestInfo(recipient, this.cookies); } if (headers != null) { @@ -207,7 +220,7 @@ namespace DotNetOpenAuth.Test.Mocks { protected override OutgoingWebResponse PrepareDirectResponse(IProtocolMessage response) { this.ProcessMessageFilter(response, true); - return new CoordinatingOutgoingWebResponse(response, this.RemoteChannel); + return new CoordinatingOutgoingWebResponse(response, this.RemoteChannel, this); } protected override OutgoingWebResponse PrepareIndirectResponse(IDirectedProtocolMessage message) { diff --git a/src/DotNetOpenAuth.Test/Mocks/CoordinatingHttpRequestInfo.cs b/src/DotNetOpenAuth.Test/Mocks/CoordinatingHttpRequestInfo.cs index a1f5cf5..2713765 100644 --- a/src/DotNetOpenAuth.Test/Mocks/CoordinatingHttpRequestInfo.cs +++ b/src/DotNetOpenAuth.Test/Mocks/CoordinatingHttpRequestInfo.cs @@ -6,10 +6,12 @@ namespace DotNetOpenAuth.Test.Mocks { using System; -using System.Collections.Generic; -using System.Diagnostics.Contracts; -using System.Net; -using DotNetOpenAuth.Messaging; + using System.Collections.Generic; + using System.Diagnostics.Contracts; + using System.Net; + using System.Web; + + using DotNetOpenAuth.Messaging; internal class CoordinatingHttpRequestInfo : HttpRequestInfo { private readonly Channel channel; @@ -30,12 +32,14 @@ using DotNetOpenAuth.Messaging; /// <param name="messageFactory">The message factory.</param> /// <param name="messageData">The message data.</param> /// <param name="recipient">The recipient.</param> + /// <param name="cookies">Cookies included in the incoming request.</param> internal CoordinatingHttpRequestInfo( Channel channel, IMessageFactory messageFactory, IDictionary<string, string> messageData, - MessageReceivingEndpoint recipient) - : this(recipient) { + MessageReceivingEndpoint recipient, + HttpCookieCollection cookies) + : this(recipient, cookies) { Contract.Requires(channel != null); Contract.Requires(messageFactory != null); Contract.Requires(messageData != null); @@ -49,8 +53,9 @@ using DotNetOpenAuth.Messaging; /// that will not generate any message. /// </summary> /// <param name="recipient">The recipient.</param> - internal CoordinatingHttpRequestInfo(MessageReceivingEndpoint recipient) - : base(GetHttpVerb(recipient), recipient != null ? recipient.Location : new Uri("http://host/path")) { + /// <param name="cookies">Cookies included in the incoming request.</param> + internal CoordinatingHttpRequestInfo(MessageReceivingEndpoint recipient, HttpCookieCollection cookies) + : base(GetHttpVerb(recipient), recipient != null ? recipient.Location : new Uri("http://host/path"), cookies: cookies) { this.recipient = recipient; } diff --git a/src/DotNetOpenAuth.Test/Mocks/CoordinatingOAuth2ClientChannel.cs b/src/DotNetOpenAuth.Test/Mocks/CoordinatingOAuth2ClientChannel.cs index 52f381d..96091ac 100644 --- a/src/DotNetOpenAuth.Test/Mocks/CoordinatingOAuth2ClientChannel.cs +++ b/src/DotNetOpenAuth.Test/Mocks/CoordinatingOAuth2ClientChannel.cs @@ -29,5 +29,9 @@ namespace DotNetOpenAuth.Test.Mocks { get { return this.wrappedChannel.ClientCredentialApplicator; } set { this.wrappedChannel.ClientCredentialApplicator = value; } } + + public System.Xml.XmlDictionaryReaderQuotas JsonReaderQuotas { + get { return this.XmlDictionaryReaderQuotas; } + } } }
\ No newline at end of file diff --git a/src/DotNetOpenAuth.Test/Mocks/CoordinatingOutgoingWebResponse.cs b/src/DotNetOpenAuth.Test/Mocks/CoordinatingOutgoingWebResponse.cs index 8d2c1e7..90dbd7d 100644 --- a/src/DotNetOpenAuth.Test/Mocks/CoordinatingOutgoingWebResponse.cs +++ b/src/DotNetOpenAuth.Test/Mocks/CoordinatingOutgoingWebResponse.cs @@ -16,16 +16,21 @@ namespace DotNetOpenAuth.Test.Mocks { internal class CoordinatingOutgoingWebResponse : OutgoingWebResponse { private CoordinatingChannel receivingChannel; + private CoordinatingChannel sendingChannel; + /// <summary> /// Initializes a new instance of the <see cref="CoordinatingOutgoingWebResponse"/> class. /// </summary> /// <param name="message">The direct response message to send to the remote channel. This message will be cloned.</param> /// <param name="receivingChannel">The receiving channel.</param> - internal CoordinatingOutgoingWebResponse(IProtocolMessage message, CoordinatingChannel receivingChannel) { + /// <param name="sendingChannel">The sending channel.</param> + internal CoordinatingOutgoingWebResponse(IProtocolMessage message, CoordinatingChannel receivingChannel, CoordinatingChannel sendingChannel) { Requires.NotNull(message, "message"); Requires.NotNull(receivingChannel, "receivingChannel"); + Requires.NotNull(sendingChannel, "sendingChannel"); this.receivingChannel = receivingChannel; + this.sendingChannel = sendingChannel; this.OriginalMessage = message; } @@ -35,6 +40,7 @@ namespace DotNetOpenAuth.Test.Mocks { } public override void Respond() { + this.sendingChannel.SaveCookies(this.Cookies); this.receivingChannel.PostMessage(this.OriginalMessage); } } |