diff options
author | 杨宇千 <crupest@outlook.com> | 2019-04-11 21:13:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-11 21:13:15 +0800 |
commit | 8c5e7069d2651fb6fae641dfe482d7a0910b3fd1 (patch) | |
tree | 49dc35791778a4ed1403319708046ac8823210b6 /Timeline.Tests/Helpers/Authentication | |
parent | 1eb6d9abfc24eec380b7b5d7423102a53041239e (diff) | |
parent | f562660f52ce055e243b937a988f04c90ad3ae55 (diff) | |
download | timeline-8c5e7069d2651fb6fae641dfe482d7a0910b3fd1.tar.gz timeline-8c5e7069d2651fb6fae641dfe482d7a0910b3fd1.tar.bz2 timeline-8c5e7069d2651fb6fae641dfe482d7a0910b3fd1.zip |
Merge pull request #19 from crupest/18-createtoken
Change create token api.
Diffstat (limited to 'Timeline.Tests/Helpers/Authentication')
-rw-r--r-- | Timeline.Tests/Helpers/Authentication/AuthenticationHttpClientExtensions.cs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Timeline.Tests/Helpers/Authentication/AuthenticationHttpClientExtensions.cs b/Timeline.Tests/Helpers/Authentication/AuthenticationHttpClientExtensions.cs index a4cb8c65..ccb2a372 100644 --- a/Timeline.Tests/Helpers/Authentication/AuthenticationHttpClientExtensions.cs +++ b/Timeline.Tests/Helpers/Authentication/AuthenticationHttpClientExtensions.cs @@ -1,11 +1,9 @@ using Newtonsoft.Json; using System; -using System.Collections.Generic; -using System.Linq; using System.Net; using System.Net.Http; using System.Threading.Tasks; -using Timeline.Controllers; +using Timeline.Entities; using Xunit; namespace Timeline.Tests.Helpers.Authentication @@ -14,13 +12,16 @@ namespace Timeline.Tests.Helpers.Authentication { private const string CreateTokenUrl = "/api/User/CreateToken"; - public static async Task<UserController.CreateTokenResult> CreateUserTokenAsync(this HttpClient client, string username, string password) + public static async Task<CreateTokenResponse> CreateUserTokenAsync(this HttpClient client, string username, string password, bool assertSuccess = true) { - var response = await client.PostAsJsonAsync(CreateTokenUrl, new UserController.UserCredentials { Username = username, Password = password }); + var response = await client.PostAsJsonAsync(CreateTokenUrl, new CreateTokenRequest { Username = username, Password = password }); Assert.Equal(HttpStatusCode.OK, response.StatusCode); - var result = JsonConvert.DeserializeObject<UserController.CreateTokenResult>(await response.Content.ReadAsStringAsync()); + var result = JsonConvert.DeserializeObject<CreateTokenResponse>(await response.Content.ReadAsStringAsync()); + + if (assertSuccess) + Assert.True(result.Success); return result; } |