diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-02-17 21:27:51 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-02-17 21:27:51 -0800 |
commit | cb2d22209b169f5470bc4db8b8be5ec88dc1811e (patch) | |
tree | 3f78da3b50a0a887e54d9993dfb3c978e6c99e9e /src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs | |
parent | 656ef7b1b405d56d986776082a2670c68c415c44 (diff) | |
download | DotNetOpenAuth-cb2d22209b169f5470bc4db8b8be5ec88dc1811e.zip DotNetOpenAuth-cb2d22209b169f5470bc4db8b8be5ec88dc1811e.tar.gz DotNetOpenAuth-cb2d22209b169f5470bc4db8b8be5ec88dc1811e.tar.bz2 |
IAuthenticationRequest.AddCallbackArgument no longer appends parameters to existing values.
Fixes Google Code Issue 203.
Diffstat (limited to 'src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs')
-rw-r--r-- | src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs index e73ec13..ce95038 100644 --- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs @@ -11,6 +11,7 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { using System.Linq; using System.Text; using System.Web; + using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; using DotNetOpenAuth.OpenId.Messages; @@ -20,14 +21,15 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { [TestClass] public class AuthenticationRequestTests : OpenIdTestBase { private readonly Realm realm = new Realm("http://localhost/rp.aspx"); - private readonly Uri returnTo = new Uri("http://localhost/rp.aspx"); private readonly Identifier claimedId = "http://claimedId"; private readonly Identifier delegatedLocalId = "http://localId"; private readonly Protocol protocol = Protocol.Default; + private Uri returnTo; [TestInitialize] public override void SetUp() { base.SetUp(); + this.returnTo = new Uri("http://localhost/rp.aspx"); } /// <summary> @@ -113,11 +115,41 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { } /// <summary> + /// Verifies that AddCallbackArguments adds query arguments to the return_to URL of the message. + /// </summary> + [TestMethod] + public void AddCallbackArgument() { + IAuthenticationRequest_Accessor authRequest = this.CreateAuthenticationRequest(this.claimedId, this.claimedId); + Assert.AreEqual(this.returnTo, authRequest.ReturnToUrl); + authRequest.AddCallbackArguments("p1", "v1"); + var req = (SignedResponseRequest)authRequest.RedirectingResponse.OriginalMessage; + NameValueCollection query = HttpUtility.ParseQueryString(req.ReturnTo.Query); + Assert.AreEqual("v1", query["p1"]); + } + + /// <summary> + /// Verifies that AddCallbackArguments replaces pre-existing parameter values + /// rather than appending them. + /// </summary> + [TestMethod] + public void AddCallbackArgumentClearsPreviousArgument() { + UriBuilder returnToWithArgs = new UriBuilder(this.returnTo); + returnToWithArgs.AppendQueryArgs(new Dictionary<string, string> { { "p1", "v1" } }); + this.returnTo = returnToWithArgs.Uri; + IAuthenticationRequest_Accessor authRequest = this.CreateAuthenticationRequest(this.claimedId, this.claimedId); + authRequest.AddCallbackArguments("p1", "v2"); + var req = (SignedResponseRequest)authRequest.RedirectingResponse.OriginalMessage; + NameValueCollection query = HttpUtility.ParseQueryString(req.ReturnTo.Query); + Assert.AreEqual("v2", query["p1"]); + } + + /// <summary> /// Verifies that authentication requests are generated first for OPs that respond /// to authentication requests. /// </summary> [TestMethod, Ignore] public void UnresponsiveProvidersComeLast() { + // TODO: code here Assert.Inconclusive("Not yet implemented."); } |