Fix tests to work with new default

This commit is contained in:
Hao Kung 2017-07-07 11:28:41 -07:00 committed by Hao Kung
parent d433f034fa
commit 38d33cfbf2
7 changed files with 7 additions and 26 deletions

View File

@ -1247,7 +1247,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies
=> CreateServerWithServices(s =>
{
s.AddSingleton<ISystemClock>(_clock);
s.AddAuthentication().AddCookie(configureOptions);
s.AddAuthentication(o => o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(configureOptions);
s.AddSingleton<IClaimsTransformation, ClaimsTransformer>();
}, testpath, baseAddress);

View File

@ -86,24 +86,6 @@ namespace Microsoft.AspNetCore.Authentication
await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync("http://example.com/auth/One"));
}
[Fact]
public async Task VerifyDefaultBehavior()
{
var server = CreateServer();
await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync("http://example.com/auth"));
var response = await server.CreateClient().GetAsync("http://example.com/add/One");
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var transaction = await server.SendAsync("http://example.com/auth");
Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One"));
response = await server.CreateClient().GetAsync("http://example.com/add/Two");
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
// Default will blow up since now there's two
await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync("http://example.com/auth"));
}
public class TestOptions : AuthenticationSchemeOptions
{
public Singleton Instance { get; set; }

View File

@ -81,8 +81,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook
{
services.AddAuthentication(options =>
{
options.DefaultSignInScheme = "External";
options.DefaultAuthenticateScheme = "External";
options.DefaultScheme = "External";
})
.AddCookie("External", o => { })
.AddFacebook(o =>
@ -221,7 +220,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook
{
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie()
.AddFacebook(o =>

View File

@ -1050,7 +1050,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
services.AddTransient<IClaimsTransformation, ClaimsTransformer>();
services.AddAuthentication(o =>
{
o.DefaultAuthenticateScheme = TestExtensions.CookieAuthenticationScheme;
o.DefaultScheme = TestExtensions.CookieAuthenticationScheme;
o.DefaultChallengeScheme = GoogleDefaults.AuthenticationScheme;
});
services.AddAuthentication()

View File

@ -748,7 +748,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer
}
});
})
.ConfigureServices(services => services.AddAuthentication().AddJwtBearer(options));
.ConfigureServices(services => services.AddAuthentication(o => o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options));
return new TestServer(builder);
}

View File

@ -226,7 +226,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount
{
services.AddAuthentication(o =>
{
o.DefaultAuthenticateScheme = TestExtensions.CookieAuthenticationScheme;
o.DefaultScheme = TestExtensions.CookieAuthenticationScheme;
});
services.AddAuthentication()
.AddCookie(TestExtensions.CookieAuthenticationScheme, o => { })

View File

@ -111,7 +111,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect
{
services.AddAuthentication(o =>
{
o.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
});
services.AddAuthentication()
.AddCookie()