Fix DataProtection DI dependencies.
This commit is contained in:
parent
0fee3c87a0
commit
b37966f7ef
|
|
@ -18,8 +18,6 @@ using Microsoft.AspNet.Http.Security;
|
|||
using Microsoft.AspNet.TestHost;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
|
||||
namespace Microsoft.AspNet.Security.Cookies
|
||||
{
|
||||
|
|
@ -367,7 +365,7 @@ namespace Microsoft.AspNet.Security.Cookies
|
|||
|
||||
private static TestServer CreateServer(Action<CookieAuthenticationOptions> configureOptions, Func<HttpContext, Task> testpath = null)
|
||||
{
|
||||
return TestServer.Create(app =>
|
||||
return TestServer.Create(TestServices.CreateTestServices(), app =>
|
||||
{
|
||||
app.UseCookieAuthentication(configureOptions);
|
||||
app.Use(async (context, next) =>
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ namespace Microsoft.AspNet.Security.Facebook
|
|||
|
||||
private static TestServer CreateServer(Action<IApplicationBuilder> configure, Func<HttpContext, bool> handler)
|
||||
{
|
||||
return TestServer.Create(app =>
|
||||
return TestServer.Create(TestServices.CreateTestServices(), app =>
|
||||
{
|
||||
if (configure != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ namespace Microsoft.AspNet.Security.Google
|
|||
|
||||
private static TestServer CreateServer(Action<GoogleAuthenticationOptions> configureOptions, Func<HttpContext, Task> testpath = null)
|
||||
{
|
||||
return TestServer.Create(app =>
|
||||
return TestServer.Create(TestServices.CreateTestServices(), app =>
|
||||
{
|
||||
app.UseServices(services =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ namespace Microsoft.AspNet.Security.Tests.MicrosoftAccount
|
|||
|
||||
private static TestServer CreateServer(Action<MicrosoftAccountAuthenticationOptions> configureOptions, Func<HttpContext, bool> handler)
|
||||
{
|
||||
return TestServer.Create(app =>
|
||||
return TestServer.Create(TestServices.CreateTestServices(), app =>
|
||||
{
|
||||
app.UseServices(services =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
// 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 System.Runtime.Versioning;
|
||||
using Microsoft.Framework.Runtime;
|
||||
|
||||
namespace Microsoft.AspNet.Security
|
||||
{
|
||||
public class TestApplicationEnvironment : IApplicationEnvironment
|
||||
{
|
||||
public string ApplicationBasePath
|
||||
{
|
||||
get { return Environment.CurrentDirectory; }
|
||||
}
|
||||
|
||||
public string ApplicationName
|
||||
{
|
||||
get { return "Test App environment"; }
|
||||
}
|
||||
|
||||
public string Configuration
|
||||
{
|
||||
get { return "Test"; }
|
||||
}
|
||||
|
||||
public FrameworkName RuntimeFramework
|
||||
{
|
||||
get { return new FrameworkName(".NETFramework", new Version(4, 5)); }
|
||||
}
|
||||
|
||||
public string Version
|
||||
{
|
||||
get { return "1.0.0"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ namespace Microsoft.AspNet.Security.Twitter
|
|||
|
||||
private static TestServer CreateServer(Action<IApplicationBuilder> configure, Func<HttpContext, bool> handler)
|
||||
{
|
||||
return TestServer.Create(app =>
|
||||
return TestServer.Create(TestServices.CreateTestServices(), app =>
|
||||
{
|
||||
app.UseServices(services =>
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue