IdentityShroud/IdentityShroud.TestUtils/Substitutes/EncryptionServiceSubstitute.cs

21 lines
No EOL
722 B
C#

using IdentityShroud.Core.Contracts;
using IdentityShroud.Core.Security;
namespace IdentityShroud.TestUtils.Substitutes;
public static class EncryptionServiceSubstitute
{
public static KekId KeyId { get; } = KekId.NewId();
public static IDekEncryptionService CreatePassthrough()
{
var encryptionService = Substitute.For<IDekEncryptionService>();
encryptionService
.Encrypt(Arg.Any<ReadOnlyMemory<byte>>())
.Returns(x => new EncryptedDek(KeyId, x.ArgAt<ReadOnlyMemory<byte>>(0).ToArray()));
encryptionService
.Decrypt(Arg.Any<EncryptedDek>())
.Returns(x => x.ArgAt<EncryptedDek>(0).Value);
return encryptionService;
}
}