Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit b37966f

Browse files
committed
Fix DataProtection DI dependencies.
1 parent 0fee3c8 commit b37966f

File tree

7 files changed

+64
-7
lines changed

7 files changed

+64
-7
lines changed

test/Microsoft.AspNet.Security.Test/Cookies/CookieMiddlewareTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
using Microsoft.AspNet.TestHost;
1919
using Shouldly;
2020
using Xunit;
21-
using Microsoft.Framework.OptionsModel;
22-
using Microsoft.Framework.DependencyInjection;
2321

2422
namespace Microsoft.AspNet.Security.Cookies
2523
{
@@ -367,7 +365,7 @@ private static async Task<XElement> GetAuthData(TestServer server, string url, s
367365

368366
private static TestServer CreateServer(Action<CookieAuthenticationOptions> configureOptions, Func<HttpContext, Task> testpath = null)
369367
{
370-
return TestServer.Create(app =>
368+
return TestServer.Create(TestServices.CreateTestServices(), app =>
371369
{
372370
app.UseCookieAuthentication(configureOptions);
373371
app.Use(async (context, next) =>

test/Microsoft.AspNet.Security.Test/Facebook/FacebookMiddlewareTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public async Task ChallengeWillTriggerRedirection()
107107

108108
private static TestServer CreateServer(Action<IApplicationBuilder> configure, Func<HttpContext, bool> handler)
109109
{
110-
return TestServer.Create(app =>
110+
return TestServer.Create(TestServices.CreateTestServices(), app =>
111111
{
112112
if (configure != null)
113113
{

test/Microsoft.AspNet.Security.Test/Google/GoogleMiddlewareTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ private static async Task<Transaction> SendAsync(TestServer server, string uri,
463463

464464
private static TestServer CreateServer(Action<GoogleAuthenticationOptions> configureOptions, Func<HttpContext, Task> testpath = null)
465465
{
466-
return TestServer.Create(app =>
466+
return TestServer.Create(TestServices.CreateTestServices(), app =>
467467
{
468468
app.UseServices(services =>
469469
{

test/Microsoft.AspNet.Security.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public async Task AuthenticatedEventCanGetRefreshToken()
161161

162162
private static TestServer CreateServer(Action<MicrosoftAccountAuthenticationOptions> configureOptions, Func<HttpContext, bool> handler)
163163
{
164-
return TestServer.Create(app =>
164+
return TestServer.Create(TestServices.CreateTestServices(), app =>
165165
{
166166
app.UseServices(services =>
167167
{
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Runtime.Versioning;
6+
using Microsoft.Framework.Runtime;
7+
8+
namespace Microsoft.AspNet.Security
9+
{
10+
public class TestApplicationEnvironment : IApplicationEnvironment
11+
{
12+
public string ApplicationBasePath
13+
{
14+
get { return Environment.CurrentDirectory; }
15+
}
16+
17+
public string ApplicationName
18+
{
19+
get { return "Test App environment"; }
20+
}
21+
22+
public string Configuration
23+
{
24+
get { return "Test"; }
25+
}
26+
27+
public FrameworkName RuntimeFramework
28+
{
29+
get { return new FrameworkName(".NETFramework", new Version(4, 5)); }
30+
}
31+
32+
public string Version
33+
{
34+
get { return "1.0.0"; }
35+
}
36+
}
37+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using Microsoft.AspNet.Security.DataProtection;
6+
using Microsoft.Framework.DependencyInjection;
7+
using Microsoft.Framework.DependencyInjection.Fallback;
8+
using Microsoft.Framework.Runtime;
9+
10+
namespace Microsoft.AspNet.Security
11+
{
12+
public static class TestServices
13+
{
14+
public static IServiceProvider CreateTestServices()
15+
{
16+
var collection = new ServiceCollection();
17+
collection.AddSingleton<IApplicationEnvironment, TestApplicationEnvironment>();
18+
collection.Add(DataProtectionServices.GetDefaultServices());
19+
return collection.BuildServiceProvider();
20+
}
21+
}
22+
}

test/Microsoft.AspNet.Security.Test/Twitter/TwitterMiddlewareTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public async Task ChallengeWillTriggerRedirection()
107107

108108
private static TestServer CreateServer(Action<IApplicationBuilder> configure, Func<HttpContext, bool> handler)
109109
{
110-
return TestServer.Create(app =>
110+
return TestServer.Create(TestServices.CreateTestServices(), app =>
111111
{
112112
app.UseServices(services =>
113113
{

0 commit comments

Comments
 (0)