diff options
Diffstat (limited to 'src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs')
-rw-r--r-- | src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs b/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs index 49bec4c..300c252 100644 --- a/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs +++ b/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs @@ -9,6 +9,7 @@ namespace DotNetOAuth.Test.Scenarios { using System.Reflection;
using System.Threading;
using DotNetOAuth.ChannelElements;
+ using DotNetOAuth.Messages;
using DotNetOAuth.Messaging;
using DotNetOAuth.Messaging.Bindings;
using DotNetOAuth.Messaging.Reflection;
@@ -20,6 +21,7 @@ namespace DotNetOAuth.Test.Scenarios { internal class CoordinatingOAuthChannel : OAuthChannel {
private EventWaitHandle incomingMessageSignal = new AutoResetEvent(false);
private IProtocolMessage incomingMessage;
+ private Response incomingRawResponse;
/// <summary>
/// Initializes a new instance of the <see cref="CoordinatingOAuthChannel"/> class for Consumers.
@@ -40,6 +42,20 @@ namespace DotNetOAuth.Test.Scenarios { /// </summary>
internal CoordinatingOAuthChannel RemoteChannel { get; set; }
+ internal Response RequestProtectedResource(AccessProtectedResourcesMessage request) {
+ TestBase.TestLogger.InfoFormat("Sending protected resource request: {0}", request);
+ PrepareMessageForSending(request);
+ // Drop the outgoing message in the other channel's in-slot and let them know it's there.
+ this.RemoteChannel.incomingMessage = request;
+ this.RemoteChannel.incomingMessageSignal.Set();
+ return this.AwaitIncomingRawResponse();
+ }
+
+ internal void SendDirectRawResponse(Response response) {
+ this.RemoteChannel.incomingRawResponse = response;
+ this.RemoteChannel.incomingMessageSignal.Set();
+ }
+
protected override IProtocolMessage RequestInternal(IDirectedProtocolMessage request) {
TestBase.TestLogger.InfoFormat("Sending request: {0}", request);
// Drop the outgoing message in the other channel's in-slot and let them know it's there.
@@ -66,7 +82,7 @@ namespace DotNetOAuth.Test.Scenarios { }
protected override IProtocolMessage ReadFromRequestInternal(HttpRequestInfo request) {
- return request.Message;
+ return request.Message ?? base.ReadFromRequestInternal(request);
}
private IProtocolMessage AwaitIncomingMessage() {
@@ -76,6 +92,13 @@ namespace DotNetOAuth.Test.Scenarios { return response;
}
+ private Response AwaitIncomingRawResponse() {
+ this.incomingMessageSignal.WaitOne();
+ Response response = this.incomingRawResponse;
+ this.incomingRawResponse = null;
+ return response;
+ }
+
private T CloneSerializedParts<T>(T message) where T : class, IProtocolMessage {
if (message == null) {
throw new ArgumentNullException("message");
|