Refactor code structure and optimize performance across multiple modules

This commit is contained in:
StellaOps Bot
2025-12-26 20:03:22 +02:00
parent c786faae84
commit b4fc66feb6
3353 changed files with 88254 additions and 1590657 deletions

View File

@@ -12,6 +12,7 @@ using StellaOps.Cryptography.Plugin.EIDAS.DependencyInjection;
using StellaOps.Cryptography.Plugin.EIDAS.Models;
using Xunit;
using StellaOps.TestKit;
namespace StellaOps.Cryptography.Plugin.EIDAS.Tests;
public class EidasCryptoProviderTests
@@ -70,13 +71,15 @@ public class EidasCryptoProviderTests
?? throw new InvalidOperationException("Failed to resolve EidasCryptoProvider");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Provider_Name_IsEidas()
{
Assert.Equal("eidas", _provider.Name);
}
[Theory]
[Trait("Category", TestCategories.Unit)]
[Theory]
[InlineData(CryptoCapability.Signing, "ECDSA-P256", true)]
[InlineData(CryptoCapability.Signing, "ECDSA-P384", true)]
[InlineData(CryptoCapability.Signing, "ECDSA-P521", true)]
@@ -94,19 +97,22 @@ public class EidasCryptoProviderTests
Assert.Equal(expected, result);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void GetPasswordHasher_ThrowsNotSupported()
{
Assert.Throws<NotSupportedException>(() => _provider.GetPasswordHasher("PBKDF2"));
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void GetHasher_ThrowsNotSupported()
{
Assert.Throws<NotSupportedException>(() => _provider.GetHasher("SHA256"));
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void GetSigner_ReturnsEidasSigner()
{
var keyRef = new CryptoKeyReference("test-key-local");
@@ -117,7 +123,8 @@ public class EidasCryptoProviderTests
Assert.Equal("ECDSA-P256", signer.AlgorithmId);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void UpsertSigningKey_AddsKey()
{
var keyRef = new CryptoKeyReference("test-upsert");
@@ -134,7 +141,8 @@ public class EidasCryptoProviderTests
Assert.Contains(keys, k => k.Reference.KeyId == "test-upsert");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void RemoveSigningKey_RemovesKey()
{
var keyRef = new CryptoKeyReference("test-remove");
@@ -153,14 +161,16 @@ public class EidasCryptoProviderTests
Assert.DoesNotContain(_provider.GetSigningKeys(), k => k.Reference.KeyId == "test-remove");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void RemoveSigningKey_ReturnsFalseForNonExistentKey()
{
var removed = _provider.RemoveSigningKey("non-existent-key");
Assert.False(removed);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task SignAsync_WithLocalKey_ReturnsSignature()
{
// Note: This test will use the stub implementation
@@ -176,7 +186,8 @@ public class EidasCryptoProviderTests
Assert.NotEmpty(signature);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task VerifyAsync_WithLocalKey_ReturnsTrue()
{
// Note: This test will use the stub implementation
@@ -192,7 +203,8 @@ public class EidasCryptoProviderTests
Assert.True(isValid);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task SignAsync_WithTspKey_ReturnsSignature()
{
// Note: This test will use the stub TSP implementation
@@ -208,7 +220,8 @@ public class EidasCryptoProviderTests
Assert.NotEmpty(signature);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void ExportPublicJsonWebKey_ReturnsStubJwk()
{
var keyRef = new CryptoKeyReference("test-key-local");
@@ -226,7 +239,8 @@ public class EidasCryptoProviderTests
public class EidasDependencyInjectionTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void AddEidasCryptoProviders_RegistersServices()
{
var services = new ServiceCollection();
@@ -249,7 +263,8 @@ public class EidasDependencyInjectionTests
Assert.IsType<EidasCryptoProvider>(provider);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void AddEidasCryptoProviders_WithAction_RegistersServices()
{
var services = new ServiceCollection();

View File

@@ -30,6 +30,7 @@
<ItemGroup>
<ProjectReference Include="..\StellaOps.Cryptography.Plugin.EIDAS\StellaOps.Cryptography.Plugin.EIDAS.csproj" />
<ProjectReference Include="..\StellaOps.Cryptography\StellaOps.Cryptography.csproj" />
<ProjectReference Include="../StellaOps.TestKit/StellaOps.TestKit.csproj" />
</ItemGroup>
</Project>