aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/Helpers/Authentication
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-04-11 20:11:23 +0800
committercrupest <crupest@outlook.com>2019-04-11 20:11:23 +0800
commitf562660f52ce055e243b937a988f04c90ad3ae55 (patch)
tree49dc35791778a4ed1403319708046ac8823210b6 /Timeline.Tests/Helpers/Authentication
parent1eb6d9abfc24eec380b7b5d7423102a53041239e (diff)
downloadtimeline-f562660f52ce055e243b937a988f04c90ad3ae55.tar.gz
timeline-f562660f52ce055e243b937a988f04c90ad3ae55.tar.bz2
timeline-f562660f52ce055e243b937a988f04c90ad3ae55.zip
Change create token api.
Diffstat (limited to 'Timeline.Tests/Helpers/Authentication')
-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;
}