diff options
Diffstat (limited to 'src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionTestUtilities.cs')
-rw-r--r-- | src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionTestUtilities.cs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionTestUtilities.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionTestUtilities.cs index 334fc93..4a78fc1 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionTestUtilities.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionTestUtilities.cs @@ -10,6 +10,7 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { using System.Diagnostics.Contracts; using System.Linq; using DotNetOpenAuth.Messaging; + using DotNetOpenAuth.Messaging.Bindings; using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.ChannelElements; using DotNetOpenAuth.OpenId.Extensions; @@ -33,8 +34,10 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { Protocol protocol, IEnumerable<IOpenIdMessageExtension> requests, IEnumerable<IOpenIdMessageExtension> responses) { - ProviderSecuritySettings securitySettings = new ProviderSecuritySettings(); - Association association = HmacShaAssociation.Create(protocol, protocol.Args.SignatureAlgorithm.Best, AssociationRelyingPartyType.Smart, securitySettings); + var securitySettings = new ProviderSecuritySettings(); + var cryptoKeyStore = new MemoryCryptoKeyStore(); + var associationStore = new ProviderAssociationHandleEncoder(cryptoKeyStore); + Association association = HmacShaAssociationProvider.Create(protocol, protocol.Args.SignatureAlgorithm.Best, AssociationRelyingPartyType.Smart, associationStore, securitySettings); var coordinator = new OpenIdCoordinator( rp => { RegisterExtension(rp.Channel, Mocks.MockOpenIdExtension.Factory); @@ -49,7 +52,7 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { requestBase.Extensions.Add(extension); } - rp.Channel.Send(requestBase); + rp.Channel.Respond(requestBase); var response = rp.Channel.ReadFromRequest<PositiveAssertionResponse>(); var receivedResponses = response.Extensions.Cast<IOpenIdMessageExtension>(); @@ -57,7 +60,8 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { }, op => { RegisterExtension(op.Channel, Mocks.MockOpenIdExtension.Factory); - op.AssociationStore.StoreAssociation(AssociationRelyingPartyType.Smart, association); + var key = cryptoKeyStore.GetCurrentKey(ProviderAssociationHandleEncoder.AssociationHandleEncodingSecretBucket, TimeSpan.FromSeconds(1)); + op.CryptoKeyStore.StoreKey(ProviderAssociationHandleEncoder.AssociationHandleEncodingSecretBucket, key.Key, key.Value); var request = op.Channel.ReadFromRequest<CheckIdRequest>(); var response = new PositiveAssertionResponse(request); var receivedRequests = request.Extensions.Cast<IOpenIdMessageExtension>(); @@ -67,13 +71,13 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { response.Extensions.Add(extensionResponse); } - op.Channel.Send(response); + op.Channel.Respond(response); }); coordinator.Run(); } internal static void RegisterExtension(Channel channel, StandardOpenIdExtensionFactory.CreateDelegate extensionFactory) { - Contract.Requires<ArgumentNullException>(channel != null); + Requires.NotNull(channel, "channel"); var factory = (OpenIdExtensionFactoryAggregator)channel.BindingElements.OfType<ExtensionsBindingElement>().Single().ExtensionFactory; factory.Factories.OfType<StandardOpenIdExtensionFactory>().Single().RegisterExtension(extensionFactory); |