diff options
Diffstat (limited to 'src')
11 files changed, 216 insertions, 183 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/Channel.cs b/src/DotNetOpenAuth.Core/Messaging/Channel.cs index 62de162..b087538 100644 --- a/src/DotNetOpenAuth.Core/Messaging/Channel.cs +++ b/src/DotNetOpenAuth.Core/Messaging/Channel.cs @@ -669,6 +669,10 @@ namespace DotNetOpenAuth.Messaging { Requires.NotNull(request, "request"); Requires.That(request.Recipient != null, "request", MessagingStrings.DirectedMessageMissingRecipient); + if (this.OutgoingMessageFilter != null) { + this.OutgoingMessageFilter(request); + } + var webRequest = this.CreateHttpRequest(request); var directRequest = request as IHttpDirectRequest; if (directRequest != null) { @@ -975,6 +979,10 @@ namespace DotNetOpenAuth.Messaging { return dictionary; } + internal Action<IProtocolMessage> OutgoingMessageFilter { get; set; } + + internal Action<IProtocolMessage> IncomingMessageFilter { get; set; } + /// <summary> /// Prepares a message for transmit by applying signatures, nonces, etc. /// </summary> @@ -1024,6 +1032,10 @@ namespace DotNetOpenAuth.Messaging { this.EnsureValidMessageParts(message); message.EnsureValidMessage(); + if (this.OutgoingMessageFilter != null) { + this.OutgoingMessageFilter(message); + } + if (Logger.Channel.IsInfoEnabled) { var directedMessage = message as IDirectedProtocolMessage; string recipient = (directedMessage != null && directedMessage.Recipient != null) ? directedMessage.Recipient.AbsoluteUri : "<response>"; @@ -1223,6 +1235,10 @@ namespace DotNetOpenAuth.Messaging { // message deserializer did for us. It would be too late to do it here since // they might look initialized by the time we have an IProtocolMessage instance. message.EnsureValidMessage(); + + if (this.IncomingMessageFilter != null) { + this.IncomingMessageFilter(message); + } } /// <summary> diff --git a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs index 4b976af..df11a16 100644 --- a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs +++ b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs @@ -699,28 +699,6 @@ namespace DotNetOpenAuth.Messaging { } /// <summary> - /// Adds a Set-Cookie HTTP header for the specified cookie. - /// WARNING: support for cookie properties is currently VERY LIMITED. - /// </summary> - /// <param name="headers">The headers.</param> - /// <param name="cookie">The cookie.</param> - internal static void SetCookie(this HttpResponseHeaders headers, Cookie cookie) { - Requires.NotNull(headers, "headers"); - Requires.NotNull(cookie, "cookie"); - - var cookieBuilder = new StringBuilder(HttpUtility.UrlEncode(cookie.Name) + "=" + HttpUtility.UrlEncode(cookie.Value)); - if (cookie.HttpOnly) { - cookieBuilder.Append("; HttpOnly"); - } - - if (cookie.Secure) { - cookieBuilder.Append("; Secure"); - } - - headers.Add("Set-Cookie", cookieBuilder.ToString()); - } - - /// <summary> /// Gets a random string made up of a given set of allowable characters. /// </summary> /// <param name="length">The length of the desired random string.</param> diff --git a/src/DotNetOpenAuth.OAuth2.Client/DotNetOpenAuth.OAuth2.Client.csproj b/src/DotNetOpenAuth.OAuth2.Client/DotNetOpenAuth.OAuth2.Client.csproj index dedeac7..f20f681 100644 --- a/src/DotNetOpenAuth.OAuth2.Client/DotNetOpenAuth.OAuth2.Client.csproj +++ b/src/DotNetOpenAuth.OAuth2.Client/DotNetOpenAuth.OAuth2.Client.csproj @@ -64,6 +64,7 @@ </ItemGroup> <ItemGroup> <Reference Include="System.Net.Http" /> + <Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> <Reference Include="System.Net.Http.WebRequest" /> <Reference Include="Validation, Version=2.0.0.0, Culture=neutral, PublicKeyToken=2fc06f0d701809a7, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> diff --git a/src/DotNetOpenAuth.OAuth2.Client/OAuth2/WebServerClient.cs b/src/DotNetOpenAuth.OAuth2.Client/OAuth2/WebServerClient.cs index 4e9011a..5560fd5 100644 --- a/src/DotNetOpenAuth.OAuth2.Client/OAuth2/WebServerClient.cs +++ b/src/DotNetOpenAuth.OAuth2.Client/OAuth2/WebServerClient.cs @@ -11,6 +11,7 @@ namespace DotNetOpenAuth.OAuth2 { using System.Linq; using System.Net; using System.Net.Http; + using System.Net.Http.Headers; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -104,23 +105,18 @@ namespace DotNetOpenAuth.OAuth2 { // Mitigate XSRF attacks by including a state value that would be unpredictable between users, but // verifiable for the same user/session. // If the host is implementing the authorization tracker though, they're handling this protection themselves. - Cookie cookie = null; + var cookies = new List<CookieHeaderValue>(); if (this.AuthorizationTracker == null) { - var context = this.Channel.GetHttpContext(); - string xsrfKey = MessagingUtilities.GetNonCryptoRandomDataAsBase64(16); - cookie = new Cookie(XsrfCookieName, xsrfKey) { + cookies.Add(new CookieHeaderValue(XsrfCookieName, xsrfKey) { HttpOnly = true, Secure = FormsAuthentication.RequireSSL, - ////Expires = DateTime.Now.Add(OAuth2ClientSection.Configuration.MaxAuthorizationTime), // we prefer session cookies to persistent ones - }; + }); request.ClientState = xsrfKey; } var response = await this.Channel.PrepareResponseAsync(request, cancellationToken); - if (cookie != null) { - response.Headers.SetCookie(cookie); - } + response.Headers.AddCookies(cookies); return response; } @@ -156,8 +152,11 @@ namespace DotNetOpenAuth.OAuth2 { authorizationState = this.AuthorizationTracker.GetAuthorizationState(callback, response.ClientState); ErrorUtilities.VerifyProtocol(authorizationState != null, ClientStrings.AuthorizationResponseUnexpectedMismatch); } else { - HttpCookie cookie = request.Headers.Cookies[XsrfCookieName]; - ErrorUtilities.VerifyProtocol(cookie != null && string.Equals(response.ClientState, cookie.Value, StringComparison.Ordinal), ClientStrings.AuthorizationResponseUnexpectedMismatch); + var xsrfCookieValue = (from cookieHeader in request.Headers.GetCookies() + from cookie in cookieHeader.Cookies + where cookie.Name == XsrfCookieName + select cookie.Value).FirstOrDefault(); + ErrorUtilities.VerifyProtocol(xsrfCookieValue != null && string.Equals(response.ClientState, xsrfCookieValue, StringComparison.Ordinal), ClientStrings.AuthorizationResponseUnexpectedMismatch); authorizationState = new AuthorizationState { Callback = callback }; } var success = response as EndUserAuthorizationSuccessAuthCodeResponse; diff --git a/src/DotNetOpenAuth.Test/CoordinatorBase.cs b/src/DotNetOpenAuth.Test/CoordinatorBase.cs index be56de6..c041ac1 100644 --- a/src/DotNetOpenAuth.Test/CoordinatorBase.cs +++ b/src/DotNetOpenAuth.Test/CoordinatorBase.cs @@ -26,25 +26,23 @@ namespace DotNetOpenAuth.Test { internal class CoordinatorBase { private Func<IHostFactories, CancellationToken, Task> driver; - private Handler[] handlers; - internal CoordinatorBase(Func<IHostFactories, CancellationToken, Task> driver, params Handler[] handlers) { Requires.NotNull(driver, "driver"); Requires.NotNull(handlers, "handlers"); this.driver = driver; - this.handlers = handlers; + this.HostFactories = new MockingHostFactories(handlers.ToList()); } + internal MockingHostFactories HostFactories { get; set; } + internal static Task RunAsync(Func<IHostFactories, CancellationToken, Task> driver, params Handler[] handlers) { var coordinator = new CoordinatorBase(driver, handlers); return coordinator.RunAsync(); } protected internal virtual async Task RunAsync(CancellationToken cancellationToken = default(CancellationToken)) { - IHostFactories hostFactories = new MockingHostFactories(this.handlers); - - await this.driver(hostFactories, cancellationToken); + await this.driver(this.HostFactories, cancellationToken); } internal static Handler Handle(Uri uri) { diff --git a/src/DotNetOpenAuth.Test/Mocks/MockHttpRequest.cs b/src/DotNetOpenAuth.Test/Mocks/MockHttpRequest.cs index 1979cf4..2c1e64b 100644 --- a/src/DotNetOpenAuth.Test/Mocks/MockHttpRequest.cs +++ b/src/DotNetOpenAuth.Test/Mocks/MockHttpRequest.cs @@ -125,5 +125,33 @@ namespace DotNetOpenAuth.Test.Mocks { return results.ToArray(); } + + internal static CoordinatorBase.Handler RegisterMockResponse(Uri url, string contentType, string content) { + return CoordinatorBase.Handle(url).By(content, contentType); + } + + internal static CoordinatorBase.Handler RegisterMockResponse(Uri requestUri, Uri responseUri, string contentType, string content) { + return RegisterMockResponse(requestUri, responseUri, contentType, null, content); + } + + internal static CoordinatorBase.Handler RegisterMockResponse(Uri requestUri, Uri responseUri, string contentType, WebHeaderCollection headers, string content) { + return CoordinatorBase.Handle(requestUri).By(req => { + var response = new HttpResponseMessage(); + response.CopyHeadersFrom(headers); + response.Content = new StringContent(content, Encoding.Default, contentType); + return response; + }); + } + + private static void CopyHeadersFrom(this HttpResponseMessage message, WebHeaderCollection headers) { + if (headers != null) { + foreach (string headerName in headers) { + string[] headerValues = headers.GetValues(headerName); + if (!message.Headers.TryAddWithoutValidation(headerName, headerValues)) { + message.Content.Headers.TryAddWithoutValidation(headerName, headerValues); + } + } + } + } } } diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs index 7e29940..d2059d9 100644 --- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs @@ -27,7 +27,6 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { [TestFixture] public class OAuthChannelTests : TestBase { private OAuthChannel channel; - private TestWebRequestHandler webRequestHandler; private SigningBindingElementBase signingElement; private INonceStore nonceStore; private DotNetOpenAuth.OAuth.ServiceProviderSecuritySettings serviceProviderSecuritySettings = DotNetOpenAuth.Configuration.OAuthElement.Configuration.ServiceProvider.SecuritySettings.CreateSecuritySettings(); @@ -36,11 +35,9 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { public override void SetUp() { base.SetUp(); - this.webRequestHandler = new TestWebRequestHandler(); this.signingElement = new RsaSha1ServiceProviderSigningBindingElement(new InMemoryTokenManager()); this.nonceStore = new NonceMemoryStore(StandardExpirationBindingElement.MaximumMessageAge); - this.channel = new OAuthServiceProviderChannel(this.signingElement, this.nonceStore, new InMemoryTokenManager(), this.serviceProviderSecuritySettings, new TestMessageFactory()); - this.channel.WebRequestHandler = this.webRequestHandler; + this.channel = new OAuthServiceProviderChannel(this.signingElement, this.nonceStore, new InMemoryTokenManager(), this.serviceProviderSecuritySettings, new TestMessageFactory(), this.HostFactories); } [Test, ExpectedException(typeof(ArgumentException))] @@ -212,7 +209,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { }; Assert.AreEqual(CreateAuthorizationHeader(declaredParts), webRequest.Headers.Authorization.ToString()); - Assert.AreEqual("appearinform=formish", this.webRequestHandler.RequestEntityAsString); + Assert.AreEqual("appearinform=formish", await webRequest.Content.ReadAsStringAsync()); } [Test] @@ -295,7 +292,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { } private async Task ParameterizedRequestTestAsync(HttpDeliveryMethods scheme) { - TestDirectedMessage request = new TestDirectedMessage(MessageTransport.Direct) { + var request = new TestDirectedMessage(MessageTransport.Direct) { Age = 15, Name = "Andrew", Location = new Uri("http://hostb/pathB"), @@ -304,36 +301,36 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { HttpMethods = scheme, }; - HttpResponseMessage rawResponse = null; - this.webRequestHandler.Callback = async req => { - Assert.IsNotNull(req); - HttpRequestMessage reqInfo = ConvertToRequestInfo(req, this.webRequestHandler.RequestEntityStream); - Assert.AreEqual(MessagingUtilities.GetHttpVerb(scheme), reqInfo.Method); - var incomingMessage = (await this.channel.ReadFromRequestAsync(reqInfo, CancellationToken.None)) as TestMessage; - Assert.IsNotNull(incomingMessage); - Assert.AreEqual(request.Age, incomingMessage.Age); - Assert.AreEqual(request.Name, incomingMessage.Name); - Assert.AreEqual(request.Location, incomingMessage.Location); - Assert.AreEqual(request.Timestamp, incomingMessage.Timestamp); - - var responseFields = new Dictionary<string, string> { - { "age", request.Age.ToString() }, - { "Name", request.Name }, - { "Location", request.Location.AbsoluteUri }, - { "Timestamp", XmlConvert.ToString(request.Timestamp, XmlDateTimeSerializationMode.Utc) }, - }; - rawResponse = new HttpResponseMessage(); - rawResponse.Content = new StringContent(MessagingUtilities.CreateQueryString(responseFields)); - return rawResponse; - }; - - IProtocolMessage response = await this.channel.RequestAsync(request, CancellationToken.None); - Assert.IsNotNull(response); - Assert.IsInstanceOf<TestMessage>(response); - TestMessage responseMessage = (TestMessage)response; - Assert.AreEqual(request.Age, responseMessage.Age); - Assert.AreEqual(request.Name, responseMessage.Name); - Assert.AreEqual(request.Location, responseMessage.Location); + await CoordinatorBase.RunAsync( + async (hostFactories, CancellationToken) => { + IProtocolMessage response = await this.channel.RequestAsync(request, CancellationToken.None); + Assert.IsNotNull(response); + Assert.IsInstanceOf<TestMessage>(response); + TestMessage responseMessage = (TestMessage)response; + Assert.AreEqual(request.Age, responseMessage.Age); + Assert.AreEqual(request.Name, responseMessage.Name); + Assert.AreEqual(request.Location, responseMessage.Location); + }, + CoordinatorBase.Handle(request.Location).By(async (req, ct) => { + Assert.IsNotNull(req); + Assert.AreEqual(MessagingUtilities.GetHttpVerb(scheme), req.Method); + var incomingMessage = (await this.channel.ReadFromRequestAsync(req, CancellationToken.None)) as TestMessage; + Assert.IsNotNull(incomingMessage); + Assert.AreEqual(request.Age, incomingMessage.Age); + Assert.AreEqual(request.Name, incomingMessage.Name); + Assert.AreEqual(request.Location, incomingMessage.Location); + Assert.AreEqual(request.Timestamp, incomingMessage.Timestamp); + + var responseFields = new Dictionary<string, string> { + { "age", request.Age.ToString() }, + { "Name", request.Name }, + { "Location", request.Location.AbsoluteUri }, + { "Timestamp", XmlConvert.ToString(request.Timestamp, XmlDateTimeSerializationMode.Utc) }, + }; + var rawResponse = new HttpResponseMessage(); + rawResponse.Content = new StringContent(MessagingUtilities.CreateQueryString(responseFields)); + return rawResponse; + })); } private async Task ParameterizedReceiveTestAsync(HttpDeliveryMethods scheme) { diff --git a/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs b/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs index 2262878..14a0a6d 100644 --- a/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs @@ -341,19 +341,24 @@ namespace DotNetOpenAuth.Test.OpenId { Association rpAssociation = null, opAssociation; AssociateSuccessfulResponse associateSuccessfulResponse = null; AssociateUnsuccessfulResponse associateUnsuccessfulResponse = null; + var relyingParty = new OpenIdRelyingParty(new StandardRelyingPartyApplicationStore(), this.HostFactories); + var provider = new OpenIdProvider(new StandardProviderApplicationStore(), this.HostFactories) { + SecuritySettings = this.ProviderSecuritySettings + }; var coordinator = new CoordinatorBase( - CoordinatorBase.RelyingPartyDriver(async (rp, ct) => { - rp.SecuritySettings = this.RelyingPartySecuritySettings; - rpAssociation = await rp.AssociationManager.GetOrCreateAssociationAsync(opDescription, ct); - }), - CoordinatorBase.HandleProvider(async (op, request, ct) => { - op.SecuritySettings = this.ProviderSecuritySettings; - IRequest req = await op.GetRequestAsync(request, ct); + async (hostFactories, ct) => { + relyingParty.SecuritySettings = this.RelyingPartySecuritySettings; + rpAssociation = await relyingParty.AssociationManager.GetOrCreateAssociationAsync(opDescription, ct); + }, + CoordinatorBase.Handle(opDescription.Uri).By(async (request, ct) => { + IRequest req = await provider.GetRequestAsync(request, ct); Assert.IsNotNull(req, "Expected incoming request but did not receive it."); Assert.IsTrue(req.IsResponseReady); - return await op.PrepareResponseAsync(req, ct); + return await provider.PrepareResponseAsync(req, ct); })); - coordinator.IncomingMessageFilter = message => { + this.HostFactories.Handlers.AddRange(coordinator.HostFactories.Handlers); + coordinator.HostFactories = this.HostFactories; + relyingParty.Channel.IncomingMessageFilter = message => { Assert.AreSame(opDescription.Version, message.Version, "The message was recognized as version {0} but was expected to be {1}.", message.Version, Protocol.Lookup(opDescription.Version).ProtocolVersion); var associateSuccess = message as AssociateSuccessfulResponse; var associateFailed = message as AssociateUnsuccessfulResponse; @@ -364,16 +369,16 @@ namespace DotNetOpenAuth.Test.OpenId { associateUnsuccessfulResponse = associateFailed; } }; - coordinator.OutgoingMessageFilter = message => { + relyingParty.Channel.OutgoingMessageFilter = message => { Assert.AreEqual(opDescription.Version, message.Version, "The message was for version {0} but was expected to be for {1}.", message.Version, opDescription.Version); }; await coordinator.RunAsync(); if (expectSuccess) { Assert.IsNotNull(rpAssociation); - Association actual = coordinator.RelyingParty.AssociationManager.AssociationStoreTestHook.GetAssociation(opDescription.Uri, rpAssociation.Handle); + Association actual = relyingParty.AssociationManager.AssociationStoreTestHook.GetAssociation(opDescription.Uri, rpAssociation.Handle); Assert.AreEqual(rpAssociation, actual); - opAssociation = coordinator.Provider.AssociationStore.Deserialize(new TestSignedDirectedMessage(), false, rpAssociation.Handle); + opAssociation = provider.AssociationStore.Deserialize(new TestSignedDirectedMessage(), false, rpAssociation.Handle); Assert.IsNotNull(opAssociation, "The Provider could not decode the association handle."); Assert.AreEqual(opAssociation.Handle, rpAssociation.Handle); @@ -391,7 +396,7 @@ namespace DotNetOpenAuth.Test.OpenId { var unencryptedResponse = (AssociateUnencryptedResponse)associateSuccessfulResponse; } } else { - Assert.IsNull(coordinator.RelyingParty.AssociationManager.AssociationStoreTestHook.GetAssociation(opDescription.Uri, new RelyingPartySecuritySettings())); + Assert.IsNull(relyingParty.AssociationManager.AssociationStoreTestHook.GetAssociation(opDescription.Uri, new RelyingPartySecuritySettings())); } } } diff --git a/src/DotNetOpenAuth.Test/OpenId/DiscoveryServices/UriDiscoveryServiceTests.cs b/src/DotNetOpenAuth.Test/OpenId/DiscoveryServices/UriDiscoveryServiceTests.cs index 88ad208..e75afb8 100644 --- a/src/DotNetOpenAuth.Test/OpenId/DiscoveryServices/UriDiscoveryServiceTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/DiscoveryServices/UriDiscoveryServiceTests.cs @@ -10,47 +10,53 @@ namespace DotNetOpenAuth.Test.OpenId.DiscoveryServices { using System.Linq; using System.Net; using System.Text; + using System.Threading; + using System.Threading.Tasks; using System.Web; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; using DotNetOpenAuth.OpenId.RelyingParty; + using DotNetOpenAuth.Test.Mocks; + using NUnit.Framework; [TestFixture] public class UriDiscoveryServiceTests : OpenIdTestBase { [Test] - public void DiscoveryWithRedirects() { + public async Task DiscoveryWithRedirects() { Identifier claimedId = this.GetMockIdentifier(ProtocolVersion.V20, false); // Add a couple of chained redirect pages that lead to the claimedId. Uri userSuppliedUri = new Uri("https://localhost/someSecurePage"); Uri insecureMidpointUri = new Uri("http://localhost/insecureStop"); - this.MockResponder.RegisterMockRedirect(userSuppliedUri, insecureMidpointUri); - this.MockResponder.RegisterMockRedirect(insecureMidpointUri, new Uri(claimedId.ToString())); + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockRedirect(userSuppliedUri, insecureMidpointUri)); + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockRedirect(insecureMidpointUri, new Uri(claimedId.ToString()))); // don't require secure SSL discovery for this test. Identifier userSuppliedIdentifier = new UriIdentifier(userSuppliedUri, false); - Assert.AreEqual(1, this.Discover(userSuppliedIdentifier).Count()); + var discoveryResult = await this.DiscoverAsync(userSuppliedIdentifier); + Assert.AreEqual(1, discoveryResult.Count()); } [Test] - public void DiscoverRequireSslWithSecureRedirects() { + public async Task DiscoverRequireSslWithSecureRedirects() { Identifier claimedId = this.GetMockIdentifier(ProtocolVersion.V20, true); // Add a couple of chained redirect pages that lead to the claimedId. // All redirects should be secure. Uri userSuppliedUri = new Uri("https://localhost/someSecurePage"); Uri secureMidpointUri = new Uri("https://localhost/secureStop"); - this.MockResponder.RegisterMockRedirect(userSuppliedUri, secureMidpointUri); - this.MockResponder.RegisterMockRedirect(secureMidpointUri, new Uri(claimedId.ToString())); + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockRedirect(userSuppliedUri, secureMidpointUri)); + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockRedirect(secureMidpointUri, new Uri(claimedId.ToString()))); Identifier userSuppliedIdentifier = new UriIdentifier(userSuppliedUri, true); - Assert.AreEqual(1, this.Discover(userSuppliedIdentifier).Count()); + var discoveryResult = await this.DiscoverAsync(userSuppliedIdentifier); + Assert.AreEqual(1, discoveryResult.Count()); } [Test, ExpectedException(typeof(ProtocolException))] - public void DiscoverRequireSslWithInsecureRedirect() { + public async Task DiscoverRequireSslWithInsecureRedirect() { Identifier claimedId = this.GetMockIdentifier(ProtocolVersion.V20, true); // Add a couple of chained redirect pages that lead to the claimedId. @@ -58,41 +64,43 @@ namespace DotNetOpenAuth.Test.OpenId.DiscoveryServices { // the ultimate endpoint is never found as a result of high security profile. Uri userSuppliedUri = new Uri("https://localhost/someSecurePage"); Uri insecureMidpointUri = new Uri("http://localhost/insecureStop"); - this.MockResponder.RegisterMockRedirect(userSuppliedUri, insecureMidpointUri); - this.MockResponder.RegisterMockRedirect(insecureMidpointUri, new Uri(claimedId.ToString())); + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockRedirect(userSuppliedUri, insecureMidpointUri)); + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockRedirect(insecureMidpointUri, new Uri(claimedId.ToString()))); Identifier userSuppliedIdentifier = new UriIdentifier(userSuppliedUri, true); - this.Discover(userSuppliedIdentifier); + await this.DiscoverAsync(userSuppliedIdentifier); } [Test] - public void DiscoveryRequireSslWithInsecureXrdsInSecureHtmlHead() { + public async Task DiscoveryRequireSslWithInsecureXrdsInSecureHtmlHead() { var insecureXrdsSource = this.GetMockIdentifier(ProtocolVersion.V20, false); Uri secureClaimedUri = new Uri("https://localhost/secureId"); string html = string.Format("<html><head><meta http-equiv='X-XRDS-Location' content='{0}'/></head><body></body></html>", insecureXrdsSource); - this.MockResponder.RegisterMockResponse(secureClaimedUri, "text/html", html); + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockResponse(secureClaimedUri, "text/html", html)); Identifier userSuppliedIdentifier = new UriIdentifier(secureClaimedUri, true); - Assert.AreEqual(0, this.Discover(userSuppliedIdentifier).Count()); + var discoveryResult = await this.DiscoverAsync(userSuppliedIdentifier); + Assert.AreEqual(0, discoveryResult.Count()); } [Test] - public void DiscoveryRequireSslWithInsecureXrdsInSecureHttpHeader() { + public async Task DiscoveryRequireSslWithInsecureXrdsInSecureHttpHeader() { var insecureXrdsSource = this.GetMockIdentifier(ProtocolVersion.V20, false); string html = "<html><head></head><body></body></html>"; WebHeaderCollection headers = new WebHeaderCollection { { "X-XRDS-Location", insecureXrdsSource } }; - this.MockResponder.RegisterMockResponse(VanityUriSsl, VanityUriSsl, "text/html", headers, html); + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockResponse(VanityUriSsl, VanityUriSsl, "text/html", headers, html)); Identifier userSuppliedIdentifier = new UriIdentifier(VanityUriSsl, true); - Assert.AreEqual(0, this.Discover(userSuppliedIdentifier).Count()); + var discoveryResult = await this.DiscoverAsync(userSuppliedIdentifier); + Assert.AreEqual(0, discoveryResult.Count()); } [Test] - public void DiscoveryRequireSslWithInsecureXrdsButSecureLinkTags() { + public async Task DiscoveryRequireSslWithInsecureXrdsButSecureLinkTags() { var insecureXrdsSource = this.GetMockIdentifier(ProtocolVersion.V20, false); string html = string.Format( @" @@ -104,104 +112,106 @@ namespace DotNetOpenAuth.Test.OpenId.DiscoveryServices { HttpUtility.HtmlEncode(insecureXrdsSource), HttpUtility.HtmlEncode(OPUriSsl.AbsoluteUri), HttpUtility.HtmlEncode(OPLocalIdentifiersSsl[1].AbsoluteUri)); - this.MockResponder.RegisterMockResponse(VanityUriSsl, "text/html", html); + this.HostFactories.Handlers.Add(CoordinatorBase.Handle(VanityUriSsl).By(html, "text/html")); Identifier userSuppliedIdentifier = new UriIdentifier(VanityUriSsl, true); // We verify that the XRDS was ignored and the LINK tags were used // because the XRDS OP-LocalIdentifier uses different local identifiers. - Assert.AreEqual(OPLocalIdentifiersSsl[1].AbsoluteUri, this.Discover(userSuppliedIdentifier).Single().ProviderLocalIdentifier.ToString()); + var discoveryResult = await this.DiscoverAsync(userSuppliedIdentifier); + Assert.AreEqual(OPLocalIdentifiersSsl[1].AbsoluteUri, discoveryResult.Single().ProviderLocalIdentifier.ToString()); } [Test] - public void DiscoveryRequiresSslIgnoresInsecureEndpointsInXrds() { + public async Task DiscoveryRequiresSslIgnoresInsecureEndpointsInXrds() { var insecureEndpoint = GetServiceEndpoint(0, ProtocolVersion.V20, 10, false); var secureEndpoint = GetServiceEndpoint(1, ProtocolVersion.V20, 20, true); UriIdentifier secureClaimedId = new UriIdentifier(VanityUriSsl, true); - this.MockResponder.RegisterMockXrdsResponse(secureClaimedId, new IdentifierDiscoveryResult[] { insecureEndpoint, secureEndpoint }); - Assert.AreEqual(secureEndpoint.ProviderLocalIdentifier, this.Discover(secureClaimedId).Single().ProviderLocalIdentifier); + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockXrdsResponse(secureClaimedId, new IdentifierDiscoveryResult[] { insecureEndpoint, secureEndpoint })); + var discoverResult = await this.DiscoverAsync(secureClaimedId); + Assert.AreEqual(secureEndpoint.ProviderLocalIdentifier, discoverResult.Single().ProviderLocalIdentifier); } [Test] - public void XrdsDirectDiscovery_10() { - this.FailDiscoverXrds("xrds-irrelevant"); - this.DiscoverXrds("xrds10", ProtocolVersion.V10, null, "http://a/b"); - this.DiscoverXrds("xrds11", ProtocolVersion.V11, null, "http://a/b"); - this.DiscoverXrds("xrds1020", ProtocolVersion.V10, null, "http://a/b"); + public async Task XrdsDirectDiscovery_10() { + await this.FailDiscoverXrdsAsync("xrds-irrelevant"); + await this.DiscoverXrdsAsync("xrds10", ProtocolVersion.V10, null, "http://a/b"); + await this.DiscoverXrdsAsync("xrds11", ProtocolVersion.V11, null, "http://a/b"); + await this.DiscoverXrdsAsync("xrds1020", ProtocolVersion.V10, null, "http://a/b"); } [Test] - public void XrdsDirectDiscovery_20() { - this.DiscoverXrds("xrds20", ProtocolVersion.V20, null, "http://a/b"); - this.DiscoverXrds("xrds2010a", ProtocolVersion.V20, null, "http://a/b"); - this.DiscoverXrds("xrds2010b", ProtocolVersion.V20, null, "http://a/b"); + public async Task XrdsDirectDiscovery_20() { + await this.DiscoverXrdsAsync("xrds20", ProtocolVersion.V20, null, "http://a/b"); + await this.DiscoverXrdsAsync("xrds2010a", ProtocolVersion.V20, null, "http://a/b"); + await this.DiscoverXrdsAsync("xrds2010b", ProtocolVersion.V20, null, "http://a/b"); } [Test] - public void HtmlDiscover_11() { - this.DiscoverHtml("html10prov", ProtocolVersion.V11, null, "http://a/b"); - this.DiscoverHtml("html10both", ProtocolVersion.V11, "http://c/d", "http://a/b"); - this.FailDiscoverHtml("html10del"); + public async Task HtmlDiscover_11() { + await this.DiscoverHtmlAsync("html10prov", ProtocolVersion.V11, null, "http://a/b"); + await this.DiscoverHtmlAsync("html10both", ProtocolVersion.V11, "http://c/d", "http://a/b"); + await this.FailDiscoverHtmlAsync("html10del"); // Verify that HTML discovery generates the 1.x endpoints when appropriate - this.DiscoverHtml("html2010", ProtocolVersion.V11, "http://g/h", "http://e/f"); - this.DiscoverHtml("html1020", ProtocolVersion.V11, "http://g/h", "http://e/f"); - this.DiscoverHtml("html2010combinedA", ProtocolVersion.V11, "http://c/d", "http://a/b"); - this.DiscoverHtml("html2010combinedB", ProtocolVersion.V11, "http://c/d", "http://a/b"); - this.DiscoverHtml("html2010combinedC", ProtocolVersion.V11, "http://c/d", "http://a/b"); + await this.DiscoverHtmlAsync("html2010", ProtocolVersion.V11, "http://g/h", "http://e/f"); + await this.DiscoverHtmlAsync("html1020", ProtocolVersion.V11, "http://g/h", "http://e/f"); + await this.DiscoverHtmlAsync("html2010combinedA", ProtocolVersion.V11, "http://c/d", "http://a/b"); + await this.DiscoverHtmlAsync("html2010combinedB", ProtocolVersion.V11, "http://c/d", "http://a/b"); + await this.DiscoverHtmlAsync("html2010combinedC", ProtocolVersion.V11, "http://c/d", "http://a/b"); } [Test] - public void HtmlDiscover_20() { - this.DiscoverHtml("html20prov", ProtocolVersion.V20, null, "http://a/b"); - this.DiscoverHtml("html20both", ProtocolVersion.V20, "http://c/d", "http://a/b"); - this.FailDiscoverHtml("html20del"); - this.DiscoverHtml("html2010", ProtocolVersion.V20, "http://c/d", "http://a/b"); - this.DiscoverHtml("html1020", ProtocolVersion.V20, "http://c/d", "http://a/b"); - this.DiscoverHtml("html2010combinedA", ProtocolVersion.V20, "http://c/d", "http://a/b"); - this.DiscoverHtml("html2010combinedB", ProtocolVersion.V20, "http://c/d", "http://a/b"); - this.DiscoverHtml("html2010combinedC", ProtocolVersion.V20, "http://c/d", "http://a/b"); - this.FailDiscoverHtml("html20relative"); + public async Task HtmlDiscover_20() { + await this.DiscoverHtmlAsync("html20prov", ProtocolVersion.V20, null, "http://a/b"); + await this.DiscoverHtmlAsync("html20both", ProtocolVersion.V20, "http://c/d", "http://a/b"); + await this.FailDiscoverHtmlAsync("html20del"); + await this.DiscoverHtmlAsync("html2010", ProtocolVersion.V20, "http://c/d", "http://a/b"); + await this.DiscoverHtmlAsync("html1020", ProtocolVersion.V20, "http://c/d", "http://a/b"); + await this.DiscoverHtmlAsync("html2010combinedA", ProtocolVersion.V20, "http://c/d", "http://a/b"); + await this.DiscoverHtmlAsync("html2010combinedB", ProtocolVersion.V20, "http://c/d", "http://a/b"); + await this.DiscoverHtmlAsync("html2010combinedC", ProtocolVersion.V20, "http://c/d", "http://a/b"); + await this.FailDiscoverHtmlAsync("html20relative"); } [Test] - public void XrdsDiscoveryFromHead() { - this.MockResponder.RegisterMockResponse(new Uri("http://localhost/xrds1020.xml"), "application/xrds+xml", LoadEmbeddedFile("/Discovery/xrdsdiscovery/xrds1020.xml")); - this.DiscoverXrds("XrdsReferencedInHead.html", ProtocolVersion.V10, null, "http://a/b"); + public async Task XrdsDiscoveryFromHead() { + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockResponse(new Uri("http://localhost/xrds1020.xml"), "application/xrds+xml", LoadEmbeddedFile("/Discovery/xrdsdiscovery/xrds1020.xml"))); + await this.DiscoverXrdsAsync("XrdsReferencedInHead.html", ProtocolVersion.V10, null, "http://a/b"); } [Test] - public void XrdsDiscoveryFromHttpHeader() { + public async Task XrdsDiscoveryFromHttpHeader() { WebHeaderCollection headers = new WebHeaderCollection(); headers.Add("X-XRDS-Location", new Uri("http://localhost/xrds1020.xml").AbsoluteUri); - this.MockResponder.RegisterMockResponse(new Uri("http://localhost/xrds1020.xml"), "application/xrds+xml", LoadEmbeddedFile("/Discovery/xrdsdiscovery/xrds1020.xml")); - this.DiscoverXrds("XrdsReferencedInHttpHeader.html", ProtocolVersion.V10, null, "http://a/b", headers); + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockResponse(new Uri("http://localhost/xrds1020.xml"), "application/xrds+xml", LoadEmbeddedFile("/Discovery/xrdsdiscovery/xrds1020.xml"))); + await this.DiscoverXrdsAsync("XrdsReferencedInHttpHeader.html", ProtocolVersion.V10, null, "http://a/b", headers); } /// <summary> /// Verifies HTML discovery proceeds if an XRDS document is referenced that doesn't contain OpenID endpoints. /// </summary> [Test] - public void HtmlDiscoveryProceedsIfXrdsIsEmpty() { - this.MockResponder.RegisterMockResponse(new Uri("http://localhost/xrds-irrelevant.xml"), "application/xrds+xml", LoadEmbeddedFile("/Discovery/xrdsdiscovery/xrds-irrelevant.xml")); - this.DiscoverHtml("html20provWithEmptyXrds", ProtocolVersion.V20, null, "http://a/b"); + public async Task HtmlDiscoveryProceedsIfXrdsIsEmpty() { + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockResponse(new Uri("http://localhost/xrds-irrelevant.xml"), "application/xrds+xml", LoadEmbeddedFile("/Discovery/xrdsdiscovery/xrds-irrelevant.xml"))); + await this.DiscoverHtmlAsync("html20provWithEmptyXrds", ProtocolVersion.V20, null, "http://a/b"); } /// <summary> /// Verifies HTML discovery proceeds if the XRDS that is referenced cannot be found. /// </summary> [Test] - public void HtmlDiscoveryProceedsIfXrdsIsBadOrMissing() { - this.DiscoverHtml("html20provWithBadXrds", ProtocolVersion.V20, null, "http://a/b"); + public async Task HtmlDiscoveryProceedsIfXrdsIsBadOrMissing() { + await this.DiscoverHtmlAsync("html20provWithBadXrds", ProtocolVersion.V20, null, "http://a/b"); } /// <summary> /// Verifies that a dual identifier yields only one service endpoint by default. /// </summary> [Test] - public void DualIdentifierOffByDefault() { - this.MockResponder.RegisterMockResponse(VanityUri, "application/xrds+xml", LoadEmbeddedFile("/Discovery/xrdsdiscovery/xrds20dual.xml")); - var results = this.Discover(VanityUri).ToList(); + public async Task DualIdentifierOffByDefault() { + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockResponse(VanityUri, "application/xrds+xml", LoadEmbeddedFile("/Discovery/xrdsdiscovery/xrds20dual.xml"))); + var results = (await this.DiscoverAsync(VanityUri)).ToList(); Assert.AreEqual(1, results.Count(r => r.ClaimedIdentifier == r.Protocol.ClaimedIdentifierForOPIdentifier), "OP Identifier missing from discovery results."); Assert.AreEqual(1, results.Count, "Unexpected additional services discovered."); } @@ -210,22 +220,21 @@ namespace DotNetOpenAuth.Test.OpenId.DiscoveryServices { /// Verifies that a dual identifier yields two service endpoints when that feature is turned on. /// </summary> [Test] - public void DualIdentifier() { - this.MockResponder.RegisterMockResponse(VanityUri, "application/xrds+xml", LoadEmbeddedFile("/Discovery/xrdsdiscovery/xrds20dual.xml")); + public async Task DualIdentifier() { + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockResponse(VanityUri, "application/xrds+xml", LoadEmbeddedFile("/Discovery/xrdsdiscovery/xrds20dual.xml"))); var rp = this.CreateRelyingParty(true); - rp.Channel.WebRequestHandler = this.RequestHandler; rp.SecuritySettings.AllowDualPurposeIdentifiers = true; - var results = rp.Discover(VanityUri).ToList(); + var results = (await rp.DiscoverAsync(VanityUri, CancellationToken.None)).ToList(); Assert.AreEqual(1, results.Count(r => r.ClaimedIdentifier == r.Protocol.ClaimedIdentifierForOPIdentifier), "OP Identifier missing from discovery results."); Assert.AreEqual(1, results.Count(r => r.ClaimedIdentifier == VanityUri), "Claimed identifier missing from discovery results."); Assert.AreEqual(2, results.Count, "Unexpected additional services discovered."); } - private void Discover(string url, ProtocolVersion version, Identifier expectedLocalId, string providerEndpoint, bool expectSreg, bool useRedirect) { - this.Discover(url, version, expectedLocalId, providerEndpoint, expectSreg, useRedirect, null); + private async Task DiscoverAsync(string url, ProtocolVersion version, Identifier expectedLocalId, string providerEndpoint, bool expectSreg, bool useRedirect) { + await this.DiscoverAsync(url, version, expectedLocalId, providerEndpoint, expectSreg, useRedirect, null); } - private void Discover(string url, ProtocolVersion version, Identifier expectedLocalId, string providerEndpoint, bool expectSreg, bool useRedirect, WebHeaderCollection headers) { + private async Task DiscoverAsync(string url, ProtocolVersion version, Identifier expectedLocalId, string providerEndpoint, bool expectSreg, bool useRedirect, WebHeaderCollection headers) { Protocol protocol = Protocol.Lookup(version); Uri baseUrl = new Uri("http://localhost/"); UriIdentifier claimedId = new Uri(baseUrl, url); @@ -243,7 +252,7 @@ namespace DotNetOpenAuth.Test.OpenId.DiscoveryServices { } else { throw new InvalidOperationException(); } - this.MockResponder.RegisterMockResponse(new Uri(idToDiscover), claimedId, contentType, headers ?? new WebHeaderCollection(), LoadEmbeddedFile(url)); + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockResponse(new Uri(idToDiscover), claimedId, contentType, headers ?? new WebHeaderCollection(), LoadEmbeddedFile(url))); IdentifierDiscoveryResult expected = IdentifierDiscoveryResult.CreateForClaimedIdentifier( claimedId, @@ -252,7 +261,8 @@ namespace DotNetOpenAuth.Test.OpenId.DiscoveryServices { null, null); - IdentifierDiscoveryResult se = this.Discover(idToDiscover).FirstOrDefault(ep => ep.Equals(expected)); + var discoveryResult = await this.DiscoverAsync(idToDiscover); + IdentifierDiscoveryResult se = discoveryResult.FirstOrDefault(ep => ep.Equals(expected)); Assert.IsNotNull(se, url + " failed to be discovered."); // Do extra checking of service type URIs, which aren't included in @@ -262,42 +272,43 @@ namespace DotNetOpenAuth.Test.OpenId.DiscoveryServices { Assert.AreEqual(expectSreg, se.IsExtensionSupported<ClaimsRequest>()); } - private void DiscoverXrds(string page, ProtocolVersion version, Identifier expectedLocalId, string providerEndpoint) { - this.DiscoverXrds(page, version, expectedLocalId, providerEndpoint, null); + private async Task DiscoverXrdsAsync(string page, ProtocolVersion version, Identifier expectedLocalId, string providerEndpoint) { + await this.DiscoverXrdsAsync(page, version, expectedLocalId, providerEndpoint, null); } - private void DiscoverXrds(string page, ProtocolVersion version, Identifier expectedLocalId, string providerEndpoint, WebHeaderCollection headers) { + private async Task DiscoverXrdsAsync(string page, ProtocolVersion version, Identifier expectedLocalId, string providerEndpoint, WebHeaderCollection headers) { if (!page.Contains(".")) { page += ".xml"; } - this.Discover("/Discovery/xrdsdiscovery/" + page, version, expectedLocalId, providerEndpoint, true, false, headers); - this.Discover("/Discovery/xrdsdiscovery/" + page, version, expectedLocalId, providerEndpoint, true, true, headers); + await this.DiscoverAsync("/Discovery/xrdsdiscovery/" + page, version, expectedLocalId, providerEndpoint, true, false, headers); + await this.DiscoverAsync("/Discovery/xrdsdiscovery/" + page, version, expectedLocalId, providerEndpoint, true, true, headers); } - private void DiscoverHtml(string page, ProtocolVersion version, Identifier expectedLocalId, string providerEndpoint, bool useRedirect) { - this.Discover("/Discovery/htmldiscovery/" + page, version, expectedLocalId, providerEndpoint, false, useRedirect); + private async Task DiscoverHtmlAsync(string page, ProtocolVersion version, Identifier expectedLocalId, string providerEndpoint, bool useRedirect) { + await this.DiscoverAsync("/Discovery/htmldiscovery/" + page, version, expectedLocalId, providerEndpoint, false, useRedirect); } - private void DiscoverHtml(string scenario, ProtocolVersion version, Identifier expectedLocalId, string providerEndpoint) { + private async Task DiscoverHtmlAsync(string scenario, ProtocolVersion version, Identifier expectedLocalId, string providerEndpoint) { string page = scenario + ".html"; - this.DiscoverHtml(page, version, expectedLocalId, providerEndpoint, false); - this.DiscoverHtml(page, version, expectedLocalId, providerEndpoint, true); + await this.DiscoverHtmlAsync(page, version, expectedLocalId, providerEndpoint, false); + await this.DiscoverHtmlAsync(page, version, expectedLocalId, providerEndpoint, true); } - private void FailDiscover(string url) { + private async Task FailDiscoverAsync(string url) { UriIdentifier userSuppliedId = new Uri(new Uri("http://localhost"), url); - this.MockResponder.RegisterMockResponse(new Uri(userSuppliedId), userSuppliedId, "text/html", LoadEmbeddedFile(url)); + this.HostFactories.Handlers.Add(MockHttpRequest.RegisterMockResponse(new Uri(userSuppliedId), userSuppliedId, "text/html", LoadEmbeddedFile(url))); - Assert.AreEqual(0, this.Discover(userSuppliedId).Count()); // ... but that no endpoint info is discoverable + var discoveryResult = await this.DiscoverAsync(userSuppliedId); + Assert.AreEqual(0, discoveryResult.Count()); // ... but that no endpoint info is discoverable } - private void FailDiscoverHtml(string scenario) { - this.FailDiscover("/Discovery/htmldiscovery/" + scenario + ".html"); + private async Task FailDiscoverHtmlAsync(string scenario) { + await this.FailDiscoverAsync("/Discovery/htmldiscovery/" + scenario + ".html"); } - private void FailDiscoverXrds(string scenario) { - this.FailDiscover("/Discovery/xrdsdiscovery/" + scenario + ".xml"); + private async Task FailDiscoverXrdsAsync(string scenario) { + await this.FailDiscoverAsync("/Discovery/xrdsdiscovery/" + scenario + ".xml"); } } } diff --git a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs index 05dd8dd..5b4a5aa 100644 --- a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs +++ b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs @@ -23,8 +23,6 @@ namespace DotNetOpenAuth.Test.OpenId { using NUnit.Framework; public class OpenIdTestBase : TestBase { - internal MockingHostFactories HostFactories; - protected internal const string IdentifierSelect = "http://specs.openid.net/auth/2.0/identifier_select"; protected internal static readonly Uri BaseMockUri = new Uri("http://localhost/"); @@ -71,7 +69,6 @@ namespace DotNetOpenAuth.Test.OpenId { this.RelyingPartySecuritySettings = OpenIdElement.Configuration.RelyingParty.SecuritySettings.CreateSecuritySettings(); this.ProviderSecuritySettings = OpenIdElement.Configuration.Provider.SecuritySettings.CreateSecuritySettings(); - this.HostFactories = new MockingHostFactories(); this.AutoProviderScenario = Scenarios.AutoApproval; Identifier.EqualityOnStrings = true; } diff --git a/src/DotNetOpenAuth.Test/TestBase.cs b/src/DotNetOpenAuth.Test/TestBase.cs index 28f5ccd..0c958ef 100644 --- a/src/DotNetOpenAuth.Test/TestBase.cs +++ b/src/DotNetOpenAuth.Test/TestBase.cs @@ -49,6 +49,8 @@ namespace DotNetOpenAuth.Test { get { return this.messageDescriptions; } } + internal MockingHostFactories HostFactories; + /// <summary> /// The TestInitialize method for the test cases. /// </summary> @@ -57,6 +59,7 @@ namespace DotNetOpenAuth.Test { log4net.Config.XmlConfigurator.Configure(Assembly.GetExecutingAssembly().GetManifestResourceStream("DotNetOpenAuth.Test.Logging.config")); MessageBase.LowSecurityMode = true; this.messageDescriptions = new MessageDescriptionCollection(); + this.HostFactories = new MockingHostFactories(); SetMockHttpContext(); } |