Fix all tests

This commit is contained in:
jvyden 2021-11-22 17:40:25 -05:00
parent 688721d6c2
commit 84669201ab
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
5 changed files with 25 additions and 7 deletions

View file

@ -9,6 +9,7 @@ using LBPUnion.ProjectLighthouse.Serialization;
using LBPUnion.ProjectLighthouse.Types;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Tests
{
@ -25,9 +26,15 @@ namespace LBPUnion.ProjectLighthouse.Tests
this.Client = this.Server.CreateClient();
}
public async Task<HttpResponseMessage> AuthenticateResponse(int number = 0)
public async Task<HttpResponseMessage> AuthenticateResponse(int number = 0, bool createUser = true)
{
const string username = "unitTestUser";
if (createUser)
{
await using Database database = new();
if (await database.Users.FirstOrDefaultAsync(u => u.Username == $"{username}{number}") == null)
await database.CreateUser($"{username}{number}", HashHelper.BCryptHash($"unitTestPassword{number}"));
}
string stringContent = $"{LoginData.UsernamePrefix}{username}{number}{(char)0x00}";