ProjectLighthouse/ProjectLighthouse.Tests.GameApiTests/Integration/DatabaseTests.cs
Henry Asbridge e060f55896
Base64 encode auth tokens (#1029)
* Base64 encode auth tokens to prevent issues in emails
This fixes #1023, which should in turn solve some issues people were having with emails.

* Make test bcrypt hash things as the auth token isn't one by default

* Update ProjectLighthouse/Helpers/CryptoHelper.cs

Co-authored-by: Josh <josh@slendy.pw>

* Make only email tokens base64 encoded

---------

Co-authored-by: Zaprit <zaprit@hugespaceship.io>
Co-authored-by: Josh <josh@slendy.pw>
2024-06-29 18:14:16 +00:00

29 lines
No EOL
1 KiB
C#

using System;
using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup;
using LBPUnion.ProjectLighthouse.Tests.Helpers;
using LBPUnion.ProjectLighthouse.Tests.Integration;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using Xunit;
namespace ProjectLighthouse.Tests.GameApiTests.Integration;
[Trait("Category", "Integration")]
public class DatabaseTests : LighthouseServerTest<GameServerTestStartup>
{
[Fact]
public async Task CanCreateUserTwice()
{
await using DatabaseContext database = await IntegrationHelper.GetIntegrationDatabase();
int rand = new Random().Next();
UserEntity userA = await database.CreateUser("unitTestUser" + rand, CryptoHelper.BCryptHash(CryptoHelper.GenerateAuthToken()));
UserEntity userB = await database.CreateUser("unitTestUser" + rand, CryptoHelper.BCryptHash(CryptoHelper.GenerateAuthToken()));
Assert.NotNull(userA);
Assert.NotNull(userB);
}
}