diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-04-22 09:00:23 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-04-22 09:00:23 -0700 |
commit | efbff7b947ef326b7b007613e30b2d4ad1b6094b (patch) | |
tree | 8bb26657f558c359215e2e7e129306964f8d8e03 | |
parent | 29eb21d69595b58579a9573958597def7ac0a672 (diff) | |
download | DotNetOpenAuth-efbff7b947ef326b7b007613e30b2d4ad1b6094b.zip DotNetOpenAuth-efbff7b947ef326b7b007613e30b2d4ad1b6094b.tar.gz DotNetOpenAuth-efbff7b947ef326b7b007613e30b2d4ad1b6094b.tar.bz2 |
Added the rest of the message type tests for the WRAP draft I'm working off of.
-rw-r--r-- | src/DotNetOpenAuth.Test/OAuthWrap/MessageFactoryTests.cs | 115 |
1 files changed, 113 insertions, 2 deletions
diff --git a/src/DotNetOpenAuth.Test/OAuthWrap/MessageFactoryTests.cs b/src/DotNetOpenAuth.Test/OAuthWrap/MessageFactoryTests.cs index 9526f9a..82a765a 100644 --- a/src/DotNetOpenAuth.Test/OAuthWrap/MessageFactoryTests.cs +++ b/src/DotNetOpenAuth.Test/OAuthWrap/MessageFactoryTests.cs @@ -21,7 +21,7 @@ namespace DotNetOpenAuth.Test.OAuthWrap { public class MessageFactoryTests : OAuthWrapTestBase { private OAuthWrapChannel channel; private IMessageFactory messageFactory; - private MessageReceivingEndpoint recipient = new MessageReceivingEndpoint("http://who", HttpDeliveryMethods.PostRequest); + private readonly MessageReceivingEndpoint recipient = new MessageReceivingEndpoint("http://who", HttpDeliveryMethods.PostRequest); public override void SetUp() { base.SetUp(); @@ -117,7 +117,8 @@ namespace DotNetOpenAuth.Test.OAuthWrap { [TestCase, Ignore("Not implemented")] public void WebAppAccessTokenBadClientResponse() { - // HTTP 401 Unauthorized + // HTTP 401 Unauthorized + // WWW-Authenticate: WRAP } [TestCase] @@ -224,6 +225,116 @@ namespace DotNetOpenAuth.Test.OAuthWrap { this.messageFactory.GetNewResponseMessage(request, fields)); } + [TestCase] + public void RichAppAccessTokenRequest() { + // include just required parameters + var fields = new Dictionary<string, string> { + { Protocol.wrap_client_id, "abc" }, + { Protocol.wrap_verification_code, "abc" }, + }; + IDirectedProtocolMessage request = this.messageFactory.GetNewRequestMessage(this.recipient, fields); + Assert.IsInstanceOf(typeof(RichAppAccessTokenRequest), request); + } + + [TestCase] + public void RichAppAccessTokenSuccessResponse() { + var fields = new Dictionary<string, string> { + { Protocol.wrap_refresh_token, "abc" }, + { Protocol.wrap_access_token, "abc" }, + }; + var request = new RichAppAccessTokenRequest(this.recipient.Location, Protocol.Default.Version); + Assert.IsInstanceOf( + typeof(RichAppAccessTokenSuccessResponse), + this.messageFactory.GetNewResponseMessage(request, fields)); + } + + [TestCase] + public void RichAppAccessTokenFailedResponse() { + // HTTP 401 Unauthorized + // WWW-Authenticate: WRAP + var fields = new Dictionary<string, string> { + }; + var request = new RichAppAccessTokenRequest(this.recipient.Location, Protocol.Default.Version); + Assert.IsInstanceOf( + typeof(RichAppAccessTokenFailedResponse), + this.messageFactory.GetNewResponseMessage(request, fields)); + } + + #endregion + + #region Client Account and Password profile messages + + [TestCase] + public void ClientAccountUsernamePasswordRequest() { + var fields = new Dictionary<string, string> { + { Protocol.wrap_name, "abc" }, + { Protocol.wrap_password, "abc" }, + }; + IDirectedProtocolMessage request = this.messageFactory.GetNewRequestMessage(this.recipient, fields); + Assert.IsInstanceOf(typeof(ClientAccountUsernamePasswordRequest), request); + } + + [TestCase] + public void ClientAccountUsernamePasswordSuccessResponse() { + var fields = new Dictionary<string, string> { + { Protocol.wrap_refresh_token, "abc" }, + { Protocol.wrap_access_token, "abc" }, + }; + var request = new ClientAccountUsernamePasswordRequest(this.recipient.Location, Protocol.Default.Version); + Assert.IsInstanceOf( + typeof(ClientAccountUsernamePasswordSuccessResponse), + this.messageFactory.GetNewResponseMessage(request, fields)); + } + + [TestCase] + public void ClientAccountUsernamePasswordFailedResponse() { + // HTTP 401 Unauthorized + // WWW-Authenticate: WRAP + var fields = new Dictionary<string, string> { + }; + var request = new ClientAccountUsernamePasswordRequest(this.recipient.Location, Protocol.Default.Version); + Assert.IsInstanceOf( + typeof(ClientAccountUsernamePasswordFailedResponse), + this.messageFactory.GetNewResponseMessage(request, fields)); + } + + #endregion + + #region Assertion profile messages + + [TestCase] + public void AssertionRequest() { + var fields = new Dictionary<string, string> { + { Protocol.wrap_assertion_format, "abc" }, + { Protocol.wrap_assertion, "abc" }, + }; + IDirectedProtocolMessage request = this.messageFactory.GetNewRequestMessage(this.recipient, fields); + Assert.IsInstanceOf(typeof(AssertionRequest), request); + } + + [TestCase] + public void AssertionSuccessResponse() { + var fields = new Dictionary<string, string> { + { Protocol.wrap_access_token, "abc" }, + }; + var request = new AssertionRequest(this.recipient.Location, Protocol.Default.Version); + Assert.IsInstanceOf( + typeof(AssertionSuccessResponse), + this.messageFactory.GetNewResponseMessage(request, fields)); + } + + [TestCase] + public void AssertionFailedResponse() { + // HTTP 401 Unauthorized + // WWW-Authenticate: WRAP + var fields = new Dictionary<string, string> { + }; + var request = new AssertionRequest(this.recipient.Location, Protocol.Default.Version); + Assert.IsInstanceOf( + typeof(AssertionFailedResponse), + this.messageFactory.GetNewResponseMessage(request, fields)); + } + #endregion } } |