1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 05:00:19 -05:00

Fix more tests

This commit is contained in:
Bernd Schoolmann 2025-03-18 13:44:09 +01:00
parent 2b20f0ded9
commit d608a807cb
No known key found for this signature in database

View File

@ -13,6 +13,7 @@ using Bit.Core.AdminConsole.Services;
using Bit.Core.Auth.Entities; using Bit.Core.Auth.Entities;
using Bit.Core.Auth.Models.Api.Request.Accounts; using Bit.Core.Auth.Models.Api.Request.Accounts;
using Bit.Core.Auth.Models.Data; using Bit.Core.Auth.Models.Data;
using Bit.Core.Auth.Services;
using Bit.Core.Auth.UserFeatures.TdeOffboardingPassword.Interfaces; using Bit.Core.Auth.UserFeatures.TdeOffboardingPassword.Interfaces;
using Bit.Core.Auth.UserFeatures.UserMasterPassword.Interfaces; using Bit.Core.Auth.UserFeatures.UserMasterPassword.Interfaces;
using Bit.Core.Entities; using Bit.Core.Entities;
@ -53,6 +54,7 @@ public class AccountsControllerTests : IDisposable
_resetPasswordValidator; _resetPasswordValidator;
private readonly IRotationValidator<IEnumerable<WebAuthnLoginRotateKeyRequestModel>, IEnumerable<WebAuthnLoginRotateKeyData>> private readonly IRotationValidator<IEnumerable<WebAuthnLoginRotateKeyRequestModel>, IEnumerable<WebAuthnLoginRotateKeyData>>
_webauthnKeyRotationValidator; _webauthnKeyRotationValidator;
private readonly IOpaqueKeyExchangeService _opaqueKeyExchangeService;
public AccountsControllerTests() public AccountsControllerTests()
@ -77,6 +79,7 @@ public class AccountsControllerTests : IDisposable
_resetPasswordValidator = Substitute _resetPasswordValidator = Substitute
.For<IRotationValidator<IEnumerable<ResetPasswordWithOrgIdRequestModel>, .For<IRotationValidator<IEnumerable<ResetPasswordWithOrgIdRequestModel>,
IReadOnlyList<OrganizationUser>>>(); IReadOnlyList<OrganizationUser>>>();
_opaqueKeyExchangeService = Substitute.For<IOpaqueKeyExchangeService>();
_sut = new AccountsController( _sut = new AccountsController(
_organizationService, _organizationService,
@ -93,7 +96,8 @@ public class AccountsControllerTests : IDisposable
_sendValidator, _sendValidator,
_emergencyAccessValidator, _emergencyAccessValidator,
_resetPasswordValidator, _resetPasswordValidator,
_webauthnKeyRotationValidator _webauthnKeyRotationValidator,
_opaqueKeyExchangeService
); );
} }
@ -291,12 +295,12 @@ public class AccountsControllerTests : IDisposable
{ {
var user = GenerateExampleUser(); var user = GenerateExampleUser();
ConfigureUserServiceToReturnValidPrincipalFor(user); ConfigureUserServiceToReturnValidPrincipalFor(user);
_userService.ChangePasswordAsync(user, default, default, default, default) _userService.ChangePasswordAsync(user, default, default, default, default, null)
.Returns(Task.FromResult(IdentityResult.Success)); .Returns(Task.FromResult(IdentityResult.Success));
await _sut.PostPassword(new PasswordRequestModel()); await _sut.PostPassword(new PasswordRequestModel());
await _userService.Received(1).ChangePasswordAsync(user, default, default, default, default); await _userService.Received(1).ChangePasswordAsync(user, default, default, default, default, null);
} }
[Fact] [Fact]
@ -314,7 +318,7 @@ public class AccountsControllerTests : IDisposable
{ {
var user = GenerateExampleUser(); var user = GenerateExampleUser();
ConfigureUserServiceToReturnValidPrincipalFor(user); ConfigureUserServiceToReturnValidPrincipalFor(user);
_userService.ChangePasswordAsync(user, default, default, default, default) _userService.ChangePasswordAsync(user, default, default, default, default, null)
.Returns(Task.FromResult(IdentityResult.Failed())); .Returns(Task.FromResult(IdentityResult.Failed()));
await Assert.ThrowsAsync<BadRequestException>( await Assert.ThrowsAsync<BadRequestException>(