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:
@@ -23,23 +23,19 @@ public class CentralActorPathTests : IAsyncLifetime
|
||||
private WebApplicationFactory<Program>? _factory;
|
||||
private ActorSystem? _actorSystem;
|
||||
private string? _previousEnv;
|
||||
private CentralDbTestEnvironment? _dbEnv;
|
||||
|
||||
public Task InitializeAsync()
|
||||
{
|
||||
_previousEnv = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT");
|
||||
Environment.SetEnvironmentVariable("DOTNET_ENVIRONMENT", "Central");
|
||||
|
||||
// Supply the pepper so the Central-role StartupValidator preflight (1fcc4f5)
|
||||
// passes before WebApplicationFactory gets a chance to overlay DI config.
|
||||
// The pre-host config builder includes AddEnvironmentVariables(), so this
|
||||
// env var is visible to StartupValidator.Validate() at Program.cs line 42.
|
||||
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 =>
|
||||
@@ -99,8 +95,7 @@ public class CentralActorPathTests : IAsyncLifetime
|
||||
{
|
||||
_factory?.Dispose();
|
||||
Environment.SetEnvironmentVariable("DOTNET_ENVIRONMENT", _previousEnv);
|
||||
Environment.SetEnvironmentVariable("ScadaBridge__InboundApi__ApiKeyPepper", null);
|
||||
Environment.SetEnvironmentVariable("ScadaBridge__Database__MachineDataDb", null);
|
||||
_dbEnv?.Dispose();
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user