From cb146fcbc8649691f7fabe2cfb3265f224e000fc Mon Sep 17 00:00:00 2001 From: Patrick Pimentel Date: Mon, 24 Nov 2025 15:42:54 -0500 Subject: [PATCH] fix(auth-validator): [PM-22975] Client Version Validator - Fixed tests --- .../Factories/ApiApplicationFactory.cs | 6 ++-- test/Common/Helpers/AssertHelper.cs | 32 +------------------ .../WebApplicationFactoryExtensions.cs | 2 -- 3 files changed, 4 insertions(+), 36 deletions(-) diff --git a/test/Api.IntegrationTest/Factories/ApiApplicationFactory.cs b/test/Api.IntegrationTest/Factories/ApiApplicationFactory.cs index 173580ad8c..08bd602537 100644 --- a/test/Api.IntegrationTest/Factories/ApiApplicationFactory.cs +++ b/test/Api.IntegrationTest/Factories/ApiApplicationFactory.cs @@ -66,10 +66,10 @@ public class ApiApplicationFactory : WebApplicationFactoryBase KdfIterations = AuthConstants.PBKDF2_ITERATIONS.Default, UserAsymmetricKeys = new KeysRequestModel() { - PublicKey = "public_key", - EncryptedPrivateKey = "private_key" + PublicKey = "pk_test", + EncryptedPrivateKey = "2.iv|ct|mac" // v1-format so parsing succeeds and user is treated as v1 }, - UserSymmetricKey = "sym_key", + UserSymmetricKey = "2.iv|ct|mac", }); return await _identityApplicationFactory.TokenFromPasswordAsync(email, masterPasswordHash); diff --git a/test/Common/Helpers/AssertHelper.cs b/test/Common/Helpers/AssertHelper.cs index 1a9ad8ee16..5e9c3a5aba 100644 --- a/test/Common/Helpers/AssertHelper.cs +++ b/test/Common/Helpers/AssertHelper.cs @@ -225,37 +225,7 @@ public static class AssertHelper public async static Task AssertResponseTypeIs(HttpContext context) { - try - { - if (context.Response.Body.CanSeek) - { - context.Response.Body.Position = 0; - } - - return await JsonSerializer.DeserializeAsync(context.Response.Body); - } - catch (JsonException ex) - { - string bodyText = ""; - try - { - if (context.Response.Body.CanSeek) - { - context.Response.Body.Position = 0; - } - - using var sr = new StreamReader(context.Response.Body, leaveOpen: true); - bodyText = await sr.ReadToEndAsync(); - } - catch - { - // ignore read errors - } - - throw new Xunit.Sdk.XunitException( - $"Failed to deserialize response to {typeof(T).Name}. " + - $"StatusCode: {context.Response.StatusCode}. Body:\n{bodyText}\nException: {ex}"); - } + return await JsonSerializer.DeserializeAsync(context.Response.Body); } public static TimeSpan AssertRecent(DateTime dateTime, int skewSeconds = 2) diff --git a/test/IntegrationTestCommon/Factories/WebApplicationFactoryExtensions.cs b/test/IntegrationTestCommon/Factories/WebApplicationFactoryExtensions.cs index 37c0cb2e98..3f5bf49dd9 100644 --- a/test/IntegrationTestCommon/Factories/WebApplicationFactoryExtensions.cs +++ b/test/IntegrationTestCommon/Factories/WebApplicationFactoryExtensions.cs @@ -36,8 +36,6 @@ public static class WebApplicationFactoryExtensions httpContext.Request.Body = content.ReadAsStream(); } - httpContext.Request.Headers.Append("Bitwarden-Client-Version", "2025.11.0"); - extraConfiguration?.Invoke(httpContext); }); }