diff options
Diffstat (limited to 'src/DotNetOpenAuth.Test')
-rw-r--r-- | src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj | 2 | ||||
-rw-r--r-- | src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs | 38 | ||||
-rw-r--r-- | src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs | 24 |
3 files changed, 54 insertions, 10 deletions
diff --git a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj index 0e460bd..d16b6c4 100644 --- a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj +++ b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj @@ -41,6 +41,7 @@ </Reference> <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> <Reference Include="System" /> + <Reference Include="System.configuration" /> <Reference Include="System.Core"> <RequiredTargetFramework>3.5</RequiredTargetFramework> </Reference> @@ -105,6 +106,7 @@ <Compile Include="OpenId\Messages\IndirectErrorResponseTests.cs" /> <Compile Include="OpenId\OpenIdCoordinator.cs" /> <Compile Include="OpenId\AssociationHandshakeTests.cs" /> + <Compile Include="OpenId\OpenIdTestBase.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Messaging\ResponseTests.cs" /> <Compile Include="OAuth\AppendixScenarios.cs" /> diff --git a/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs b/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs index 103a252..e411ecb 100644 --- a/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs @@ -6,26 +6,43 @@ namespace DotNetOpenAuth.Test.OpenId { using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.Messages; using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] - public class AssociationHandshakeTests { + public class AssociationHandshakeTests : OpenIdTestBase { [TestMethod] - public void AssociateDiffieHellmanMessages() { + public void DHv2() { var opDescription = new ProviderEndpointDescription(new Uri("http://host"), Protocol.V20); - ParameterizedAssociationTest(opDescription, true, Protocol.V20.Args.SignatureAlgorithm.HMAC_SHA1); + this.ParameterizedAssociationTest( + opDescription, + Protocol.V20.Args.SignatureAlgorithm.HMAC_SHA256); } [TestMethod] - public void AssociateUnencryptedMessages() { + public void DHv1() { + var opDescription = new ProviderEndpointDescription(new Uri("http://host"), Protocol.V10); + this.ParameterizedAssociationTest( + opDescription, + Protocol.V20.Args.SignatureAlgorithm.HMAC_SHA1); + } + + [TestMethod] + public void PTv2() { var opDescription = new ProviderEndpointDescription(new Uri("https://host"), Protocol.V20); - ParameterizedAssociationTest(opDescription, false, Protocol.V20.Args.SignatureAlgorithm.HMAC_SHA1); + this.ParameterizedAssociationTest( + opDescription, + Protocol.V20.Args.SignatureAlgorithm.HMAC_SHA256); + } + + [TestMethod] + public void PTv1() { + var opDescription = new ProviderEndpointDescription(new Uri("https://host"), Protocol.V11); + this.ParameterizedAssociationTest( + opDescription, + Protocol.V20.Args.SignatureAlgorithm.HMAC_SHA1); } /// <summary> @@ -35,24 +52,25 @@ namespace DotNetOpenAuth.Test.OpenId { /// The description of the Provider that the relying party uses to formulate the request. /// The specific host is not used, but the scheme is significant. /// </param> - /// <param name="expectDiffieHellman">True if a DH session is expected to be used.</param> /// <param name="expectedAssociationType"> /// The value of the openid.assoc_type parameter expected, /// or null if a failure is anticipated. /// </param> private void ParameterizedAssociationTest( ProviderEndpointDescription opDescription, - bool expectDiffieHellman, string expectedAssociationType) { bool expectSuccess = expectedAssociationType != null; + bool expectDiffieHellman = !opDescription.Endpoint.IsTransportSecure(); Association rpAssociation = null, opAssociation; AssociateSuccessfulResponse associateSuccessfulResponse = null; AssociateUnsuccessfulResponse associateUnsuccessfulResponse = null; OpenIdCoordinator coordinator = new OpenIdCoordinator( rp => { + rp.SecuritySettings = this.RelyingPartySecuritySettings; rpAssociation = rp.GetAssociation(opDescription); }, op => { + op.SecuritySettings = this.ProviderSecuritySettings; op.AutoRespond(); }); coordinator.IncomingMessageFilter = (message) => { diff --git a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs new file mode 100644 index 0000000..4b52634 --- /dev/null +++ b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs @@ -0,0 +1,24 @@ +//----------------------------------------------------------------------- +// <copyright file="OpenIdTestBase.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth.Test.OpenId { + using DotNetOpenAuth.Configuration; + using DotNetOpenAuth.OpenId.Provider; + using DotNetOpenAuth.OpenId.RelyingParty; + + public class OpenIdTestBase : TestBase { + protected RelyingPartySecuritySettings RelyingPartySecuritySettings { get; private set; } + + protected ProviderSecuritySettings ProviderSecuritySettings { get; private set; } + + public override void SetUp() { + base.SetUp(); + + RelyingPartySecuritySettings = RelyingPartySection.Configuration.SecuritySettings.CreateSecuritySettings(); + ProviderSecuritySettings = ProviderSection.Configuration.SecuritySettings.CreateSecuritySettings(); + } + } +} |