part #2
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
// Sprint: SPRINT_4100_0006_0002 - eIDAS Crypto Plugin Tests
|
||||
using StellaOps.Cryptography;
|
||||
using StellaOps.TestKit;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Cryptography.Plugin.EIDAS.Tests;
|
||||
|
||||
public partial class EidasCryptoProviderTests
|
||||
{
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void GetSigner_ReturnsEidasSigner()
|
||||
{
|
||||
var keyRef = new CryptoKeyReference("test-key-local");
|
||||
var signer = _provider.GetSigner("ECDSA-P256", keyRef);
|
||||
|
||||
Assert.NotNull(signer);
|
||||
Assert.Equal("test-key-local", signer.KeyId);
|
||||
Assert.Equal("ECDSA-P256", signer.AlgorithmId);
|
||||
}
|
||||
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void UpsertSigningKey_AddsKey()
|
||||
{
|
||||
var keyRef = new CryptoKeyReference("test-upsert");
|
||||
var signingKey = new CryptoSigningKey(
|
||||
keyRef,
|
||||
"ECDSA-P256",
|
||||
new byte[] { 1, 2, 3, 4 },
|
||||
FixedUtcNow);
|
||||
|
||||
_provider.UpsertSigningKey(signingKey);
|
||||
|
||||
var keys = _provider.GetSigningKeys();
|
||||
Assert.Contains(keys, k => k.Reference.KeyId == "test-upsert");
|
||||
}
|
||||
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void RemoveSigningKey_RemovesKey()
|
||||
{
|
||||
var keyRef = new CryptoKeyReference("test-remove");
|
||||
var signingKey = new CryptoSigningKey(
|
||||
keyRef,
|
||||
"ECDSA-P256",
|
||||
new byte[] { 1, 2, 3, 4 },
|
||||
FixedUtcNow);
|
||||
|
||||
_provider.UpsertSigningKey(signingKey);
|
||||
Assert.Contains(_provider.GetSigningKeys(), k => k.Reference.KeyId == "test-remove");
|
||||
|
||||
var removed = _provider.RemoveSigningKey("test-remove");
|
||||
|
||||
Assert.True(removed);
|
||||
Assert.DoesNotContain(_provider.GetSigningKeys(), k => k.Reference.KeyId == "test-remove");
|
||||
}
|
||||
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void RemoveSigningKey_ReturnsFalseForNonExistentKey()
|
||||
{
|
||||
var removed = _provider.RemoveSigningKey("non-existent-key");
|
||||
|
||||
Assert.False(removed);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user