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 | ebda3fc381ee4ed9f729fa85c1cee837ce4c5c3b (patch) | |
tree | d1c9c7b51353b67b47bb4cd89aa82754ef0a1234 /Timeline.Tests/AuthorizationUnitTest.cs | |
parent | 85d25348c9d6ad527b86c57fd5023829c8b9d6bf (diff) | |
parent | 2a32e03a384a30b14988b0b6e40db845f4a5444e (diff) | |
download | timeline-ebda3fc381ee4ed9f729fa85c1cee837ce4c5c3b.tar.gz timeline-ebda3fc381ee4ed9f729fa85c1cee837ce4c5c3b.tar.bz2 timeline-ebda3fc381ee4ed9f729fa85c1cee837ce4c5c3b.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); } } |