-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathTestWebApplicationFactory.cs
33 lines (30 loc) · 1.16 KB
/
TestWebApplicationFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
namespace softaware.Authentication.Hmac.AspNetCore.Test
{
public class TestWebApplicationFactory(Action<HmacAuthenticationSchemeOptions> configureOptions)
: WebApplicationFactory<TestStartup>
{
private readonly Action<HmacAuthenticationSchemeOptions> configureOptions = configureOptions;
protected override IWebHostBuilder CreateWebHostBuilder()
{
return new WebHostBuilder().UseStartup<TestStartup>();
}
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.ConfigureServices(services =>
{
services.AddAuthentication(o =>
{
o.DefaultScheme = HmacAuthenticationDefaults.AuthenticationScheme;
})
.AddHmacAuthentication(
HmacAuthenticationDefaults.AuthenticationScheme,
HmacAuthenticationDefaults.AuthenticationType,
this.configureOptions);
});
}
}
}