diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-09-25 08:31:40 -0700 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-09-25 08:31:40 -0700 |
commit | a9fb696c40441e06ef817d7e28bae74c6a6cb6e4 (patch) | |
tree | e78f45395a2cee9592bceed86f3cbf2aba7c9022 /src/DotNetOAuth.Test/Scenarios | |
parent | e99268dcde5f942a2577a2d4d271febf991b6fa1 (diff) | |
download | DotNetOpenAuth-a9fb696c40441e06ef817d7e28bae74c6a6cb6e4.zip DotNetOpenAuth-a9fb696c40441e06ef817d7e28bae74c6a6cb6e4.tar.gz DotNetOpenAuth-a9fb696c40441e06ef817d7e28bae74c6a6cb6e4.tar.bz2 |
Added enough token management that the Appendix A scenario test is passing again.
Diffstat (limited to 'src/DotNetOAuth.Test/Scenarios')
-rw-r--r-- | src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs | 27 | ||||
-rw-r--r-- | src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs | 5 |
2 files changed, 20 insertions, 12 deletions
diff --git a/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs b/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs index 86d5d43..563fac3 100644 --- a/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs +++ b/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs @@ -8,45 +8,50 @@ namespace DotNetOAuth.Test { using System;
using System.Collections.Specialized;
using System.IO;
+ using System.Linq;
using System.Net;
using System.Web;
using DotNetOAuth.Messaging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DotNetOAuth.Test.Scenarios;
using DotNetOAuth.ChannelElements;
+ using System.Collections.Generic;
+ using DotNetOAuth.Test.Mocks;
[TestClass]
public class AppendixScenarios : TestBase {
[TestMethod]
public void SpecAppendixAExample() {
- ServiceProvider sp = new ServiceProvider {
+ ServiceProviderEndpoints spEndpoints = new ServiceProviderEndpoints() {
RequestTokenEndpoint = new ServiceProviderEndpoint("https://photos.example.net/request_token", HttpDeliveryMethod.PostRequest),
UserAuthorizationEndpoint = new ServiceProviderEndpoint("http://photos.example.net/authorize", HttpDeliveryMethod.GetRequest),
AccessTokenEndpoint = new ServiceProviderEndpoint("https://photos.example.net/access_token", HttpDeliveryMethod.PostRequest),
};
+ var tokenManager = new InMemoryTokenManager();
+ var sp = new ServiceProvider(spEndpoints, tokenManager);
+ Consumer consumer = new Consumer {
+ ConsumerKey = "dpf43f3p2l4k3l03",
+ ConsumerSecret = "kd94hf93k423kf44",
+ ServiceProvider = spEndpoints,
+ };
Coordinator coordinator = new Coordinator(
channel => {
- Consumer consumer = new Consumer {
- Channel = channel,
- ConsumerKey = "dpf43f3p2l4k3l03",
- ConsumerSecret = "kd94hf93k423kf44",
- ServiceProvider = sp,
- };
-
+ consumer.Channel = channel;
string requestTokenSecret = consumer.RequestUserAuthorization(new Uri("http://printer.example.com/request_token_ready"));
var accessTokenMessage = consumer.ProcessUserAuthorization(requestTokenSecret);
},
channel => {
+ tokenManager.AddConsumer(consumer.ConsumerKey, consumer.ConsumerSecret);
sp.Channel = channel;
var requestTokenMessage = sp.ReadTokenRequest();
- sp.SendUnauthorizedTokenResponse("hh5s93j4hdidpola", "hdhd0244k9j7ao03");
+ sp.SendUnauthorizedTokenResponse(requestTokenMessage);
var authRequest = sp.ReadAuthorizationRequest();
sp.SendAuthorizationResponse(authRequest);
var accessRequest = sp.ReadAccessTokenRequest();
- sp.SendAccessToken("nnch734d00sl2jdk", "pfkkdhi9sl3r4s00");
+ sp.SendAccessToken(accessRequest);
});
- coordinator.SigningElement = new PlainTextSigningBindingElement();
+ coordinator.SigningElement = (SigningBindingElementBase)sp.Channel.BindingElements.Single(el => el is SigningBindingElementBase);
coordinator.Start();
}
}
diff --git a/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs b/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs index 1de449a..2a42983 100644 --- a/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs +++ b/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs @@ -16,6 +16,7 @@ namespace DotNetOAuth.Test.Scenarios { using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DotNetOAuth.Messaging.Reflection;
+ using DotNetOAuth.Messages;
/// <summary>
/// A special channel used in test simulations to pass messages directly between two parties.
@@ -92,8 +93,10 @@ namespace DotNetOAuth.Test.Scenarios { directedMessage.Recipient,
directedMessage.HttpMethods);
cloned = (T)ctor.Invoke(new object[] { endpoint });
+ } else if ((ctor = message.GetType().GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[0], null)) != null) {
+ cloned = (T)ctor.Invoke(new object[0]);
} else {
- throw new InvalidOperationException("Unrecognized constructor signature.");
+ throw new InvalidOperationException("Unrecognized constructor signature on type " + message.GetType());
}
} else {
cloned = (T)Activator.CreateInstance(message.GetType(), true);
|