From 5f06906087b71cf587dce0f4ef3e1a1f84d5348d Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 20 Nov 2014 17:25:16 -0800 Subject: [PATCH] React to fallback changes --- .../Cookies/CookieMiddlewareTests.cs | 4 +++- .../Facebook/FacebookMiddlewareTests.cs | 8 +++---- .../Google/GoogleMiddlewareTests.cs | 3 ++- .../MicrosoftAccountMiddlewareTests.cs | 3 ++- .../TestServices.cs | 22 ------------------- .../Twitter/TwitterMiddlewareTests.cs | 4 +++- 6 files changed, 14 insertions(+), 30 deletions(-) delete mode 100644 test/Microsoft.AspNet.Security.Test/TestServices.cs diff --git a/test/Microsoft.AspNet.Security.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNet.Security.Test/Cookies/CookieMiddlewareTests.cs index dbf470f839..a5ca8bcaf7 100644 --- a/test/Microsoft.AspNet.Security.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Security.Test/Cookies/CookieMiddlewareTests.cs @@ -15,6 +15,7 @@ using System.Xml.Linq; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Security; +using Microsoft.AspNet.Security.DataProtection; using Microsoft.AspNet.TestHost; using Shouldly; using Xunit; @@ -365,8 +366,9 @@ namespace Microsoft.AspNet.Security.Cookies private static TestServer CreateServer(Action configureOptions, Func testpath = null) { - return TestServer.Create(TestServices.CreateTestServices(), app => + return TestServer.Create(app => { + app.UseServices(services => services.Add(DataProtectionServices.GetDefaultServices())); app.UseCookieAuthentication(configureOptions); app.Use(async (context, next) => { diff --git a/test/Microsoft.AspNet.Security.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNet.Security.Test/Facebook/FacebookMiddlewareTests.cs index 08c5e1ed43..1749a6ffe3 100644 --- a/test/Microsoft.AspNet.Security.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Security.Test/Facebook/FacebookMiddlewareTests.cs @@ -9,11 +9,9 @@ using System.Net.Http; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Security; -using Microsoft.AspNet.Security.Cookies; +using Microsoft.AspNet.Security.DataProtection; using Microsoft.AspNet.TestHost; using Microsoft.Framework.DependencyInjection; -using Microsoft.Framework.OptionsModel; using Shouldly; using Xunit; @@ -29,6 +27,7 @@ namespace Microsoft.AspNet.Security.Facebook { app.UseServices(services => { + services.Add(DataProtectionServices.GetDefaultServices()); services.ConfigureFacebookAuthentication(options => { options.AppId = "Test App Id"; @@ -72,6 +71,7 @@ namespace Microsoft.AspNet.Security.Facebook { app.UseServices(services => { + services.Add(DataProtectionServices.GetDefaultServices()); services.ConfigureFacebookAuthentication(options => { options.AppId = "Test App Id"; @@ -107,7 +107,7 @@ namespace Microsoft.AspNet.Security.Facebook private static TestServer CreateServer(Action configure, Func handler) { - return TestServer.Create(TestServices.CreateTestServices(), app => + return TestServer.Create(app => { if (configure != null) { diff --git a/test/Microsoft.AspNet.Security.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNet.Security.Test/Google/GoogleMiddlewareTests.cs index b6945d4c5e..e9169baf3c 100644 --- a/test/Microsoft.AspNet.Security.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Security.Test/Google/GoogleMiddlewareTests.cs @@ -463,10 +463,11 @@ namespace Microsoft.AspNet.Security.Google private static TestServer CreateServer(Action configureOptions, Func testpath = null) { - return TestServer.Create(TestServices.CreateTestServices(), app => + return TestServer.Create(app => { app.UseServices(services => { + services.Add(DataProtectionServices.GetDefaultServices()); services.Configure(options => { options.SignInAsAuthenticationType = CookieAuthenticationType; diff --git a/test/Microsoft.AspNet.Security.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNet.Security.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs index 5b01da6c09..6a5cb84f39 100644 --- a/test/Microsoft.AspNet.Security.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Security.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -161,10 +161,11 @@ namespace Microsoft.AspNet.Security.Tests.MicrosoftAccount private static TestServer CreateServer(Action configureOptions, Func handler) { - return TestServer.Create(TestServices.CreateTestServices(), app => + return TestServer.Create(app => { app.UseServices(services => { + services.Add(DataProtectionServices.GetDefaultServices()); services.Configure(options => { options.SignInAsAuthenticationType = "External"; diff --git a/test/Microsoft.AspNet.Security.Test/TestServices.cs b/test/Microsoft.AspNet.Security.Test/TestServices.cs deleted file mode 100644 index ea3b392ce7..0000000000 --- a/test/Microsoft.AspNet.Security.Test/TestServices.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNet.Security.DataProtection; -using Microsoft.Framework.DependencyInjection; -using Microsoft.Framework.DependencyInjection.Fallback; -using Microsoft.Framework.Runtime; - -namespace Microsoft.AspNet.Security -{ - public static class TestServices - { - public static IServiceProvider CreateTestServices() - { - var collection = new ServiceCollection(); - collection.AddSingleton(); - collection.Add(DataProtectionServices.GetDefaultServices()); - return collection.BuildServiceProvider(); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Security.Test/Twitter/TwitterMiddlewareTests.cs b/test/Microsoft.AspNet.Security.Test/Twitter/TwitterMiddlewareTests.cs index ab24c00747..a1d6c095fe 100644 --- a/test/Microsoft.AspNet.Security.Test/Twitter/TwitterMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Security.Test/Twitter/TwitterMiddlewareTests.cs @@ -17,6 +17,7 @@ using Shouldly; using Xunit; using Microsoft.Framework.OptionsModel; using Microsoft.Framework.DependencyInjection; +using Microsoft.AspNet.Security.DataProtection; namespace Microsoft.AspNet.Security.Twitter { @@ -107,10 +108,11 @@ namespace Microsoft.AspNet.Security.Twitter private static TestServer CreateServer(Action configure, Func handler) { - return TestServer.Create(TestServices.CreateTestServices(), app => + return TestServer.Create(app => { app.UseServices(services => { + services.Add(DataProtectionServices.GetDefaultServices()); services.Configure(options => { options.SignInAsAuthenticationType = "External";