Add basic initial functional tests for CustomPolicyProvider sample
This commit is contained in:
parent
8d0f84ea46
commit
31b0413931
|
|
@ -14,6 +14,7 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\samples\Cookies\Cookies.csproj" />
|
||||
<ProjectReference Include="..\..\samples\ClaimsTransformation\ClaimsTransformation.csproj" />
|
||||
<ProjectReference Include="..\..\samples\CustomPolicyProvider\CustomPolicyProvider.csproj" />
|
||||
<ProjectReference Include="..\..\samples\DynamicSchemes\DynamicSchemes.csproj" />
|
||||
<ProjectReference Include="..\..\samples\Identity.ExternalClaims\Identity.ExternalClaims.csproj" />
|
||||
<ProjectReference Include="..\..\samples\PathSchemeSelection\PathSchemeSelection.csproj" />
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using Xunit;
|
||||
|
||||
namespace AuthSamples.FunctionalTests
|
||||
{
|
||||
public class CustomPolicyProviderTests : IClassFixture<WebApplicationFactory<CustomPolicyProvider.Startup>>
|
||||
{
|
||||
public CustomPolicyProviderTests(WebApplicationFactory<CustomPolicyProvider.Startup> fixture)
|
||||
{
|
||||
Client = fixture.CreateDefaultClient();
|
||||
}
|
||||
|
||||
public HttpClient Client { get; }
|
||||
|
||||
[Fact]
|
||||
public async Task DefaultReturns200()
|
||||
{
|
||||
// Arrange & Act
|
||||
var response = await Client.GetAsync("/");
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task MinimumAge10RedirectsWhenNotLoggedIn()
|
||||
{
|
||||
// Arrange & Act
|
||||
var response = await Client.GetAsync("/Home/MinimumAge10");
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
|
||||
Assert.Equal("http://localhost/account/signin?ReturnUrl=%2FHome%2FMinimumAge10", response.Headers.Location.ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task MinimumAge50RedirectsWhenNotLoggedIn()
|
||||
{
|
||||
// Arrange & Act
|
||||
var response = await Client.GetAsync("/Home/MinimumAge50");
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
|
||||
Assert.Equal("http://localhost/account/signin?ReturnUrl=%2FHome%2FMinimumAge50", response.Headers.Location.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue