aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/IntegratedTests/AuthorizationTest.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-11-20 00:28:53 +0800
committercrupest <crupest@outlook.com>2019-11-20 00:28:53 +0800
commited8bae9cf7fd22300678d718cfee1913209f2cd0 (patch)
tree55eaf43bda897148b0fa8a65406e7289aed3832e /Timeline.Tests/IntegratedTests/AuthorizationTest.cs
parent0ff98dd9274485994b11d9d00f4b647a5f2d42ac (diff)
downloadtimeline-ed8bae9cf7fd22300678d718cfee1913209f2cd0.tar.gz
timeline-ed8bae9cf7fd22300678d718cfee1913209f2cd0.tar.bz2
timeline-ed8bae9cf7fd22300678d718cfee1913209f2cd0.zip
Clean and refactor tests.
Diffstat (limited to 'Timeline.Tests/IntegratedTests/AuthorizationTest.cs')
-rw-r--r--Timeline.Tests/IntegratedTests/AuthorizationTest.cs23
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);