-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathUtilities.cs
More file actions
25 lines (24 loc) · 802 Bytes
/
Copy pathUtilities.cs
File metadata and controls
25 lines (24 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
using Blazorcrud.Server.Authorization;
using Blazorcrud.Shared.Models;
using Microsoft.AspNetCore.Mvc.Testing;
namespace Blazorcrud.Server.IntegrationTests
{
public static class Utilities
{
public static async Task<string> GetJwtAsync(HttpClient client)
{
var login = new AuthenticateRequest
{
Username = "admin",
Password = "admin"
};
var response = await client.PostAsJsonAsync("/api/user/authenticate", login);
response.EnsureSuccessStatusCode();
var authResponse = await response.Content.ReadFromJsonAsync<AuthenticateResponse>();
return authResponse.Token;
}
}
}