diff --git a/src/Core/KeyManagement/UserKey/Implementations/RotateUserAccountkeysCommand.cs b/src/Core/KeyManagement/UserKey/Implementations/RotateUserAccountkeysCommand.cs index dea3436435..d30db6fa77 100644 --- a/src/Core/KeyManagement/UserKey/Implementations/RotateUserAccountkeysCommand.cs +++ b/src/Core/KeyManagement/UserKey/Implementations/RotateUserAccountkeysCommand.cs @@ -108,7 +108,7 @@ public class RotateUserAccountKeysCommand( { throw new InvalidOperationException("The provided signing key data does not match the user's current signing key data."); } - if (string.IsNullOrEmpty(model.AccountKeys.PublicKeyEncryptionKeyPairData?.SiginedPublicKey)) + if (string.IsNullOrEmpty(model.AccountKeys.PublicKeyEncryptionKeyPairData?.SignedPublicKey)) { throw new InvalidOperationException("No signed public key provided, but the user already has a signature key pair."); } diff --git a/test/Core.Test/KeyManagement/UserKey/RotateUserAccountKeysCommandTests.cs b/test/Core.Test/KeyManagement/UserKey/RotateUserAccountKeysCommandTests.cs index 91fd813f71..bb2637e2db 100644 --- a/test/Core.Test/KeyManagement/UserKey/RotateUserAccountKeysCommandTests.cs +++ b/test/Core.Test/KeyManagement/UserKey/RotateUserAccountKeysCommandTests.cs @@ -136,7 +136,7 @@ public class RotateUserAccountKeysCommandTests } [Theory, BitAutoData] - public async Task ThrowsWhenSignatureKeyPairMissingForV2User(SutProvider sutProvider, User user, + public async Task ThrowsWhenSignatureKeyPairMissingInModelForV2User(SutProvider sutProvider, User user, RotateUserAccountKeysData model) { // Simulate v2 user (e.g., by setting a property or flag, depending on implementation) @@ -144,8 +144,8 @@ public class RotateUserAccountKeysCommandTests user.KdfIterations = 3; user.KdfMemory = 64; user.KdfParallelism = 4; - user.PublicKey = "v2-public-key"; - user.PrivateKey = "2.xxx"; + user.PublicKey = "public-key"; + user.PrivateKey = "7.xxx"; // Remove signature key pair if (model.AccountKeys != null) { @@ -160,10 +160,11 @@ public class RotateUserAccountKeysCommandTests model.UserKeyEncryptedAccountPrivateKey = "2.xxx"; model.AccountKeys.PublicKeyEncryptionKeyPairData.PublicKey = user.PublicKey; sutProvider.GetDependency().GetByUserIdAsync(user.Id) - .Returns((SignatureKeyPairData)null); + .Returns(new SignatureKeyPairData(SignatureAlgorithm.Ed25519, "dummyWrappedSigningKey", "dummyVerifyingKey")); sutProvider.GetDependency().CheckPasswordAsync(user, model.OldMasterKeyAuthenticationHash) .Returns(true); - await Assert.ThrowsAsync(async () => await sutProvider.Sut.RotateUserAccountKeysAsync(user, model)); + var ex = await Assert.ThrowsAsync(async () => await sutProvider.Sut.RotateUserAccountKeysAsync(user, model)); + Assert.Equal("The provided user key encrypted account private key was not wrapped with XChaCha20-Poly1305", ex.Message); } [Theory, BitAutoData]