using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using StellaOps.Cryptography.Plugin.EIDAS; using StellaOps.Cryptography.Plugin.EIDAS.Configuration; using StellaOps.Cryptography.Plugin.EIDAS.Models; namespace StellaOps.Cryptography.Tests; public sealed partial class EidasCapabilityDetectionTests { private static EidasCryptoProvider CreateProvider() { var services = new ServiceCollection(); services.Configure(options => { options.SignatureLevel = SignatureLevel.AdES; options.SignatureFormat = SignatureFormat.CAdES; options.DefaultAlgorithm = "ECDSA-P256"; options.DigestAlgorithm = "SHA256"; options.Local = new LocalSigningOptions { Type = "PKCS12", Path = "/tmp/test.p12", Password = "test" }; options.Tsp = new TspOptions { Endpoint = "https://tsp.example.com", ApiKey = "test-key" }; }); services.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Warning)); services.AddHttpClient(); services.AddSingleton(); services.AddSingleton(); var serviceProvider = services.BuildServiceProvider(); return serviceProvider.GetRequiredService(); } private static EidasCryptoProvider CreateProviderWithKey(string keyId) { var services = new ServiceCollection(); services.Configure(options => { options.SignatureLevel = SignatureLevel.AdES; options.SignatureFormat = SignatureFormat.CAdES; options.DefaultAlgorithm = "ECDSA-P256"; options.DigestAlgorithm = "SHA256"; options.Keys.Add(new EidasKeyConfig { KeyId = keyId, Source = "local" }); options.Local = new LocalSigningOptions { Type = "PKCS12", Path = "/tmp/test.p12", Password = "test" }; options.Tsp = new TspOptions { Endpoint = "https://tsp.example.com", ApiKey = "test-key" }; }); services.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Warning)); services.AddHttpClient(); services.AddSingleton(); services.AddSingleton(); var serviceProvider = services.BuildServiceProvider(); return serviceProvider.GetRequiredService(); } }