Files
git.stella-ops.org/src/Scanner/__Tests/StellaOps.Scanner.Surface.Secrets.Tests/FileSurfaceSecretProviderTests.cs
master f98cea3bcf Add Authority Advisory AI and API Lifecycle Configuration
- Introduced AuthorityAdvisoryAiOptions and related classes for managing advisory AI configurations, including remote inference options and tenant-specific settings.
- Added AuthorityApiLifecycleOptions to control API lifecycle settings, including legacy OAuth endpoint configurations.
- Implemented validation and normalization methods for both advisory AI and API lifecycle options to ensure proper configuration.
- Created AuthorityNotificationsOptions and its related classes for managing notification settings, including ack tokens, webhooks, and escalation options.
- Developed IssuerDirectoryClient and related models for interacting with the issuer directory service, including caching mechanisms and HTTP client configurations.
- Added support for dependency injection through ServiceCollectionExtensions for the Issuer Directory Client.
- Updated project file to include necessary package references for the new Issuer Directory Client library.
2025-11-02 13:50:25 +02:00

48 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.IO;
using System.Text.Json;
using StellaOps.Scanner.Surface.Secrets;
using StellaOps.Scanner.Surface.Secrets.Providers;
namespace StellaOps.Scanner.Surface.Secrets.Tests;
public sealed class FileSurfaceSecretProviderTests
{
[Fact]
public async Task GetAsync_ReturnsSecret_FromJson()
{
var rootDirectory = Directory.CreateTempSubdirectory();
var root = rootDirectory.FullName;
var request = new SurfaceSecretRequest("tenant", "component", "registry");
var path = Path.Combine(root, request.Tenant, request.Component, request.SecretType);
Directory.CreateDirectory(path);
var payloadPath = Path.Combine(path, "default.json");
await File.WriteAllTextAsync(payloadPath, JsonSerializer.Serialize(new
{
Payload = Convert.ToBase64String(new byte[] { 10, 20, 30 }),
Metadata = new Dictionary<string, string> { ["username"] = "demo" }
}));
try
{
var provider = new FileSurfaceSecretProvider(root);
var handle = await provider.GetAsync(request);
try
{
Assert.Equal(new byte[] { 10, 20, 30 }, handle.AsBytes().ToArray());
Assert.Equal("demo", handle.Metadata["username"]);
}
finally
{
handle.Dispose();
}
}
finally
{
rootDirectory.Delete(true);
}
}
}