feat(secrets): switch Central config secrets to ${secret:} tokens (ScadaBridge G-4 T4)
Switch the three literal ${SCADABRIDGE_*} placeholders in appsettings.Central.json
to ${secret:} references resolved by the pre-host secrets expander, and update the
_secrets doc note. Fix Host.Tests fixtures that boot the real Program pipeline against
Central config: CentralDbTestEnvironment now also supplies the LDAP service-account
password and JWT signing key as whole-key env overrides (rollback path) so the expander
skips the tokens without a seeded store; the three fixtures that managed env vars
inline now use CentralDbTestEnvironment.
This commit is contained in:
@@ -84,22 +84,19 @@ public class CentralCompositionRootTests : IDisposable
|
||||
{
|
||||
private readonly WebApplicationFactory<Program> _factory;
|
||||
private readonly string? _previousEnv;
|
||||
private readonly CentralDbTestEnvironment _dbEnv;
|
||||
|
||||
public CentralCompositionRootTests()
|
||||
{
|
||||
_previousEnv = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT");
|
||||
Environment.SetEnvironmentVariable("DOTNET_ENVIRONMENT", "Central");
|
||||
|
||||
// Supply the pepper so the Central-role StartupValidator preflight (1fcc4f5)
|
||||
// passes. The pre-host config builder uses AddEnvironmentVariables(), which
|
||||
// runs before WithWebHostBuilder.ConfigureAppConfiguration applies DI config.
|
||||
Environment.SetEnvironmentVariable("ScadaBridge__InboundApi__ApiKeyPepper",
|
||||
CentralDbTestEnvironment.TestPepper);
|
||||
// Supply MachineDataDb so the reverted Host-008 Require (REQ-HOST-3/4, M2.9 #17)
|
||||
// passes for Central-role StartupValidator. A non-empty placeholder satisfies
|
||||
// the preflight; the DI override below replaces the real DbContext anyway.
|
||||
Environment.SetEnvironmentVariable("ScadaBridge__Database__MachineDataDb",
|
||||
"Server=localhost;Database=MachineData;");
|
||||
// Supply the pepper, MachineDataDb and the G-4 secret-backed keys
|
||||
// (ConfigurationDb / LDAP service-account password / JWT signing key) as
|
||||
// whole-key env overrides so the pre-host config builder — which calls
|
||||
// AddEnvironmentVariables() before the ${secret:...} expander runs — sees
|
||||
// concrete values and the Central-role StartupValidator preflight passes.
|
||||
_dbEnv = new CentralDbTestEnvironment();
|
||||
|
||||
_factory = new WebApplicationFactory<Program>()
|
||||
.WithWebHostBuilder(builder =>
|
||||
@@ -164,8 +161,7 @@ public class CentralCompositionRootTests : IDisposable
|
||||
{
|
||||
_factory.Dispose();
|
||||
Environment.SetEnvironmentVariable("DOTNET_ENVIRONMENT", _previousEnv);
|
||||
Environment.SetEnvironmentVariable("ScadaBridge__InboundApi__ApiKeyPepper", null);
|
||||
Environment.SetEnvironmentVariable("ScadaBridge__Database__MachineDataDb", null);
|
||||
_dbEnv.Dispose();
|
||||
}
|
||||
|
||||
// --- Singletons ---
|
||||
|
||||
Reference in New Issue
Block a user