diff options
author | 杨宇千 <crupest@outlook.com> | 2019-07-23 19:03:25 +0800 |
---|---|---|
committer | 杨宇千 <crupest@outlook.com> | 2019-07-23 19:03:25 +0800 |
commit | 58985e8f2a6931029974067b2c1e78963e4508f0 (patch) | |
tree | 572a2ae5c65c484718b3bfda68fd8babc56fe6f2 /Timeline.Tests/Helpers/Authentication/AuthenticationExtensions.cs | |
parent | c84faf2b8f5a55ae170e92ead6516e573a318e65 (diff) | |
download | timeline-58985e8f2a6931029974067b2c1e78963e4508f0.tar.gz timeline-58985e8f2a6931029974067b2c1e78963e4508f0.tar.bz2 timeline-58985e8f2a6931029974067b2c1e78963e4508f0.zip |
Fix bugs and write unit tests.
Diffstat (limited to 'Timeline.Tests/Helpers/Authentication/AuthenticationExtensions.cs')
-rw-r--r-- | Timeline.Tests/Helpers/Authentication/AuthenticationExtensions.cs | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/Timeline.Tests/Helpers/Authentication/AuthenticationExtensions.cs b/Timeline.Tests/Helpers/Authentication/AuthenticationExtensions.cs index cda9fe99..f4e2e45a 100644 --- a/Timeline.Tests/Helpers/Authentication/AuthenticationExtensions.cs +++ b/Timeline.Tests/Helpers/Authentication/AuthenticationExtensions.cs @@ -1,11 +1,9 @@ using Microsoft.AspNetCore.Mvc.Testing; using Newtonsoft.Json; using System; -using System.Net; using System.Net.Http; using System.Threading.Tasks; using Timeline.Entities.Http; -using Xunit; namespace Timeline.Tests.Helpers.Authentication { @@ -13,15 +11,10 @@ namespace Timeline.Tests.Helpers.Authentication { private const string CreateTokenUrl = "/token/create"; - public static async Task<CreateTokenResponse> CreateUserTokenAsync(this HttpClient client, string username, string password, bool assertSuccess = true) + public static async Task<CreateTokenResponse> CreateUserTokenAsync(this HttpClient client, string username, string password) { var response = await client.PostAsJsonAsync(CreateTokenUrl, new CreateTokenRequest { Username = username, Password = password }); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - var result = JsonConvert.DeserializeObject<CreateTokenResponse>(await response.Content.ReadAsStringAsync()); - if (assertSuccess) - Assert.True(result.Success); - return result; } |