diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-01-10 14:57:27 -0800 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2009-01-10 14:57:27 -0800 |
commit | e01aa6be32c2d0437821459c97e4aa6d5e445ca6 (patch) | |
tree | fd510e97e050baa3bc3b4882171f16bca420de9e /src/DotNetOpenAuth.Test/OpenId | |
parent | 33f36e268403464e549882857f026bc1ad1fb102 (diff) | |
download | DotNetOpenAuth-e01aa6be32c2d0437821459c97e4aa6d5e445ca6.zip DotNetOpenAuth-e01aa6be32c2d0437821459c97e4aa6d5e445ca6.tar.gz DotNetOpenAuth-e01aa6be32c2d0437821459c97e4aa6d5e445ca6.tar.bz2 |
Added some tests for OpenIdRelyingParty.
Diffstat (limited to 'src/DotNetOpenAuth.Test/OpenId')
-rw-r--r-- | src/DotNetOpenAuth.Test/OpenId/RelyingParty/OpenIdRelyingPartyTests.cs | 37 | ||||
-rw-r--r-- | src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs | 2 |
2 files changed, 37 insertions, 2 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/OpenIdRelyingPartyTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/OpenIdRelyingPartyTests.cs index 3f8ff22..0fcb750 100644 --- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/OpenIdRelyingPartyTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/OpenIdRelyingPartyTests.cs @@ -6,9 +6,8 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { using System; - using System.Collections.Generic; using System.Linq; - using System.Text; + using DotNetOpenAuth.Messaging; using DotNetOpenAuth.Messaging.Bindings; using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.RelyingParty; @@ -31,5 +30,39 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { var rp = new OpenIdRelyingParty(new AssociationMemoryStore<Uri>(), new NonceMemoryStore(TimeSpan.FromMinutes(5)), new PrivateSecretMemoryStore()); rp.SecuritySettings = null; } + + [TestMethod] + public void CreateRequest() { + var rp = this.CreateRelyingParty(); + rp.AssociationStore.StoreAssociation(TestSupport.GetFullUrl("/" + TestSupport.ProviderPage), HmacShaAssociation.Create("somehandle", new byte[20], TimeSpan.FromDays(1))); + Identifier id = Identifier.Parse(GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20)); + var req = rp.CreateRequest(id, TestSupport.Realm, TestSupport.ReturnTo); + Assert.IsNotNull(req); + } + + [TestMethod] + public void CreateRequests() { + var rp = this.CreateRelyingParty(); + rp.AssociationStore.StoreAssociation(TestSupport.GetFullUrl("/" + TestSupport.ProviderPage), HmacShaAssociation.Create("somehandle", new byte[20], TimeSpan.FromDays(1))); + Identifier id = Identifier.Parse(GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20)); + var requests = rp.CreateRequests(id, TestSupport.Realm, TestSupport.ReturnTo); + Assert.AreEqual(1, requests.Count()); + } + [TestMethod, ExpectedException(typeof(ProtocolException))] + public void CreateRequestOnNonOpenID() { + Uri nonOpenId = new Uri("http://www.microsoft.com/"); + var rp = this.CreateRelyingParty(); + this.MockResponder.RegisterMockResponse(nonOpenId, "text/html", "<html/>"); + rp.CreateRequest(nonOpenId, TestSupport.Realm, TestSupport.ReturnTo); + } + + [TestMethod] + public void CreateRequestsOnNonOpenID() { + Uri nonOpenId = new Uri("http://www.microsoft.com/"); + var rp = this.CreateRelyingParty(); + this.MockResponder.RegisterMockResponse(nonOpenId, "text/html", "<html/>"); + var requests = rp.CreateRequests(nonOpenId, TestSupport.Realm, TestSupport.ReturnTo); + Assert.AreEqual(0, requests.Count()); + } } } diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs index 7ebd0a9..b3812ce 100644 --- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs @@ -40,6 +40,8 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { Assert.AreEqual<string>(authResponseAccessor.endpoint.FriendlyIdentifierForDisplay, authResponse.FriendlyIdentifierForDisplay); Assert.AreSame(extension, authResponse.GetExtension(typeof(ClaimsResponse))); Assert.AreSame(extension, authResponse.GetExtension<ClaimsResponse>()); + Assert.IsNull(authResponse.GetCallbackArgument("a")); + Assert.AreEqual(0, authResponse.GetCallbackArguments().Count); } /// <summary> |