diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-12-01 20:45:37 -0800 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-12-01 20:45:37 -0800 |
commit | fac327d8047e62bd265997cf05ff45ac062a4ff3 (patch) | |
tree | d424be3e1ac4659472c256aaf5b76e847cd4cc52 /src | |
parent | 797d58e5b6336e243c80c7d5e31929c7faf50620 (diff) | |
download | DotNetOpenAuth-fac327d8047e62bd265997cf05ff45ac062a4ff3.zip DotNetOpenAuth-fac327d8047e62bd265997cf05ff45ac062a4ff3.tar.gz DotNetOpenAuth-fac327d8047e62bd265997cf05ff45ac062a4ff3.tar.bz2 |
Added a few tests.
Diffstat (limited to 'src')
6 files changed, 100 insertions, 5 deletions
diff --git a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj index a0f6549..0ea0f5e 100644 --- a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj +++ b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj @@ -115,6 +115,8 @@ <Compile Include="OpenId\AssociationHandshakeTests.cs" /> <Compile Include="OpenId\OpenIdTestBase.cs" /> <Compile Include="OpenId\RealmTests.cs" /> + <Compile Include="OpenId\RelyingParty\OpenIdRelyingPartyTests.cs" /> + <Compile Include="OpenId\RelyingParty\RelyingPartySecuritySettingsTests.cs" /> <Compile Include="OpenId\TestSupport.cs" /> <Compile Include="OpenId\UI\UITestSupport.cs" /> <Compile Include="OpenId\UriIdentifierTests.cs" /> diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/OpenIdRelyingPartyTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/OpenIdRelyingPartyTests.cs new file mode 100644 index 0000000..6236044 --- /dev/null +++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/OpenIdRelyingPartyTests.cs @@ -0,0 +1,34 @@ +//----------------------------------------------------------------------- +// <copyright file="OpenIdRelyingPartyTests.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth.Test.OpenId.RelyingParty { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using DotNetOpenAuth.OpenId; + using DotNetOpenAuth.OpenId.RelyingParty; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class OpenIdRelyingPartyTests : OpenIdTestBase { + [TestInitialize] + public override void SetUp() { + base.SetUp(); + } + + [TestMethod, Ignore] // ignored, pending work to make dumb mode a supported scenario. + public void CtorNullAssociationStore() { + new OpenIdRelyingParty(null); + } + + [TestMethod, ExpectedException(typeof(ArgumentNullException))] + public void SecuritySettingsSetNull() { + var rp = new OpenIdRelyingParty(new AssociationMemoryStore<Uri>()); + rp.SecuritySettings = null; + } + } +} diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/RelyingPartySecuritySettingsTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/RelyingPartySecuritySettingsTests.cs new file mode 100644 index 0000000..cb5fbb5 --- /dev/null +++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/RelyingPartySecuritySettingsTests.cs @@ -0,0 +1,57 @@ +//----------------------------------------------------------------------- +// <copyright file="RelyingPartySecuritySettingsTests.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth.Test.OpenId.RelyingParty { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using DotNetOpenAuth.OpenId.RelyingParty; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class RelyingPartySecuritySettingsTests : OpenIdTestBase { + private RelyingPartySecuritySettings settings; + + [TestInitialize] + public override void SetUp() { + base.SetUp(); + + this.settings = new RelyingPartySecuritySettings(); + } + + /// <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); + } + } +} diff --git a/src/DotNetOpenAuth.Test/OpenId/TestSupport.cs b/src/DotNetOpenAuth.Test/OpenId/TestSupport.cs index c80fa97..bad34ee 100644 --- a/src/DotNetOpenAuth.Test/OpenId/TestSupport.cs +++ b/src/DotNetOpenAuth.Test/OpenId/TestSupport.cs @@ -156,11 +156,12 @@ namespace DotNetOpenAuth.Test.OpenId { ////internal static UriIdentifier GetDirectedIdentityUrl(Scenarios scenario, ProtocolVersion providerVersion) { //// return GetDirectedIdentityUrl(scenario, providerVersion, false); ////} + ////internal static UriIdentifier GetDirectedIdentityUrl(Scenarios scenario, ProtocolVersion providerVersion, bool useSsl) { - //// return new UriIdentifier(GetFullUrl("/" + directedIdentityPage, new Dictionary<string, string> { - //// { "user", scenario.ToString() }, - //// { "version", providerVersion.ToString() }, - ////}, useSsl)); + //// return new UriIdentifier(GetFullUrl("/" + DirectedIdentityPage, new Dictionary<string, string> { + //// { "user", scenario.ToString() }, + //// { "version", providerVersion.ToString() }, + //// }, useSsl)); ////} ////internal static IRelyingPartyApplicationStore RelyingPartyStore; diff --git a/src/DotNetOpenAuth.Test/OpenId/XriIdentifierTests.cs b/src/DotNetOpenAuth.Test/OpenId/XriIdentifierTests.cs index d84b8b1..87ecd4b 100644 --- a/src/DotNetOpenAuth.Test/OpenId/XriIdentifierTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/XriIdentifierTests.cs @@ -452,7 +452,7 @@ uEyb50RJ7DWmXctSC0b3eymZ2lSXxAWNOsNy this.VerifyCanonicalId("@id*andrewarnott", null); } - ////[TestMethod, Ignore("XRI parsing and normalization is not implemented (yet).")] + [TestMethod, Ignore] // XRI parsing and normalization is not implemented (yet). public void NormalizeCase() { Identifier id = "=!9B72.7dd1.50a9.5ccd"; Assert.AreEqual("=!9B72.7DD1.50A9.5CCD", id.ToString()); diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs index cf3597c..e9d96a6 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs @@ -30,6 +30,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// </summary> /// <param name="associationStore">The association store. If null, the relying party will always operate in "dumb mode".</param> public OpenIdRelyingParty(IAssociationStore<Uri> associationStore) { + // TODO: fix this so that a null association store is supported as 'dumb mode only'. ErrorUtilities.VerifyArgumentNotNull(associationStore, "associationStore"); this.Channel = new OpenIdChannel(); |