aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/Helpers/Authentication/AuthenticationExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Timeline.Tests/Helpers/Authentication/AuthenticationExtensions.cs')
-rw-r--r--Timeline.Tests/Helpers/Authentication/AuthenticationExtensions.cs16
1 files changed, 2 insertions, 14 deletions
diff --git a/Timeline.Tests/Helpers/Authentication/AuthenticationExtensions.cs b/Timeline.Tests/Helpers/Authentication/AuthenticationExtensions.cs
index f4e2e45a..27362ac3 100644
--- a/Timeline.Tests/Helpers/Authentication/AuthenticationExtensions.cs
+++ b/Timeline.Tests/Helpers/Authentication/AuthenticationExtensions.cs
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Newtonsoft.Json;
-using System;
using System.Net.Http;
using System.Threading.Tasks;
using Timeline.Entities.Http;
@@ -11,9 +10,9 @@ namespace Timeline.Tests.Helpers.Authentication
{
private const string CreateTokenUrl = "/token/create";
- public static async Task<CreateTokenResponse> CreateUserTokenAsync(this HttpClient client, string username, string password)
+ public static async Task<CreateTokenResponse> CreateUserTokenAsync(this HttpClient client, string username, string password, double? expireOffset = null)
{
- var response = await client.PostAsJsonAsync(CreateTokenUrl, new CreateTokenRequest { Username = username, Password = password });
+ var response = await client.PostAsJsonAsync(CreateTokenUrl, new CreateTokenRequest { Username = username, Password = password, ExpireOffset = expireOffset });
var result = JsonConvert.DeserializeObject<CreateTokenResponse>(await response.Content.ReadAsStringAsync());
return result;
}
@@ -25,16 +24,5 @@ namespace Timeline.Tests.Helpers.Authentication
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
return client;
}
-
- public static async Task<HttpResponseMessage> SendWithAuthenticationAsync(this HttpClient client, string token, string path, Action<HttpRequestMessage> requestBuilder = null)
- {
- var request = new HttpRequestMessage
- {
- RequestUri = new Uri(client.BaseAddress, path),
- };
- request.Headers.Add("Authorization", "Bearer " + token);
- requestBuilder?.Invoke(request);
- return await client.SendAsync(request);
- }
}
}