summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/OpenId/RelyingParty
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Test/OpenId/RelyingParty')
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs28
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAnonymousResponseTests.cs56
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/RelyingParty/RelyingPartySecuritySettingsTests.cs37
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/RelyingParty/ServiceEndpointTests.cs40
4 files changed, 108 insertions, 53 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs
index 2c7e74c..10497b2 100644
--- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs
@@ -104,6 +104,22 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
}
/// <summary>
+ /// Verifies that delegating authentication requests are filtered out when configured to do so.
+ /// </summary>
+ [TestMethod]
+ public void CreateFiltersDelegatingIdentifiers() {
+ Identifier id = GetMockIdentifier(ProtocolVersion.V20, false, true);
+ var rp = CreateRelyingParty();
+
+ // First verify that delegating identifiers work
+ Assert.IsTrue(AuthenticationRequest.Create(id, rp, realm, returnTo, false).Any(), "The delegating identifier should have not generated any results.");
+
+ // Now disable them and try again.
+ rp.SecuritySettings.RejectDelegatingIdentifiers = true;
+ Assert.IsFalse(AuthenticationRequest.Create(id, rp, realm, returnTo, false).Any(), "The delegating identifier should have not generated any results.");
+ }
+
+ /// <summary>
/// Verifies the Provider property returns non-null.
/// </summary>
[TestMethod]
@@ -144,6 +160,18 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
}
/// <summary>
+ /// Verifies identity-less checkid_* request behavior.
+ /// </summary>
+ [TestMethod]
+ public void NonIdentityRequest() {
+ IAuthenticationRequest_Accessor authRequest = this.CreateAuthenticationRequest(this.claimedId, this.claimedId);
+ authRequest.IsExtensionOnly = true;
+ Assert.IsTrue(authRequest.IsExtensionOnly);
+ var req = (SignedResponseRequest)authRequest.RedirectingResponse.OriginalMessage;
+ Assert.IsNotInstanceOfType(req, typeof(CheckIdRequest), "An unexpected SignedResponseRequest derived type was generated.");
+ }
+
+ /// <summary>
/// Verifies that authentication requests are generated first for OPs that respond
/// to authentication requests.
/// </summary>
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAnonymousResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAnonymousResponseTests.cs
new file mode 100644
index 0000000..1418513
--- /dev/null
+++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAnonymousResponseTests.cs
@@ -0,0 +1,56 @@
+//-----------------------------------------------------------------------
+// <copyright file="PositiveAnonymousResponseTests.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
+ using System;
+ using DotNetOpenAuth.OpenId;
+ using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration;
+ using DotNetOpenAuth.OpenId.Messages;
+ using DotNetOpenAuth.OpenId.RelyingParty;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ [TestClass]
+ public class PositiveAnonymousResponseTests : OpenIdTestBase {
+ private readonly Realm realm = new Realm("http://localhost/rp.aspx");
+ private readonly Uri returnTo = new Uri("http://localhost/rp.aspx");
+
+ [TestInitialize]
+ public override void SetUp() {
+ base.SetUp();
+ }
+
+ /// <summary>
+ /// Verifies that the Status property returns the correct value.
+ /// </summary>
+ [TestMethod]
+ public void CtorAndProperties() {
+ var responseMessage = new IndirectSignedResponse(Protocol.V20.Version, this.returnTo);
+ var ext = new ClaimsResponse();
+ responseMessage.Extensions.Add(ext);
+ var response = new PositiveAnonymousResponse(responseMessage);
+ Assert.AreEqual(AuthenticationStatus.ExtensionsOnly, response.Status);
+ Assert.AreSame(responseMessage, response.Response);
+ Assert.IsNull(response.ClaimedIdentifier);
+ Assert.IsNull(response.FriendlyIdentifierForDisplay);
+ Assert.IsNull(response.Exception);
+ Assert.IsNull(response.Provider);
+ Assert.AreSame(ext, response.GetUntrustedExtension<ClaimsResponse>());
+ }
+
+ /// <summary>
+ /// Verifies the Provider property.
+ /// </summary>
+ [TestMethod]
+ public void ProviderTest() {
+ var responseMessage = new IndirectSignedResponse(Protocol.V20.Version, this.returnTo);
+ responseMessage.ProviderEndpoint = OPUri;
+ var response = new PositiveAnonymousResponse(responseMessage);
+ Assert.IsNotNull(response.Provider);
+ Assert.AreEqual(OPUri, response.Provider.Uri);
+ Assert.AreEqual(responseMessage.Version, response.Provider.Version);
+ }
+ }
+}
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/RelyingPartySecuritySettingsTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/RelyingPartySecuritySettingsTests.cs
index cb5fbb5..851939e 100644
--- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/RelyingPartySecuritySettingsTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/RelyingPartySecuritySettingsTests.cs
@@ -23,13 +23,18 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
this.settings = new RelyingPartySecuritySettings();
}
+ [TestMethod]
+ public void Defaults() {
+ Assert.IsFalse(this.settings.RejectUnsolicitedAssertions);
+ Assert.IsFalse(this.settings.RequireSsl, "Default should be to not require SSL.");
+ }
+
/// <summary>
/// Verifies that the <see cref="RelyingPartySecuritySettings.RequireSsl"/> property
/// getter/setter are implemented correctly.
/// </summary>
[TestMethod]
public void RequireSsl() {
- Assert.IsFalse(this.settings.RequireSsl, "Default should be to not require SSL.");
this.settings.RequireSsl = true;
Assert.IsTrue(this.settings.RequireSsl);
this.settings.RequireSsl = false;
@@ -37,21 +42,27 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
}
/// <summary>
- /// Verifies that changing the <see cref="RelyingPartySecuritySettings.RequireSsl"/> property
- /// fires the <see cref="RelyingPartySecuritySettings.RequireSslChanged"/> event.
+ /// Verifies that the <see cref="RelyingPartySecuritySettings.RequireDirectedIdentity"/>
+ /// property getter/setter are implemented correctly.
/// </summary>
[TestMethod]
- public void RequireSslFiresEvent() {
- bool requireSslChanged = false;
- this.settings.RequireSslChanged += (sender, e) => { requireSslChanged = true; };
-
- // Setting the property to its current value should not fire event.
- this.settings.RequireSsl = this.settings.RequireSsl;
- Assert.IsFalse(requireSslChanged);
+ public void RequireDirectedIdentity() {
+ this.settings.RequireDirectedIdentity = true;
+ Assert.IsTrue(this.settings.RequireDirectedIdentity);
+ this.settings.RequireDirectedIdentity = false;
+ Assert.IsFalse(this.settings.RequireDirectedIdentity);
+ }
- // Changing the property's value should fire the event.
- this.settings.RequireSsl = !this.settings.RequireSsl;
- Assert.IsTrue(requireSslChanged);
+ /// <summary>
+ /// Verifies that the <see cref="RelyingPartySecuritySettings.RequireAssociation"/>
+ /// property getter/setter are implemented correctly.
+ /// </summary>
+ [TestMethod]
+ public void RequireAssociation() {
+ this.settings.RequireAssociation = true;
+ Assert.IsTrue(this.settings.RequireAssociation);
+ this.settings.RequireAssociation = false;
+ Assert.IsFalse(this.settings.RequireAssociation);
}
}
}
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/ServiceEndpointTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/ServiceEndpointTests.cs
index 7b71eef..bd09bc9 100644
--- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/ServiceEndpointTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/ServiceEndpointTests.cs
@@ -173,46 +173,6 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
Assert.AreEqual("=!9B72.7DD1.50A9.5CCD", se.FriendlyIdentifierForDisplay);
}
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void IsExtensionSupportedNullType() {
- ServiceEndpoint se = ServiceEndpoint.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, new ProviderEndpointDescription(this.providerEndpoint, this.v20TypeUris), this.servicePriority, this.uriPriority);
- se.IsExtensionSupported((Type)null);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void IsExtensionSupportedNullString() {
- ServiceEndpoint se = ServiceEndpoint.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, new ProviderEndpointDescription(this.providerEndpoint, this.v20TypeUris), this.servicePriority, this.uriPriority);
- se.IsExtensionSupported((string)null);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentException))]
- public void IsExtensionSupportedEmptyString() {
- ServiceEndpoint se = ServiceEndpoint.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, new ProviderEndpointDescription(this.providerEndpoint, this.v20TypeUris), this.servicePriority, this.uriPriority);
- se.IsExtensionSupported(string.Empty);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void IsExtensionSupportedNullExtension() {
- ServiceEndpoint se = ServiceEndpoint.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, new ProviderEndpointDescription(this.providerEndpoint, this.v20TypeUris), this.servicePriority, this.uriPriority);
- se.IsExtensionSupported((IOpenIdMessageExtension)null);
- }
-
- [TestMethod]
- public void IsExtensionSupported() {
- ServiceEndpoint se = ServiceEndpoint.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, new ProviderEndpointDescription(this.providerEndpoint, this.v20TypeUris), this.servicePriority, this.uriPriority);
- Assert.IsFalse(se.IsExtensionSupported<ClaimsRequest>());
- Assert.IsFalse(se.IsExtensionSupported(new ClaimsRequest()));
- Assert.IsFalse(se.IsExtensionSupported("http://someextension/typeuri"));
-
- ProviderEndpointDescription ped = new ProviderEndpointDescription(
- OPUri,
- new[] { Protocol.V20.ClaimedIdentifierServiceTypeURI, "http://someextension", Constants.sreg_ns });
- se = ServiceEndpoint.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, ped, this.servicePriority, this.uriPriority);
- Assert.IsTrue(se.IsExtensionSupported<ClaimsRequest>());
- Assert.IsTrue(se.IsExtensionSupported(new ClaimsRequest()));
- Assert.IsTrue(se.IsExtensionSupported("http://someextension"));
- }
-
[TestMethod]
public void IsTypeUriPresent() {
ServiceEndpoint se = ServiceEndpoint.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, new ProviderEndpointDescription(this.providerEndpoint, this.v20TypeUris), this.servicePriority, this.uriPriority);