From 9517dbc98a051414eab02c76ac6cedb4e4bbb80d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 3 Jan 2009 19:06:47 -0800 Subject: [PATCH] TEMP --- .../OpenId/AssociationHandshakeTests.cs | 6 ++- .../RelyingParty/AuthenticationRequestTests.cs | 2 +- src/DotNetOpenAuth/OpenId/Provider/IRequest.cs | 10 ++--- .../OpenId/Provider/OpenIdProvider.cs | 19 --------- src/DotNetOpenAuth/OpenId/Provider/Request.cs | 48 +++++++++++----------- 5 files changed, 34 insertions(+), 51 deletions(-) diff --git a/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs b/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs index 478c5b4..ab9b855 100644 --- a/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs @@ -10,6 +10,7 @@ namespace DotNetOpenAuth.Test.OpenId { using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.Messages; using Microsoft.VisualStudio.TestTools.UnitTesting; + using DotNetOpenAuth.OpenId.Provider; [TestClass] public class AssociationHandshakeTests : OpenIdTestBase { @@ -141,7 +142,10 @@ namespace DotNetOpenAuth.Test.OpenId { }, op => { op.SecuritySettings = this.ProviderSecuritySettings; - op.AutoRespond(); + IRequest req = op.GetRequest(); + Assert.IsTrue(req.IsResponseReady); + UserAgentResponse resp = req.GetResponse(); + //resp.Send(); // coordinating channel does not require this. }); coordinator.IncomingMessageFilter = message => { Assert.AreSame(opDescription.ProtocolVersion, message.Version, "The message was recognized as version {0} but was expected to be {1}.", message.Version, opDescription.ProtocolVersion); diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs index 234b567..dca09c5 100644 --- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs @@ -33,7 +33,7 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { rp => { }, op => { - op.AutoRespond(); // association + op.GetRequest().GetResponse().Send(); // association }); var rp2 = this.CreateRelyingParty(); Identifier id = this.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20); diff --git a/src/DotNetOpenAuth/OpenId/Provider/IRequest.cs b/src/DotNetOpenAuth/OpenId/Provider/IRequest.cs index ee281bf..24d1ae8 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/IRequest.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/IRequest.cs @@ -31,11 +31,6 @@ namespace DotNetOpenAuth.OpenId.Provider { bool IsResponseReady { get; } /// - /// Gets the response to send to the user agent. - /// - UserAgentResponse Response { get; } - - /// /// Adds an extension to the response to send to the relying party. /// void AddResponseExtension(IOpenIdMessageExtension extension); @@ -54,5 +49,10 @@ namespace DotNetOpenAuth.OpenId.Provider { /// The type of the extension. /// An instance of the extension initialized with values passed in with the request. IOpenIdMessageExtension GetExtension(Type extensionType); + + /// + /// Gets the response to send to the user agent. + /// + UserAgentResponse GetResponse(); } } diff --git a/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs b/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs index 72f9482..866aca6 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs @@ -119,24 +119,5 @@ namespace DotNetOpenAuth.OpenId.Provider { throw ErrorUtilities.ThrowProtocol(MessagingStrings.UnexpectedMessageReceivedOfMany); } - - /// - /// Responds automatically to the incoming message. - /// - /// - /// The design of a method like this is flawed... but it helps us get tests going for now. - /// - internal void AutoRespond() { - var request = this.Channel.ReadFromRequest(); - - var associateRequest = request as AssociateRequest; - if (associateRequest != null) { - IProtocolMessage response = associateRequest.CreateResponse(this.AssociationStore); - this.Channel.Send(response).Send(); - } else { - // TODO: code here - throw new NotImplementedException(); - } - } } } diff --git a/src/DotNetOpenAuth/OpenId/Provider/Request.cs b/src/DotNetOpenAuth/OpenId/Provider/Request.cs index 528cc2b..0962e84 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/Request.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/Request.cs @@ -32,31 +32,6 @@ namespace DotNetOpenAuth.OpenId.Provider { public abstract bool IsResponseReady { get; } - public UserAgentResponse Response { - get { - if (this.cachedUserAgentResponse == null && this.IsResponseReady) { - if (this.extensions.Count > 0) { - var extensibleResponse = this.ResponseMessage as IProtocolMessageWithExtensions; - ErrorUtilities.VerifyOperation(extensibleResponse != null, MessagingStrings.MessageNotExtensible, this.ResponseMessage.GetType().Name); - foreach (var extension in this.extensions) { - // It's possible that a prior call to this property - // has already added some/all of the extensions to the message. - // We don't have to worry about deleting old ones because - // this class provides no facility for removing extensions - // that are previously added. - if (!extensibleResponse.Extensions.Contains(extension)) { - extensibleResponse.Extensions.Add(extension); - } - } - } - - this.cachedUserAgentResponse = this.provider.Channel.Send(this.ResponseMessage); - } - - return this.cachedUserAgentResponse; - } - } - #endregion protected OpenIdProvider Provider { @@ -104,6 +79,29 @@ namespace DotNetOpenAuth.OpenId.Provider { } } + public UserAgentResponse GetResponse() { + if (this.cachedUserAgentResponse == null && this.IsResponseReady) { + if (this.extensions.Count > 0) { + var extensibleResponse = this.ResponseMessage as IProtocolMessageWithExtensions; + ErrorUtilities.VerifyOperation(extensibleResponse != null, MessagingStrings.MessageNotExtensible, this.ResponseMessage.GetType().Name); + foreach (var extension in this.extensions) { + // It's possible that a prior call to this property + // has already added some/all of the extensions to the message. + // We don't have to worry about deleting old ones because + // this class provides no facility for removing extensions + // that are previously added. + if (!extensibleResponse.Extensions.Contains(extension)) { + extensibleResponse.Extensions.Add(extension); + } + } + } + + this.cachedUserAgentResponse = this.provider.Channel.Send(this.ResponseMessage); + } + + return this.cachedUserAgentResponse; + } + #endregion /// -- 2.11.4.GIT