diff --git a/test/Identity.IntegrationTest/Login/ClientVersionGateTests.cs b/test/Identity.IntegrationTest/Login/ClientVersionGateTests.cs index 02eca826ab..501d39754d 100644 --- a/test/Identity.IntegrationTest/Login/ClientVersionGateTests.cs +++ b/test/Identity.IntegrationTest/Login/ClientVersionGateTests.cs @@ -23,7 +23,10 @@ public class ClientVersionGateTests : IClassFixture [Theory, BitAutoData, RegisterFinishRequestModelCustomize] public async Task TokenEndpoint_GrantTypePassword_V2User_OnOldClientVersion_Blocked(RegisterFinishRequestModel requestModel) { - var localFactory = new IdentityApplicationFactory(); + var localFactory = new IdentityApplicationFactory + { + UseMockClientVersionValidator = false + }; var server = localFactory.Server; var user = await localFactory.RegisterNewIdentityFactoryUserAsync(requestModel); @@ -68,7 +71,10 @@ public class ClientVersionGateTests : IClassFixture [Theory, BitAutoData, RegisterFinishRequestModelCustomize] public async Task TokenEndpoint_GrantTypePassword_V2User_OnMinClientVersion_Succeeds(RegisterFinishRequestModel requestModel) { - var localFactory = new IdentityApplicationFactory(); + var localFactory = new IdentityApplicationFactory + { + UseMockClientVersionValidator = false + }; var server = localFactory.Server; var user = await localFactory.RegisterNewIdentityFactoryUserAsync(requestModel); diff --git a/test/IntegrationTestCommon/Factories/IdentityApplicationFactory.cs b/test/IntegrationTestCommon/Factories/IdentityApplicationFactory.cs index b8642cc49e..d228ed38e3 100644 --- a/test/IntegrationTestCommon/Factories/IdentityApplicationFactory.cs +++ b/test/IntegrationTestCommon/Factories/IdentityApplicationFactory.cs @@ -25,6 +25,7 @@ public class IdentityApplicationFactory : WebApplicationFactoryBase public const string DefaultDeviceIdentifier = "92b9d953-b9b6-4eaf-9d3e-11d57144dfeb"; public const string DefaultUserEmail = "DefaultEmail@bitwarden.com"; public const string DefaultUserPasswordHash = "default_password_hash"; + public bool UseMockClientVersionValidator { get; set; } = true; /// /// A dictionary to store registration tokens for email verification. We cannot substitute the IMailService more than once, so @@ -48,12 +49,15 @@ public class IdentityApplicationFactory : WebApplicationFactoryBase }); }); - // Bypass client version gating to isolate tests from client version behavior - SubstituteService(svc => + if (UseMockClientVersionValidator) { - svc.ValidateAsync(Arg.Any(), Arg.Any()) - .Returns(Task.FromResult(true)); - }); + // Bypass client version gating to isolate tests from client version behavior + SubstituteService(svc => + { + svc.ValidateAsync(Arg.Any(), Arg.Any()) + .Returns(Task.FromResult(true)); + }); + } base.ConfigureWebHost(builder); }