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/AuthenticationTests.cs60
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/FetchResponseTests.cs16
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/Extensions/UI/UIRequestTests.cs37
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/NonIdentityTests.cs57
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs20
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/Provider/AnonymousRequestTests.cs37
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/Provider/AuthenticationRequestTest.cs15
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/Provider/HostProcessedRequestTests.cs85
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs28
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAnonymousResponseTests.cs42
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/RelyingParty/RelyingPartySecuritySettingsTests.cs25
11 files changed, 383 insertions, 39 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/AuthenticationTests.cs b/src/DotNetOpenAuth.Test/OpenId/AuthenticationTests.cs
index d825f4b..4ebdf74 100644
--- a/src/DotNetOpenAuth.Test/OpenId/AuthenticationTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/AuthenticationTests.cs
@@ -58,6 +58,66 @@ namespace DotNetOpenAuth.Test.OpenId {
this.ParameterizedAuthenticationTest(false, false, false);
}
+ [TestMethod]
+ public void UnsolicitedAssertion() {
+ this.MockResponder.RegisterMockRPDiscovery();
+ OpenIdCoordinator coordinator = new OpenIdCoordinator(
+ rp => {
+ rp.Channel.WebRequestHandler = this.MockResponder.MockWebRequestHandler;
+ IAuthenticationResponse response = rp.GetResponse();
+ Assert.AreEqual(AuthenticationStatus.Authenticated, response.Status);
+ },
+ op => {
+ op.Channel.WebRequestHandler = this.MockResponder.MockWebRequestHandler;
+ Identifier id = GetMockIdentifier(ProtocolVersion.V20);
+ op.SendUnsolicitedAssertion(OPUri, RPRealmUri, id, OPLocalIdentifiers[0]);
+ AutoProvider(op); // handle check_auth
+ });
+ coordinator.Run();
+ }
+
+ [TestMethod]
+ public void UnsolicitedAssertionRejected() {
+ this.MockResponder.RegisterMockRPDiscovery();
+ OpenIdCoordinator coordinator = new OpenIdCoordinator(
+ rp => {
+ rp.Channel.WebRequestHandler = this.MockResponder.MockWebRequestHandler;
+ rp.SecuritySettings.RejectUnsolicitedAssertions = true;
+ IAuthenticationResponse response = rp.GetResponse();
+ Assert.AreEqual(AuthenticationStatus.Failed, response.Status);
+ },
+ op => {
+ op.Channel.WebRequestHandler = this.MockResponder.MockWebRequestHandler;
+ Identifier id = GetMockIdentifier(ProtocolVersion.V20);
+ op.SendUnsolicitedAssertion(OPUri, RPRealmUri, id, OPLocalIdentifiers[0]);
+ AutoProvider(op); // handle check_auth
+ });
+ coordinator.Run();
+ }
+
+ /// <summary>
+ /// Verifies that delegating identifiers are rejected in unsolicited assertions
+ /// when the appropriate security setting is set.
+ /// </summary>
+ [TestMethod]
+ public void UnsolicitedDelegatingIdentifierRejection() {
+ this.MockResponder.RegisterMockRPDiscovery();
+ OpenIdCoordinator coordinator = new OpenIdCoordinator(
+ rp => {
+ rp.Channel.WebRequestHandler = this.MockResponder.MockWebRequestHandler;
+ rp.SecuritySettings.RejectDelegatingIdentifiers = true;
+ IAuthenticationResponse response = rp.GetResponse();
+ Assert.AreEqual(AuthenticationStatus.Failed, response.Status);
+ },
+ op => {
+ op.Channel.WebRequestHandler = this.MockResponder.MockWebRequestHandler;
+ Identifier id = GetMockIdentifier(ProtocolVersion.V20, false, true);
+ op.SendUnsolicitedAssertion(OPUri, RPRealmUri, id, OPLocalIdentifiers[0]);
+ AutoProvider(op); // handle check_auth
+ });
+ coordinator.Run();
+ }
+
private void ParameterizedAuthenticationTest(bool sharedAssociation, bool positive, bool tamper) {
foreach (Protocol protocol in Protocol.AllPracticalVersions) {
foreach (bool statelessRP in new[] { false, true }) {
diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/FetchResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/FetchResponseTests.cs
index 9d209a9..d7082c3 100644
--- a/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/FetchResponseTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/FetchResponseTests.cs
@@ -40,6 +40,22 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions {
}
[TestMethod]
+ public void GetAttributeValue() {
+ var response = new FetchResponse();
+
+ // Verify that null is returned if the attribute is absent.
+ Assert.IsNull(response.GetAttributeValue("http://someattribute"));
+
+ // Now add an attribute with no values.
+ response.Attributes.Add(new AttributeValues("http://someattribute2"));
+ Assert.IsNull(response.GetAttributeValue("http://someattribute2"));
+
+ // Now add an attribute with many values.
+ response.Attributes.Add(new AttributeValues("http://someattribute3", "a", "b", "c"));
+ Assert.AreEqual("a", response.GetAttributeValue("http://someattribute3"));
+ }
+
+ [TestMethod]
public void EqualityTests() {
var response1 = new FetchResponse();
var response2 = new FetchResponse();
diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/UI/UIRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/UI/UIRequestTests.cs
new file mode 100644
index 0000000..f69fc8b
--- /dev/null
+++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/UI/UIRequestTests.cs
@@ -0,0 +1,37 @@
+//-----------------------------------------------------------------------
+// <copyright file="UIRequestTests.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.Test.OpenId.Extensions.UI {
+ using System.Globalization;
+ using DotNetOpenAuth.Messaging.Reflection;
+ using DotNetOpenAuth.OpenId.Extensions.UI;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ [TestClass]
+ public class UIRequestTests : OpenIdTestBase {
+ [TestMethod]
+ public void Defaults() {
+ UIRequest request = new UIRequest();
+ Assert.AreEqual("popup", request.Mode);
+ Assert.AreEqual(CultureInfo.CurrentUICulture, request.LanguagePreference);
+ }
+
+ [TestMethod]
+ public void LanguagePreferenceEncoding() {
+ var request = new UIRequest();
+ request.LanguagePreference = new CultureInfo("en-US");
+ MessageDictionary dictionary = this.MessageDescriptions.GetAccessor(request);
+ Assert.AreEqual("en-US", dictionary["lang"]);
+ }
+
+ [TestMethod]
+ public void ModeEncoding() {
+ var request = new UIRequest();
+ MessageDictionary dictionary = this.MessageDescriptions.GetAccessor(request);
+ Assert.AreEqual("popup", dictionary["mode"]);
+ }
+ }
+}
diff --git a/src/DotNetOpenAuth.Test/OpenId/NonIdentityTests.cs b/src/DotNetOpenAuth.Test/OpenId/NonIdentityTests.cs
new file mode 100644
index 0000000..49bb32c
--- /dev/null
+++ b/src/DotNetOpenAuth.Test/OpenId/NonIdentityTests.cs
@@ -0,0 +1,57 @@
+//-----------------------------------------------------------------------
+// <copyright file="NonIdentityTests.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.Test.OpenId {
+ using DotNetOpenAuth.OpenId;
+ using DotNetOpenAuth.OpenId.Messages;
+ using DotNetOpenAuth.OpenId.Provider;
+ using DotNetOpenAuth.OpenId.RelyingParty;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ [TestClass]
+ public class NonIdentityTests : OpenIdTestBase {
+ [TestMethod]
+ public void ExtensionOnlyChannelLevel() {
+ Protocol protocol = Protocol.V20;
+ AuthenticationRequestMode mode = AuthenticationRequestMode.Setup;
+
+ var coordinator = new OpenIdCoordinator(
+ rp => {
+ var request = new SignedResponseRequest(protocol.Version, OPUri, mode);
+ rp.Channel.Send(request);
+ },
+ op => {
+ var request = op.Channel.ReadFromRequest<SignedResponseRequest>();
+ Assert.IsNotInstanceOfType(request, typeof(CheckIdRequest));
+ });
+ coordinator.Run();
+ }
+
+ [TestMethod]
+ public void ExtensionOnlyFacadeLevel() {
+ Protocol protocol = Protocol.V20;
+ var coordinator = new OpenIdCoordinator(
+ rp => {
+ var request = rp.CreateRequest(GetMockIdentifier(protocol.ProtocolVersion), RPRealmUri, RPUri);
+
+ request.IsExtensionOnly = true;
+ rp.Channel.Send(request.RedirectingResponse.OriginalMessage);
+ IAuthenticationResponse response = rp.GetResponse();
+ Assert.AreEqual(AuthenticationStatus.ExtensionsOnly, response.Status);
+ },
+ op => {
+ var assocRequest = op.GetRequest();
+ op.SendResponse(assocRequest);
+
+ var request = (IAnonymousRequest)op.GetRequest();
+ request.IsApproved = true;
+ Assert.IsNotInstanceOfType(request, typeof(CheckIdRequest));
+ op.SendResponse(request);
+ });
+ coordinator.Run();
+ }
+ }
+}
diff --git a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs
index dddae27..8fa5580 100644
--- a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs
@@ -109,13 +109,19 @@ namespace DotNetOpenAuth.Test.OpenId {
}
internal static ServiceEndpoint GetServiceEndpoint(int user, ProtocolVersion providerVersion, int servicePriority, bool useSsl) {
+ return GetServiceEndpoint(user, providerVersion, servicePriority, useSsl, false);
+ }
+
+ internal static ServiceEndpoint GetServiceEndpoint(int user, ProtocolVersion providerVersion, int servicePriority, bool useSsl, bool delegating) {
var providerEndpoint = new ProviderEndpointDescription(
useSsl ? OpenIdTestBase.OPUriSsl : OpenIdTestBase.OPUri,
new string[] { Protocol.Lookup(providerVersion).ClaimedIdentifierServiceTypeURI });
+ var local_id = useSsl ? OPLocalIdentifiersSsl[user] : OPLocalIdentifiers[user];
+ var claimed_id = delegating ? (useSsl ? VanityUriSsl : VanityUri) : local_id;
return ServiceEndpoint.CreateForClaimedIdentifier(
- useSsl ? OPLocalIdentifiersSsl[user] : OPLocalIdentifiers[user],
- useSsl ? OPLocalIdentifiersSsl[user] : OPLocalIdentifiers[user],
- useSsl ? OPLocalIdentifiersSsl[user] : OPLocalIdentifiers[user],
+ claimed_id,
+ claimed_id,
+ local_id,
providerEndpoint,
servicePriority,
10);
@@ -167,8 +173,12 @@ namespace DotNetOpenAuth.Test.OpenId {
}
protected Identifier GetMockIdentifier(ProtocolVersion providerVersion, bool useSsl) {
- ServiceEndpoint se = GetServiceEndpoint(0, providerVersion, 10, useSsl);
- UriIdentifier identityUri = useSsl ? OpenIdTestBase.OPLocalIdentifiersSsl[0] : OpenIdTestBase.OPLocalIdentifiers[0];
+ return this.GetMockIdentifier(providerVersion, useSsl, false);
+ }
+
+ protected Identifier GetMockIdentifier(ProtocolVersion providerVersion, bool useSsl, bool delegating) {
+ ServiceEndpoint se = GetServiceEndpoint(0, providerVersion, 10, useSsl, delegating);
+ UriIdentifier identityUri = (UriIdentifier)se.ClaimedIdentifier;
return new MockIdentifier(identityUri, this.MockResponder, new ServiceEndpoint[] { se });
}
diff --git a/src/DotNetOpenAuth.Test/OpenId/Provider/AnonymousRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/Provider/AnonymousRequestTests.cs
new file mode 100644
index 0000000..14fef91
--- /dev/null
+++ b/src/DotNetOpenAuth.Test/OpenId/Provider/AnonymousRequestTests.cs
@@ -0,0 +1,37 @@
+//-----------------------------------------------------------------------
+// <copyright file="AnonymousRequestTests.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.Test.OpenId.Provider {
+ using DotNetOpenAuth.OpenId;
+ using DotNetOpenAuth.OpenId.Messages;
+ using DotNetOpenAuth.OpenId.Provider;
+ using DotNetOpenAuth.OpenId.RelyingParty;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ [TestClass]
+ public class AnonymousRequestTests : OpenIdTestBase {
+ /// <summary>
+ /// Verifies that IsApproved controls which response message is returned.
+ /// </summary>
+ [TestMethod]
+ public void IsApprovedDeterminesReturnedMessage() {
+ var op = CreateProvider();
+ Protocol protocol = Protocol.V20;
+ var req = new SignedResponseRequest(protocol.Version, OPUri, AuthenticationRequestMode.Setup);
+ req.ReturnTo = RPUri;
+ var anonReq = new AnonymousRequest(op, req);
+
+ Assert.IsFalse(anonReq.IsApproved.HasValue);
+
+ anonReq.IsApproved = false;
+ Assert.IsInstanceOfType(anonReq.Response, typeof(NegativeAssertionResponse));
+
+ anonReq.IsApproved = true;
+ Assert.IsInstanceOfType(anonReq.Response, typeof(IndirectSignedResponse));
+ Assert.IsNotInstanceOfType(anonReq.Response, typeof(PositiveAssertionResponse));
+ }
+ }
+}
diff --git a/src/DotNetOpenAuth.Test/OpenId/Provider/AuthenticationRequestTest.cs b/src/DotNetOpenAuth.Test/OpenId/Provider/AuthenticationRequestTest.cs
index cb898be..e2a173b 100644
--- a/src/DotNetOpenAuth.Test/OpenId/Provider/AuthenticationRequestTest.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/Provider/AuthenticationRequestTest.cs
@@ -45,20 +45,5 @@ namespace DotNetOpenAuth.Test.OpenId.Provider {
Assert.AreEqual(immediateRequest.LocalIdentifier, setupRequestMessage.LocalIdentifier);
Assert.AreEqual(immediateRequest.Version, setupRequestMessage.Version);
}
-
- [TestMethod]
- public void IsReturnUrlDiscoverable() {
- Protocol protocol = Protocol.Default;
- OpenIdProvider provider = this.CreateProvider();
- CheckIdRequest checkIdRequest = new CheckIdRequest(protocol.Version, OPUri, DotNetOpenAuth.OpenId.RelyingParty.AuthenticationRequestMode.Setup);
- checkIdRequest.Realm = RPRealmUri;
- checkIdRequest.ReturnTo = RPUri;
- AuthenticationRequest request = new AuthenticationRequest(provider, checkIdRequest);
- Assert.IsFalse(request.IsReturnUrlDiscoverable(this.MockResponder.MockWebRequestHandler));
-
- this.MockResponder.RegisterMockRPDiscovery();
- request = new AuthenticationRequest(provider, checkIdRequest);
- Assert.IsTrue(request.IsReturnUrlDiscoverable(this.MockResponder.MockWebRequestHandler));
- }
}
}
diff --git a/src/DotNetOpenAuth.Test/OpenId/Provider/HostProcessedRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/Provider/HostProcessedRequestTests.cs
new file mode 100644
index 0000000..d308271
--- /dev/null
+++ b/src/DotNetOpenAuth.Test/OpenId/Provider/HostProcessedRequestTests.cs
@@ -0,0 +1,85 @@
+//-----------------------------------------------------------------------
+// <copyright file="HostProcessedRequestTests.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.Test.OpenId.Provider {
+ using System;
+ using DotNetOpenAuth.OpenId;
+ using DotNetOpenAuth.OpenId.Messages;
+ using DotNetOpenAuth.OpenId.Provider;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ [TestClass]
+ public class HostProcessedRequestTests : OpenIdTestBase {
+ private Protocol protocol;
+ private OpenIdProvider provider;
+ private CheckIdRequest checkIdRequest;
+ private AuthenticationRequest request;
+
+ [TestInitialize]
+ public override void SetUp() {
+ base.SetUp();
+
+ this.protocol = Protocol.Default;
+ this.provider = this.CreateProvider();
+ this.checkIdRequest = new CheckIdRequest(this.protocol.Version, OPUri, DotNetOpenAuth.OpenId.RelyingParty.AuthenticationRequestMode.Setup);
+ this.checkIdRequest.Realm = RPRealmUri;
+ this.checkIdRequest.ReturnTo = RPUri;
+ this.request = new AuthenticationRequest(this.provider, this.checkIdRequest);
+ }
+
+ [TestMethod]
+ public void IsReturnUrlDiscoverableNoResponse() {
+ Assert.AreEqual(RelyingPartyDiscoveryResult.NoServiceDocument, this.request.IsReturnUrlDiscoverable(this.provider));
+ }
+
+ [TestMethod]
+ public void IsReturnUrlDiscoverableValidResponse() {
+ this.MockResponder.RegisterMockRPDiscovery();
+ this.request = new AuthenticationRequest(this.provider, this.checkIdRequest);
+ Assert.AreEqual(RelyingPartyDiscoveryResult.Success, this.request.IsReturnUrlDiscoverable(this.provider));
+ }
+
+ /// <summary>
+ /// Verifies that when discovery would be performed over standard HTTP and RequireSsl
+ /// is set, that discovery fails.
+ /// </summary>
+ [TestMethod]
+ public void IsReturnUrlDiscoverableNotSsl() {
+ this.provider.SecuritySettings.RequireSsl = true;
+ this.MockResponder.RegisterMockRPDiscovery();
+ Assert.AreEqual(RelyingPartyDiscoveryResult.NoServiceDocument, this.request.IsReturnUrlDiscoverable(this.provider));
+ }
+
+ /// <summary>
+ /// Verifies that when discovery would be performed over HTTPS that discovery succeeds.
+ /// </summary>
+ [TestMethod]
+ public void IsReturnUrlDiscoverableRequireSsl() {
+ this.MockResponder.RegisterMockRPDiscovery();
+ this.checkIdRequest.Realm = RPRealmUriSsl;
+ this.checkIdRequest.ReturnTo = RPUriSsl;
+
+ // Try once with RequireSsl
+ this.provider.SecuritySettings.RequireSsl = true;
+ this.request = new AuthenticationRequest(this.provider, this.checkIdRequest);
+ Assert.AreEqual(RelyingPartyDiscoveryResult.Success, this.request.IsReturnUrlDiscoverable(this.provider));
+
+ // And again without RequireSsl
+ this.provider.SecuritySettings.RequireSsl = false;
+ this.request = new AuthenticationRequest(this.provider, this.checkIdRequest);
+ Assert.AreEqual(RelyingPartyDiscoveryResult.Success, this.request.IsReturnUrlDiscoverable(this.provider));
+ }
+
+ [TestMethod]
+ public void IsReturnUrlDiscoverableValidButNoMatch() {
+ this.MockResponder.RegisterMockRPDiscovery();
+ this.provider.SecuritySettings.RequireSsl = false; // reset for another failure test case
+ this.checkIdRequest.ReturnTo = new Uri("http://somerandom/host");
+ this.request = new AuthenticationRequest(this.provider, this.checkIdRequest);
+ Assert.AreEqual(RelyingPartyDiscoveryResult.NoMatchingReturnTo, this.request.IsReturnUrlDiscoverable(this.provider));
+ }
+ }
+}
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..6452420
--- /dev/null
+++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAnonymousResponseTests.cs
@@ -0,0 +1,42 @@
+//-----------------------------------------------------------------------
+// <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.AreSame(ext, response.GetUntrustedExtension<ClaimsResponse>());
+ }
+ }
+}
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/RelyingPartySecuritySettingsTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/RelyingPartySecuritySettingsTests.cs
index cb5fbb5..3f1cea0 100644
--- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/RelyingPartySecuritySettingsTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/RelyingPartySecuritySettingsTests.cs
@@ -23,35 +23,22 @@ 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;
Assert.IsFalse(this.settings.RequireSsl);
}
-
- /// <summary>
- /// Verifies that changing the <see cref="RelyingPartySecuritySettings.RequireSsl"/> property
- /// fires the <see cref="RelyingPartySecuritySettings.RequireSslChanged"/> event.
- /// </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);
-
- // Changing the property's value should fire the event.
- this.settings.RequireSsl = !this.settings.RequireSsl;
- Assert.IsTrue(requireSslChanged);
- }
}
}