using System; using System.Collections.Generic; using System.IO; using System.Security.Cryptography.X509Certificates; using StellaOps.Scanner.Surface.Env; using StellaOps.Scanner.Surface.FS; using Xunit; namespace StellaOps.Scanner.WebService.Tests; public sealed class SurfaceCacheOptionsConfiguratorTests { [Fact] public void Configure_UsesSurfaceEnvironmentCacheRoot() { var cacheRoot = new DirectoryInfo(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"))); var settings = new SurfaceEnvironmentSettings( new Uri("https://surface.example"), "surface-cache", null, cacheRoot, 512, true, Array.Empty(), new SurfaceSecretsConfiguration("file", "tenant-b", "/etc/secrets", null, null, false), "tenant-b", new SurfaceTlsConfiguration(null, null, new X509Certificate2Collection())); var environment = new StubSurfaceEnvironment(settings); var configurator = new SurfaceCacheOptionsConfigurator(environment); var options = new SurfaceCacheOptions(); configurator.Configure(options); Assert.Equal(cacheRoot.FullName, options.RootDirectory); } private sealed class StubSurfaceEnvironment : ISurfaceEnvironment { public StubSurfaceEnvironment(SurfaceEnvironmentSettings settings) { Settings = settings; } public SurfaceEnvironmentSettings Settings { get; } public IReadOnlyDictionary RawVariables { get; } = new Dictionary(); } }