React to fallback changes

This commit is contained in:
Hao Kung 2014-11-20 17:25:16 -08:00
parent 977a08ddca
commit 5f06906087
6 changed files with 14 additions and 30 deletions

View File

@ -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<CookieAuthenticationOptions> configureOptions, Func<HttpContext, Task> 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) =>
{

View File

@ -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<IApplicationBuilder> configure, Func<HttpContext, bool> handler)
{
return TestServer.Create(TestServices.CreateTestServices(), app =>
return TestServer.Create(app =>
{
if (configure != null)
{

View File

@ -463,10 +463,11 @@ namespace Microsoft.AspNet.Security.Google
private static TestServer CreateServer(Action<GoogleAuthenticationOptions> configureOptions, Func<HttpContext, Task> testpath = null)
{
return TestServer.Create(TestServices.CreateTestServices(), app =>
return TestServer.Create(app =>
{
app.UseServices(services =>
{
services.Add(DataProtectionServices.GetDefaultServices());
services.Configure<ExternalAuthenticationOptions>(options =>
{
options.SignInAsAuthenticationType = CookieAuthenticationType;

View File

@ -161,10 +161,11 @@ namespace Microsoft.AspNet.Security.Tests.MicrosoftAccount
private static TestServer CreateServer(Action<MicrosoftAccountAuthenticationOptions> configureOptions, Func<HttpContext, bool> handler)
{
return TestServer.Create(TestServices.CreateTestServices(), app =>
return TestServer.Create(app =>
{
app.UseServices(services =>
{
services.Add(DataProtectionServices.GetDefaultServices());
services.Configure<ExternalAuthenticationOptions>(options =>
{
options.SignInAsAuthenticationType = "External";

View File

@ -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<IApplicationEnvironment, TestApplicationEnvironment>();
collection.Add(DataProtectionServices.GetDefaultServices());
return collection.BuildServiceProvider();
}
}
}

View File

@ -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<IApplicationBuilder> configure, Func<HttpContext, bool> handler)
{
return TestServer.Create(TestServices.CreateTestServices(), app =>
return TestServer.Create(app =>
{
app.UseServices(services =>
{
services.Add(DataProtectionServices.GetDefaultServices());
services.Configure<ExternalAuthenticationOptions>(options =>
{
options.SignInAsAuthenticationType = "External";