2026-02-08 11:57:57 +01:00
|
|
|
using IdentityShroud.Core.Contracts;
|
2026-02-26 16:53:02 +01:00
|
|
|
using IdentityShroud.Core.Security;
|
2026-02-08 11:57:57 +01:00
|
|
|
|
2026-02-15 19:06:09 +01:00
|
|
|
namespace IdentityShroud.TestUtils.Substitutes;
|
2026-02-08 11:57:57 +01:00
|
|
|
|
|
|
|
|
public static class EncryptionServiceSubstitute
|
|
|
|
|
{
|
2026-02-26 16:53:02 +01:00
|
|
|
public static KekId KeyId { get; } = KekId.NewId();
|
|
|
|
|
|
|
|
|
|
public static IDekEncryptionService CreatePassthrough()
|
2026-02-08 11:57:57 +01:00
|
|
|
{
|
2026-02-26 16:53:02 +01:00
|
|
|
var encryptionService = Substitute.For<IDekEncryptionService>();
|
2026-02-08 11:57:57 +01:00
|
|
|
encryptionService
|
2026-02-24 06:32:58 +01:00
|
|
|
.Encrypt(Arg.Any<ReadOnlyMemory<byte>>())
|
2026-02-26 16:53:02 +01:00
|
|
|
.Returns(x => new EncryptedDek(KeyId, x.ArgAt<ReadOnlyMemory<byte>>(0).ToArray()));
|
2026-02-08 11:57:57 +01:00
|
|
|
encryptionService
|
2026-02-26 16:53:02 +01:00
|
|
|
.Decrypt(Arg.Any<EncryptedDek>())
|
|
|
|
|
.Returns(x => x.ArgAt<EncryptedDek>(0).Value);
|
2026-02-08 11:57:57 +01:00
|
|
|
return encryptionService;
|
|
|
|
|
}
|
|
|
|
|
}
|