mirror of
https://github.com/bitwarden/server.git
synced 2025-06-20 02:48:03 -05:00
Fix tests
This commit is contained in:
parent
c305af7ed6
commit
ee857ed0e5
@ -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.");
|
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.");
|
throw new InvalidOperationException("No signed public key provided, but the user already has a signature key pair.");
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ public class RotateUserAccountKeysCommandTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Theory, BitAutoData]
|
[Theory, BitAutoData]
|
||||||
public async Task ThrowsWhenSignatureKeyPairMissingForV2User(SutProvider<RotateUserAccountKeysCommand> sutProvider, User user,
|
public async Task ThrowsWhenSignatureKeyPairMissingInModelForV2User(SutProvider<RotateUserAccountKeysCommand> sutProvider, User user,
|
||||||
RotateUserAccountKeysData model)
|
RotateUserAccountKeysData model)
|
||||||
{
|
{
|
||||||
// Simulate v2 user (e.g., by setting a property or flag, depending on implementation)
|
// 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.KdfIterations = 3;
|
||||||
user.KdfMemory = 64;
|
user.KdfMemory = 64;
|
||||||
user.KdfParallelism = 4;
|
user.KdfParallelism = 4;
|
||||||
user.PublicKey = "v2-public-key";
|
user.PublicKey = "public-key";
|
||||||
user.PrivateKey = "2.xxx";
|
user.PrivateKey = "7.xxx";
|
||||||
// Remove signature key pair
|
// Remove signature key pair
|
||||||
if (model.AccountKeys != null)
|
if (model.AccountKeys != null)
|
||||||
{
|
{
|
||||||
@ -160,10 +160,11 @@ public class RotateUserAccountKeysCommandTests
|
|||||||
model.UserKeyEncryptedAccountPrivateKey = "2.xxx";
|
model.UserKeyEncryptedAccountPrivateKey = "2.xxx";
|
||||||
model.AccountKeys.PublicKeyEncryptionKeyPairData.PublicKey = user.PublicKey;
|
model.AccountKeys.PublicKeyEncryptionKeyPairData.PublicKey = user.PublicKey;
|
||||||
sutProvider.GetDependency<IUserSignatureKeyPairRepository>().GetByUserIdAsync(user.Id)
|
sutProvider.GetDependency<IUserSignatureKeyPairRepository>().GetByUserIdAsync(user.Id)
|
||||||
.Returns((SignatureKeyPairData)null);
|
.Returns(new SignatureKeyPairData(SignatureAlgorithm.Ed25519, "dummyWrappedSigningKey", "dummyVerifyingKey"));
|
||||||
sutProvider.GetDependency<IUserService>().CheckPasswordAsync(user, model.OldMasterKeyAuthenticationHash)
|
sutProvider.GetDependency<IUserService>().CheckPasswordAsync(user, model.OldMasterKeyAuthenticationHash)
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
await Assert.ThrowsAsync<InvalidOperationException>(async () => await sutProvider.Sut.RotateUserAccountKeysAsync(user, model));
|
var ex = await Assert.ThrowsAsync<InvalidOperationException>(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]
|
[Theory, BitAutoData]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user