Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to new host apis #23783

Merged
7 commits merged into from
Jul 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 105 additions & 100 deletions src/Identity/test/InMemory.Test/FunctionalTest.cs

Large diffs are not rendered by default.

61 changes: 33 additions & 28 deletions src/Security/Authentication/test/AuthenticationMiddlewareTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Xunit;

namespace Microsoft.AspNetCore.Authentication
Expand All @@ -17,33 +18,38 @@ public class AuthenticationMiddlewareTests
[Fact]
public async Task OnlyInvokesCanHandleRequestHandlers()
{
var builder = new WebHostBuilder()
.Configure(app =>
{
app.UseAuthentication();
})
.ConfigureServices(services => services.AddAuthentication(o =>
{
o.AddScheme("Skip", s =>
{
s.HandlerType = typeof(SkipHandler);
});
// Won't get hit since CanHandleRequests is false
o.AddScheme("throws", s =>
{
s.HandlerType = typeof(ThrowsHandler);
});
o.AddScheme("607", s =>
{
s.HandlerType = typeof(SixOhSevenHandler);
});
// Won't get run since 607 will finish
o.AddScheme("305", s =>
{
s.HandlerType = typeof(ThreeOhFiveHandler);
});
}));
var server = new TestServer(builder);
using var host = new HostBuilder()
.ConfigureWebHost(builder =>
builder.UseTestServer()
.Configure(app =>
{
app.UseAuthentication();
})
.ConfigureServices(services => services.AddAuthentication(o =>
{
o.AddScheme("Skip", s =>
{
s.HandlerType = typeof(SkipHandler);
});
// Won't get hit since CanHandleRequests is false
o.AddScheme("throws", s =>
{
s.HandlerType = typeof(ThrowsHandler);
});
o.AddScheme("607", s =>
{
s.HandlerType = typeof(SixOhSevenHandler);
});
// Won't get run since 607 will finish
o.AddScheme("305", s =>
{
s.HandlerType = typeof(ThreeOhFiveHandler);
});
})))
.Build();

await host.StartAsync();
using var server = host.GetTestServer();
var response = await server.CreateClient().GetAsync("http://example.com/");
Assert.Equal(607, (int)response.StatusCode);
}
Expand Down Expand Up @@ -191,6 +197,5 @@ public Task SignOutAsync(AuthenticationProperties properties)
throw new NotImplementedException();
}
}

}
}
Loading