diff options
author | 杨宇千 <crupest@outlook.com> | 2019-08-04 21:35:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-04 21:35:04 +0800 |
commit | 52f5d2724d74ddb37141d8dfcc8384c0c8ce0e24 (patch) | |
tree | d1c9c7b51353b67b47bb4cd89aa82754ef0a1234 /Timeline.Tests/AuthorizationUnitTest.cs | |
parent | c07297373df08bd605f5bec96020192bb6dec151 (diff) | |
parent | d1ebb882e8484c80eca86cac80602fb4c1401834 (diff) | |
download | timeline-52f5d2724d74ddb37141d8dfcc8384c0c8ce0e24.tar.gz timeline-52f5d2724d74ddb37141d8dfcc8384c0c8ce0e24.tar.bz2 timeline-52f5d2724d74ddb37141d8dfcc8384c0c8ce0e24.zip |
Merge pull request #34 from crupest/token-time
Set token expired time and write unit tests.
Diffstat (limited to 'Timeline.Tests/AuthorizationUnitTest.cs')
-rw-r--r-- | Timeline.Tests/AuthorizationUnitTest.cs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Timeline.Tests/AuthorizationUnitTest.cs b/Timeline.Tests/AuthorizationUnitTest.cs index ee3deac8..a25a8f9b 100644 --- a/Timeline.Tests/AuthorizationUnitTest.cs +++ b/Timeline.Tests/AuthorizationUnitTest.cs @@ -8,7 +8,7 @@ using Xunit.Abstractions; namespace Timeline.Tests { - public class AuthorizationUnitTest : IClassFixture<WebApplicationFactory<Startup>> + public class AuthorizationUnitTest : IClassFixture<MyWebApplicationFactory<Startup>> { private const string AuthorizeUrl = "Test/User/Authorize"; private const string UserUrl = "Test/User/User"; @@ -16,9 +16,9 @@ namespace Timeline.Tests private readonly WebApplicationFactory<Startup> _factory; - public AuthorizationUnitTest(WebApplicationFactory<Startup> factory, ITestOutputHelper outputHelper) + public AuthorizationUnitTest(MyWebApplicationFactory<Startup> factory, ITestOutputHelper outputHelper) { - _factory = factory.WithTestConfig(outputHelper); + _factory = factory.WithTestLogging(outputHelper); } [Fact] @@ -44,12 +44,11 @@ namespace Timeline.Tests [Fact] public async Task UserAuthorizationTest() { - using (var client = _factory.CreateDefaultClient()) + using (var client = await _factory.CreateClientWithUser("user", "user")) { - var token = (await client.CreateUserTokenAsync("user", "user")).Token; - var response1 = await client.SendWithAuthenticationAsync(token, UserUrl); + var response1 = await client.GetAsync(UserUrl); Assert.Equal(HttpStatusCode.OK, response1.StatusCode); - var response2 = await client.SendWithAuthenticationAsync(token, AdminUrl); + var response2 = await client.GetAsync(AdminUrl); Assert.Equal(HttpStatusCode.Forbidden, response2.StatusCode); } } |