diff options
Diffstat (limited to 'Timeline.Tests/IntegratedTests/AuthorizationTest.cs')
-rw-r--r-- | Timeline.Tests/IntegratedTests/AuthorizationTest.cs | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/Timeline.Tests/IntegratedTests/AuthorizationTest.cs b/Timeline.Tests/IntegratedTests/AuthorizationTest.cs index a31d98f5..0bc094af 100644 --- a/Timeline.Tests/IntegratedTests/AuthorizationTest.cs +++ b/Timeline.Tests/IntegratedTests/AuthorizationTest.cs @@ -1,28 +1,17 @@ using FluentAssertions;
using Microsoft.AspNetCore.Mvc.Testing;
-using System;
using System.Net;
using System.Threading.Tasks;
using Timeline.Tests.Helpers;
-using Timeline.Tests.Helpers.Authentication;
using Xunit;
namespace Timeline.Tests.IntegratedTests
{
- public class AuthorizationTest : IClassFixture<WebApplicationFactory<Startup>>, IDisposable
+ public class AuthorizationTest : IntegratedTestBase
{
- private readonly TestApplication _testApp;
- private readonly WebApplicationFactory<Startup> _factory;
-
public AuthorizationTest(WebApplicationFactory<Startup> factory)
+ : base(factory)
{
- _testApp = new TestApplication(factory);
- _factory = _testApp.Factory;
- }
-
- public void Dispose()
- {
- _testApp.Dispose();
}
private const string BaseUrl = "testing/auth/";
@@ -33,7 +22,7 @@ namespace Timeline.Tests.IntegratedTests [Fact]
public async Task UnauthenticationTest()
{
- using var client = _factory.CreateDefaultClient();
+ using var client = await CreateClientWithNoAuth();
var response = await client.GetAsync(AuthorizeUrl);
response.Should().HaveStatusCode(HttpStatusCode.Unauthorized);
}
@@ -41,7 +30,7 @@ namespace Timeline.Tests.IntegratedTests [Fact]
public async Task AuthenticationTest()
{
- using var client = await _factory.CreateClientAsUser();
+ using var client = await CreateClientAsUser();
var response = await client.GetAsync(AuthorizeUrl);
response.Should().HaveStatusCode(HttpStatusCode.OK);
}
@@ -49,7 +38,7 @@ namespace Timeline.Tests.IntegratedTests [Fact]
public async Task UserAuthorizationTest()
{
- using var client = await _factory.CreateClientAsUser();
+ using var client = await CreateClientAsUser();
var response1 = await client.GetAsync(UserUrl);
response1.Should().HaveStatusCode(HttpStatusCode.OK);
var response2 = await client.GetAsync(AdminUrl);
@@ -59,7 +48,7 @@ namespace Timeline.Tests.IntegratedTests [Fact]
public async Task AdminAuthorizationTest()
{
- using var client = await _factory.CreateClientAsAdmin();
+ using var client = await CreateClientAsAdmin();
var response1 = await client.GetAsync(UserUrl);
response1.Should().HaveStatusCode(HttpStatusCode.OK);
var response2 = await client.GetAsync(AdminUrl);
|