tests fixes and sprints work
This commit is contained in:
@@ -5,6 +5,9 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using StellaOps.Cryptography;
|
||||
using StellaOps.Cryptography.Plugin.EIDAS;
|
||||
using StellaOps.Cryptography.Plugin.EIDAS.Configuration;
|
||||
@@ -15,13 +18,16 @@ using Xunit;
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Cryptography.Plugin.EIDAS.Tests;
|
||||
|
||||
public class EidasCryptoProviderTests
|
||||
public class EidasCryptoProviderTests : IDisposable
|
||||
{
|
||||
private readonly ServiceProvider _serviceProvider;
|
||||
private readonly EidasCryptoProvider _provider;
|
||||
private readonly string _keystorePath;
|
||||
private const string KeystorePassword = "test-password";
|
||||
|
||||
public EidasCryptoProviderTests()
|
||||
{
|
||||
_keystorePath = CreateTestKeystore();
|
||||
var services = new ServiceCollection();
|
||||
|
||||
// Configure eIDAS options
|
||||
@@ -49,8 +55,8 @@ public class EidasCryptoProviderTests
|
||||
options.Local = new LocalSigningOptions
|
||||
{
|
||||
Type = "PKCS12",
|
||||
Path = "/tmp/test-keystore.p12",
|
||||
Password = "test-password"
|
||||
Path = _keystorePath,
|
||||
Password = KeystorePassword
|
||||
};
|
||||
|
||||
// Configure TSP (stub)
|
||||
@@ -71,6 +77,36 @@ public class EidasCryptoProviderTests
|
||||
?? throw new InvalidOperationException("Failed to resolve EidasCryptoProvider");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_serviceProvider.Dispose();
|
||||
|
||||
if (File.Exists(_keystorePath))
|
||||
{
|
||||
File.Delete(_keystorePath);
|
||||
}
|
||||
}
|
||||
|
||||
private static string CreateTestKeystore()
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"eidas-test-{Guid.NewGuid():N}.p12");
|
||||
|
||||
using var ecdsa = ECDsa.Create(ECCurve.NamedCurves.nistP256);
|
||||
var request = new CertificateRequest(
|
||||
"CN=StellaOps Test",
|
||||
ecdsa,
|
||||
HashAlgorithmName.SHA256);
|
||||
|
||||
var notBefore = DateTimeOffset.UtcNow.AddDays(-1);
|
||||
var notAfter = DateTimeOffset.UtcNow.AddDays(7);
|
||||
using var certificate = request.CreateSelfSigned(notBefore, notAfter);
|
||||
|
||||
var pfxBytes = certificate.Export(X509ContentType.Pfx, KeystorePassword);
|
||||
File.WriteAllBytes(path, pfxBytes);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Provider_Name_IsEidas()
|
||||
@@ -249,7 +285,9 @@ public class EidasDependencyInjectionTests
|
||||
{
|
||||
["StellaOps:Crypto:Profiles:eidas:SignatureLevel"] = "AdES",
|
||||
["StellaOps:Crypto:Profiles:eidas:SignatureFormat"] = "CAdES",
|
||||
["StellaOps:Crypto:Profiles:eidas:DefaultAlgorithm"] = "ECDSA-P256"
|
||||
["StellaOps:Crypto:Profiles:eidas:DefaultAlgorithm"] = "ECDSA-P256",
|
||||
["StellaOps:Crypto:Profiles:eidas:Tsp:Endpoint"] = "https://tsp.example.com",
|
||||
["StellaOps:Crypto:Profiles:eidas:Tsp:ApiKey"] = "test-api-key"
|
||||
})
|
||||
.Build();
|
||||
|
||||
@@ -275,6 +313,11 @@ public class EidasDependencyInjectionTests
|
||||
options.SignatureLevel = SignatureLevel.QES;
|
||||
options.SignatureFormat = SignatureFormat.XAdES;
|
||||
options.DefaultAlgorithm = "RSA-PSS-4096";
|
||||
options.Tsp = new TspOptions
|
||||
{
|
||||
Endpoint = "https://tsp.example.com",
|
||||
ApiKey = "test-api-key"
|
||||
};
|
||||
});
|
||||
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
@@ -8,3 +8,4 @@ Source of truth: `docs-archived/implplan/2025-12-29-csproj-audit/SPRINT_20251229
|
||||
| AUDIT-0057-M | DONE | Revalidated 2026-01-08; open findings tracked in audit report. |
|
||||
| AUDIT-0057-T | DONE | Revalidated 2026-01-08; open findings tracked in audit report. |
|
||||
| AUDIT-0057-A | TODO | Revalidated 2026-01-08 (open findings). |
|
||||
| TASK-033-004 | DONE | Fixed keystore/TSP test config; EIDAS tests pass (SPRINT_20260120_033). |
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using StellaOps.Doctor.Models;
|
||||
using StellaOps.Doctor.Plugins;
|
||||
using StellaOps.Doctor.Plugins.Attestation.Configuration;
|
||||
|
||||
@@ -12,6 +12,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StellaOps.Doctor.Models;
|
||||
using StellaOps.Doctor.Plugins;
|
||||
using StellaOps.Doctor.Plugins.Builders;
|
||||
|
||||
namespace StellaOps.Doctor.Plugins.Integration.Checks;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StellaOps.Doctor.Models;
|
||||
using StellaOps.Doctor.Plugins;
|
||||
using StellaOps.Doctor.Plugins.Builders;
|
||||
|
||||
namespace StellaOps.Doctor.Plugins.Integration.Checks;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StellaOps.Doctor.Models;
|
||||
using StellaOps.Doctor.Plugins;
|
||||
using StellaOps.Doctor.Plugins.Builders;
|
||||
|
||||
namespace StellaOps.Doctor.Plugins.Integration.Checks;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using StellaOps.Doctor.Models;
|
||||
using StellaOps.Doctor.Plugins;
|
||||
using StellaOps.Doctor.Plugins.Builders;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using StellaOps.Doctor.Models;
|
||||
using StellaOps.Doctor.Plugins;
|
||||
using StellaOps.Doctor.Plugins.Builders;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using StellaOps.Doctor.Models;
|
||||
using StellaOps.Doctor.Plugins;
|
||||
using StellaOps.Doctor.Plugins.Builders;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using StellaOps.Doctor.Models;
|
||||
using StellaOps.Doctor.Plugins;
|
||||
using StellaOps.Doctor.Plugins.Builders;
|
||||
|
||||
Reference in New Issue
Block a user