summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/OpenId
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Test/OpenId')
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/ChannelElements/SigningBindingElementTests.cs2
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs13
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/Provider/OpenIdProviderTests.cs23
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/RelyingParty/OpenIdRelyingPartyTests.cs41
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs14
5 files changed, 82 insertions, 11 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/SigningBindingElementTests.cs b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/SigningBindingElementTests.cs
index 6bd2c00..3ab6559 100644
--- a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/SigningBindingElementTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/SigningBindingElementTests.cs
@@ -36,7 +36,7 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements {
signedMessage.UtcCreationDate = DateTime.Parse("1/1/2009");
signedMessage.AssociationHandle = association.Handle;
Assert.IsNotNull(signer.ProcessOutgoingMessage(message));
- Assert.AreEqual("0wOdvNgzCZ5I5AzbU58Nq2Tg8EJZ7QoNz4gpx2r7jII=", signedMessage.Signature);
+ Assert.AreEqual("o9+uN7qTaUS9v0otbHTuNAtbkpBm14+es9QnNo6IHD4=", signedMessage.Signature);
}
/// <summary>
diff --git a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs
index 59c818c..5034b7e 100644
--- a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs
@@ -71,6 +71,14 @@ namespace DotNetOpenAuth.Test.OpenId {
this.MockResponder = MockHttpRequest.CreateUntrustedMockHttpHandler();
this.RequestHandler = this.MockResponder.MockWebRequestHandler;
this.AutoProviderScenario = Scenarios.AutoApproval;
+ Identifier.EqualityOnStrings = true;
+ }
+
+ [TestCleanup]
+ public override void Cleanup() {
+ base.Cleanup();
+
+ Identifier.EqualityOnStrings = false;
}
/// <summary>
@@ -168,6 +176,11 @@ namespace DotNetOpenAuth.Test.OpenId {
}
}
+ protected Realm GetMockRealm(bool useSsl) {
+ var rpDescription = new RelyingPartyEndpointDescription(useSsl ? RPUriSsl : RPUri, new string[] { Protocol.V20.RPReturnToTypeURI });
+ return new MockRealm(useSsl ? RPRealmUriSsl : RPRealmUri, rpDescription);
+ }
+
protected Identifier GetMockIdentifier(ProtocolVersion providerVersion) {
return this.GetMockIdentifier(providerVersion, false);
}
diff --git a/src/DotNetOpenAuth.Test/OpenId/Provider/OpenIdProviderTests.cs b/src/DotNetOpenAuth.Test/OpenId/Provider/OpenIdProviderTests.cs
index 7c92389..8528aa7 100644
--- a/src/DotNetOpenAuth.Test/OpenId/Provider/OpenIdProviderTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/Provider/OpenIdProviderTests.cs
@@ -6,6 +6,7 @@
namespace DotNetOpenAuth.Test.OpenId.Provider {
using System;
+ using System.IO;
using System.Web;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OpenId;
@@ -128,15 +129,19 @@ namespace DotNetOpenAuth.Test.OpenId.Provider {
[TestMethod]
public void BadRequestsGenerateValidErrorResponsesHosted() {
- using (AspNetHost host = AspNetHost.CreateHost(TestWebDirectory)) {
- Uri opEndpoint = new Uri(host.BaseUri, "/OpenIdProviderEndpoint.ashx");
- var rp = new OpenIdRelyingParty(null);
- var nonOpenIdMessage = new Mocks.TestDirectedMessage();
- nonOpenIdMessage.Recipient = opEndpoint;
- nonOpenIdMessage.HttpMethods = HttpDeliveryMethods.PostRequest;
- MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired, nonOpenIdMessage);
- var response = rp.Channel.Request<DirectErrorResponse>(nonOpenIdMessage);
- Assert.IsNotNull(response.ErrorMessage);
+ try {
+ using (AspNetHost host = AspNetHost.CreateHost(TestWebDirectory)) {
+ Uri opEndpoint = new Uri(host.BaseUri, "/OpenIdProviderEndpoint.ashx");
+ var rp = new OpenIdRelyingParty(null);
+ var nonOpenIdMessage = new Mocks.TestDirectedMessage();
+ nonOpenIdMessage.Recipient = opEndpoint;
+ nonOpenIdMessage.HttpMethods = HttpDeliveryMethods.PostRequest;
+ MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired, nonOpenIdMessage);
+ var response = rp.Channel.Request<DirectErrorResponse>(nonOpenIdMessage);
+ Assert.IsNotNull(response.ErrorMessage);
+ }
+ } catch (FileNotFoundException ex) {
+ Assert.Inconclusive("Unable to execute hosted ASP.NET tests because {0} could not be found. {1}", ex.FileName, ex.FusionLog);
}
}
}
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/OpenIdRelyingPartyTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/OpenIdRelyingPartyTests.cs
index 68bbff3..f6a57e7 100644
--- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/OpenIdRelyingPartyTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/OpenIdRelyingPartyTests.cs
@@ -63,6 +63,21 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
Assert.AreEqual(1, requests.Count());
}
+ [TestMethod]
+ public void CreateRequestsWithEndpointFilter() {
+ var rp = this.CreateRelyingParty();
+ StoreAssociation(rp, OPUri, HmacShaAssociation.Create("somehandle", new byte[20], TimeSpan.FromDays(1)));
+ Identifier id = Identifier.Parse(GetMockIdentifier(ProtocolVersion.V20));
+
+ rp.EndpointFilter = opendpoint => true;
+ var requests = rp.CreateRequests(id, RPRealmUri, RPUri);
+ Assert.AreEqual(1, requests.Count());
+
+ rp.EndpointFilter = opendpoint => false;
+ requests = rp.CreateRequests(id, RPRealmUri, RPUri);
+ Assert.AreEqual(0, requests.Count());
+ }
+
[TestMethod, ExpectedException(typeof(ProtocolException))]
public void CreateRequestOnNonOpenID() {
Uri nonOpenId = new Uri("http://www.microsoft.com/");
@@ -79,5 +94,31 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
var requests = rp.CreateRequests(nonOpenId, RPRealmUri, RPUri);
Assert.AreEqual(0, requests.Count());
}
+
+ /// <summary>
+ /// Verifies that incoming positive assertions throw errors if they come from
+ /// OPs that are not approved by <see cref="OpenIdRelyingParty.EndpointFilter"/>.
+ /// </summary>
+ [TestMethod]
+ public void AssertionWithEndpointFilter() {
+ var coordinator = new OpenIdCoordinator(
+ rp => {
+ // register with RP so that id discovery passes
+ rp.Channel.WebRequestHandler = this.MockResponder.MockWebRequestHandler;
+
+ // Rig it to always deny the incoming OP
+ rp.EndpointFilter = op => false;
+
+ // Receive the unsolicited assertion
+ var response = rp.GetResponse();
+ Assert.AreEqual(AuthenticationStatus.Failed, response.Status);
+ },
+ op => {
+ Identifier id = GetMockIdentifier(ProtocolVersion.V20);
+ op.SendUnsolicitedAssertion(OPUri, GetMockRealm(false), id, id);
+ AutoProvider(op);
+ });
+ coordinator.Run();
+ }
}
}
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs
index 7701090..701bcae 100644
--- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs
@@ -38,7 +38,7 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
Assert.AreEqual(AuthenticationStatus.Authenticated, authResponse.Status);
Assert.IsNull(authResponse.Exception);
Assert.AreEqual<string>(assertion.ClaimedIdentifier, authResponse.ClaimedIdentifier);
- Assert.AreEqual<string>(authResponseAccessor.endpoint.FriendlyIdentifierForDisplay, authResponse.FriendlyIdentifierForDisplay);
+ Assert.AreEqual<string>(authResponse.Endpoint.FriendlyIdentifierForDisplay, authResponse.FriendlyIdentifierForDisplay);
Assert.AreSame(extension, authResponse.GetUntrustedExtension(typeof(ClaimsResponse)));
Assert.AreSame(extension, authResponse.GetUntrustedExtension<ClaimsResponse>());
Assert.IsNull(authResponse.GetCallbackArgument("a"));
@@ -59,6 +59,18 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
Assert.AreEqual(AuthenticationStatus.Failed, authResponse.Status);
}
+ /// <summary>
+ /// Verifies that the RP rejects positive assertions with HTTP Claimed
+ /// Cdentifiers when RequireSsl is set to true.
+ /// </summary>
+ [TestMethod, ExpectedException(typeof(ProtocolException))]
+ public void InsecureIdentifiersRejectedWithRequireSsl() {
+ PositiveAssertionResponse assertion = this.GetPositiveAssertion();
+ var rp = CreateRelyingParty();
+ rp.SecuritySettings.RequireSsl = true;
+ var authResponse = new PositiveAuthenticationResponse(assertion, rp);
+ }
+
[TestMethod]
public void GetCallbackArguments() {
PositiveAssertionResponse assertion = this.GetPositiveAssertion();