feat(kms): Implement file-backed key management commands and handlers
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled

- Added `kms export` and `kms import` commands to manage file-backed signing keys.
- Implemented `HandleKmsExportAsync` and `HandleKmsImportAsync` methods in CommandHandlers for exporting and importing key material.
- Introduced KmsPassphrasePrompt for secure passphrase input.
- Updated CLI architecture documentation to include new KMS commands.
- Enhanced unit tests for KMS export and import functionalities.
- Updated project references to include StellaOps.Cryptography.Kms library.
- Marked KMS interface implementation and CLI support tasks as DONE in the task board.
This commit is contained in:
master
2025-10-30 14:41:48 +02:00
parent a3822c88cd
commit 240e8ff25d
13 changed files with 697 additions and 107 deletions

View File

@@ -1,32 +1,59 @@
using System;
using System.CommandLine;
using System.IO;
using System.Threading;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using StellaOps.Cli.Configuration;
using StellaOps.Cli.Plugins;
using Xunit;
using System.Text.Json;
using System.Threading;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using StellaOps.Cli.Configuration;
using StellaOps.Cli.Plugins;
using StellaOps.Cli.Plugins.NonCore;
using StellaOps.Cli.Tests.Testing;
using Xunit;
namespace StellaOps.Cli.Tests.Plugins;
public sealed class CliCommandModuleLoaderTests
{
[Fact]
public void RegisterModules_LoadsNonCoreCommandsFromPlugin()
{
var options = new StellaOpsCliOptions();
var repoRoot = Path.GetFullPath(
Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", ".."));
options.Plugins.BaseDirectory = repoRoot;
options.Plugins.Directory = "plugins/cli";
options.Plugins.ManifestSearchPattern = "manifest.json";
var services = new ServiceCollection()
.AddSingleton(options)
.BuildServiceProvider();
[Fact]
public void RegisterModules_LoadsNonCoreCommandsFromPlugin()
{
using var temp = new TempDirectory();
var manifestDirectory = Path.Combine(temp.Path, "plugins", "cli");
Directory.CreateDirectory(manifestDirectory);
var assemblyPath = typeof(NonCoreCliCommandModule).Assembly.Location;
var manifestPath = Path.Combine(manifestDirectory, "noncore.manifest.json");
var manifestBody = new
{
schemaVersion = CliPluginManifest.CurrentSchemaVersion,
id = "stellaops.cli.plugins.noncore",
displayName = "NonCore CLI Commands",
version = "1.0.0",
requiresRestart = true,
entryPoint = new
{
type = "dotnet",
assembly = assemblyPath,
typeName = typeof(NonCoreCliCommandModule).FullName
}
};
File.WriteAllText(
manifestPath,
JsonSerializer.Serialize(manifestBody, new JsonSerializerOptions(JsonSerializerDefaults.Web) { WriteIndented = true }));
var options = new StellaOpsCliOptions();
options.Plugins.BaseDirectory = temp.Path;
options.Plugins.Directory = "plugins/cli";
options.Plugins.ManifestSearchPattern = "*.manifest.json";
options.Plugins.SearchPatterns.Clear();
options.Plugins.SearchPatterns.Add(Path.GetFileName(assemblyPath));
var services = new ServiceCollection()
.AddSingleton(options)
.BuildServiceProvider();
var logger = NullLoggerFactory.Instance.CreateLogger<CliCommandModuleLoader>();
var loader = new CliCommandModuleLoader(services, options, logger);