From 23d9e3f4e581874353c65bc587cb87806312ae51 Mon Sep 17 00:00:00 2001 From: Thomas Avery Date: Fri, 25 Oct 2024 11:03:12 -0500 Subject: [PATCH] update tests --- .../AccountsKeyManagementControllerTests.cs | 43 +++++++++++++------ .../AccountsKeyManagementControllerTests.cs | 17 +++++--- ...egenerateUserAsymmetricKeysCommandTests.cs | 1 + 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/test/Api.IntegrationTest/KeyManagement/Controllers/AccountsKeyManagementControllerTests.cs b/test/Api.IntegrationTest/KeyManagement/Controllers/AccountsKeyManagementControllerTests.cs index 0895bb1d9..ec7ca3746 100644 --- a/test/Api.IntegrationTest/KeyManagement/Controllers/AccountsKeyManagementControllerTests.cs +++ b/test/Api.IntegrationTest/KeyManagement/Controllers/AccountsKeyManagementControllerTests.cs @@ -19,6 +19,7 @@ public class AccountsKeyManagementControllerTests : IClassFixture(); _emergencyAccessRepository = _factory.GetService(); + _organizationUserRepository = _factory.GetService(); } public async Task InitializeAsync() @@ -80,24 +82,30 @@ public class AccountsKeyManagementControllerTests : IClassFixture sutProvider, - KeyRegenerationRequestModel data, User user) + KeyRegenerationRequestModel data, User user, ICollection orgUsers, + ICollection accessDetails) { sutProvider.GetDependency().IsEnabled(Arg.Is(FeatureFlagKeys.PrivateKeyRegeneration)) .Returns(true); sutProvider.GetDependency().GetUserByPrincipalAsync(Arg.Any()).Returns(user); + sutProvider.GetDependency().GetManyByUserAsync(Arg.Is(user.Id)).Returns(orgUsers); + sutProvider.GetDependency().GetManyDetailsByGranteeIdAsync(Arg.Is(user.Id)) + .Returns(accessDetails); await sutProvider.Sut.RegenerateKeysAsync(data); @@ -81,9 +85,12 @@ public class AccountsKeyManagementControllerTests .GetManyByUserAsync(Arg.Is(user.Id)); await sutProvider.GetDependency().Received(1) .GetManyDetailsByGranteeIdAsync(Arg.Is(user.Id)); - await sutProvider.GetDependency().ReceivedWithAnyArgs(1) - .RegenerateKeysAsync(Arg.Any(), - Arg.Any>(), - Arg.Any>()); + await sutProvider.GetDependency().Received(1) + .RegenerateKeysAsync( + Arg.Is(u => + u.UserId == user.Id && u.PublicKey == data.UserPublicKey && + u.UserKeyEncryptedPrivateKey == data.UserKeyEncryptedUserPrivateKey), + Arg.Is(orgUsers), + Arg.Is(accessDetails)); } } diff --git a/test/Core.Test/KeyManagement/Commands/RegenerateUserAsymmetricKeysCommandTests.cs b/test/Core.Test/KeyManagement/Commands/RegenerateUserAsymmetricKeysCommandTests.cs index f35673e0e..ce2b9afef 100644 --- a/test/Core.Test/KeyManagement/Commands/RegenerateUserAsymmetricKeysCommandTests.cs +++ b/test/Core.Test/KeyManagement/Commands/RegenerateUserAsymmetricKeysCommandTests.cs @@ -56,6 +56,7 @@ public class RegenerateUserAsymmetricKeysCommandTests [BitAutoData(false, true, false)] [BitAutoData(false, true, true)] [BitAutoData(true, false, false)] + [BitAutoData(true, false, true)] [BitAutoData(true, true, false)] [BitAutoData(true, true, true)] public async Task RegenerateKeysAsync_UserIdMisMatch_NotFoundException(