aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/Helpers
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-04-11 21:13:15 +0800
committerGitHub <noreply@github.com>2019-04-11 21:13:15 +0800
commit19cae15eba2bcede41b818e1b8ab7fd5ac92eb05 (patch)
tree34118752ae3015a26c0f6f3a02b3043806ce895a /Timeline.Tests/Helpers
parent5b5ca3acb1b9decb5ad13798dc79ba2d58f2ce95 (diff)
parent63573d7c988e0bc1b7e82eeea53ecc3678b0a2f5 (diff)
downloadtimeline-19cae15eba2bcede41b818e1b8ab7fd5ac92eb05.tar.gz
timeline-19cae15eba2bcede41b818e1b8ab7fd5ac92eb05.tar.bz2
timeline-19cae15eba2bcede41b818e1b8ab7fd5ac92eb05.zip
Merge pull request #19 from crupest/18-createtoken
Change create token api.
Diffstat (limited to 'Timeline.Tests/Helpers')
-rw-r--r--Timeline.Tests/Helpers/Authentication/AuthenticationHttpClientExtensions.cs13
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;
}