1
0
mirror of https://github.com/bitwarden/server synced 2026-01-14 14:33:51 +00:00

fix(auth-validator): [PM-22975] Client Version Validator - Fixed tests.

This commit is contained in:
Patrick Pimentel
2026-01-02 16:44:58 -05:00
parent f44cd58b0a
commit 9a1f91f2dd
2 changed files with 61 additions and 23 deletions

View File

@@ -13,6 +13,7 @@ namespace Bit.Identity.IntegrationTest.Login;
public class ClientVersionGateTests : IClassFixture<IdentityApplicationFactory>
{
private readonly IdentityApplicationFactory _factory;
private const string DefaultEncryptedString = "2.3Uk+WNBIoU5xzmVFNcoWzz==|1MsPIYuRfdOHfu/0uY6H2Q==|/98sp4wb6pHP1VTZ9JcNCYgQjEUMFPlqJgCwRk1YXKg=";
public ClientVersionGateTests(IdentityApplicationFactory factory)
{
@@ -23,6 +24,7 @@ public class ClientVersionGateTests : IClassFixture<IdentityApplicationFactory>
[Theory, BitAutoData, RegisterFinishRequestModelCustomize]
public async Task TokenEndpoint_GrantTypePassword_V2User_OnOldClientVersion_Blocked(RegisterFinishRequestModel requestModel)
{
NormalizeEncryptedStrings(requestModel);
var localFactory = new IdentityApplicationFactory
{
UseMockClientVersionValidator = false
@@ -72,6 +74,7 @@ public class ClientVersionGateTests : IClassFixture<IdentityApplicationFactory>
[Theory, BitAutoData, RegisterFinishRequestModelCustomize]
public async Task TokenEndpoint_GrantTypePassword_V2User_OnMinClientVersion_Succeeds(RegisterFinishRequestModel requestModel)
{
NormalizeEncryptedStrings(requestModel);
var localFactory = new IdentityApplicationFactory
{
UseMockClientVersionValidator = false
@@ -123,4 +126,24 @@ public class ClientVersionGateTests : IClassFixture<IdentityApplicationFactory>
databaseContext.Users.RemoveRange(databaseContext.Users);
databaseContext.SaveChanges();
}
private static void NormalizeEncryptedStrings(RegisterFinishRequestModel requestModel)
{
var accountKeys = requestModel.UserAsymmetricKeys.AccountKeys;
if (accountKeys == null)
{
return;
}
accountKeys.UserKeyEncryptedAccountPrivateKey = DefaultEncryptedString;
if (accountKeys.PublicKeyEncryptionKeyPair != null)
{
accountKeys.PublicKeyEncryptionKeyPair.WrappedPrivateKey = DefaultEncryptedString;
}
if (accountKeys.SignatureKeyPair != null)
{
accountKeys.SignatureKeyPair.WrappedSigningKey = DefaultEncryptedString;
accountKeys.SignatureKeyPair.SignatureAlgorithm = "ed25519";
}
}
}