chore(host): remove unused Database:MachineDataDb option, validation, config and docs
This commit is contained in:
@@ -29,7 +29,7 @@ public class CentralActorPathTests : IAsyncLifetime
|
||||
_previousEnv = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT");
|
||||
Environment.SetEnvironmentVariable("DOTNET_ENVIRONMENT", "Central");
|
||||
|
||||
// Supply the pepper, MachineDataDb and the G-4 secret-backed keys
|
||||
// Supply the pepper 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
|
||||
|
||||
@@ -100,7 +100,7 @@ public class CentralAuditWiringTests : IDisposable
|
||||
_previousEnv = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT");
|
||||
Environment.SetEnvironmentVariable("DOTNET_ENVIRONMENT", "Central");
|
||||
|
||||
// Supply the pepper, MachineDataDb and the G-4 secret-backed keys
|
||||
// Supply the pepper 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
|
||||
|
||||
@@ -12,11 +12,6 @@ namespace ZB.MOM.WW.ScadaBridge.Host.Tests;
|
||||
/// StartupValidator preflight (added in 1fcc4f5) does not fail for tests that set
|
||||
/// <c>DOTNET_ENVIRONMENT=Central</c> without an explicit pepper env var.
|
||||
///
|
||||
/// Also supplies <c>ScadaBridge__Database__MachineDataDb</c> so the Central-role
|
||||
/// StartupValidator preflight (a missing MachineDataDb setting) does not
|
||||
/// fail for tests that set <c>DOTNET_ENVIRONMENT=Central</c> without an explicit
|
||||
/// MachineDataDb env var.
|
||||
///
|
||||
/// G-4 (secrets adoption): <c>appsettings.Central.json</c> now carries
|
||||
/// <c>${secret:...}</c> references for the ConfigurationDb connection string, the
|
||||
/// LDAP service-account password and the JWT signing key. The pre-host secrets
|
||||
@@ -44,11 +39,6 @@ internal sealed class CentralDbTestEnvironment : IDisposable
|
||||
|
||||
private const string ConfigKey = "ScadaBridge__Database__ConfigurationDb";
|
||||
|
||||
private const string MachineDataDb =
|
||||
"Server=localhost,1433;Database=ScadaBridgeMachineData;User Id=scadabridge_app;Password=ScadaBridge_Dev1#;TrustServerCertificate=true";
|
||||
|
||||
private const string MachineDataKey = "ScadaBridge__Database__MachineDataDb";
|
||||
|
||||
// Test-only pepper — satisfies the ≥16-char StartupValidator requirement without
|
||||
// committing a real secret. The env-var name uses the double-underscore delimiter
|
||||
// so AddEnvironmentVariables() maps it to ScadaBridge:InboundApi:ApiKeyPepper.
|
||||
@@ -67,7 +57,6 @@ internal sealed class CentralDbTestEnvironment : IDisposable
|
||||
private const string JwtSigningKeyKey = "ScadaBridge__Security__JwtSigningKey";
|
||||
|
||||
private readonly string? _previousConfig;
|
||||
private readonly string? _previousMachineData;
|
||||
private readonly string? _previousPepper;
|
||||
private readonly string? _previousLdapPassword;
|
||||
private readonly string? _previousJwtSigningKey;
|
||||
@@ -95,9 +84,6 @@ internal sealed class CentralDbTestEnvironment : IDisposable
|
||||
_previousConfig = Environment.GetEnvironmentVariable(ConfigKey);
|
||||
Environment.SetEnvironmentVariable(ConfigKey, ConfigurationDb);
|
||||
|
||||
_previousMachineData = Environment.GetEnvironmentVariable(MachineDataKey);
|
||||
Environment.SetEnvironmentVariable(MachineDataKey, MachineDataDb);
|
||||
|
||||
_previousPepper = Environment.GetEnvironmentVariable(PepperKey);
|
||||
Environment.SetEnvironmentVariable(PepperKey, TestPepper);
|
||||
|
||||
@@ -112,7 +98,6 @@ internal sealed class CentralDbTestEnvironment : IDisposable
|
||||
public void Dispose()
|
||||
{
|
||||
Environment.SetEnvironmentVariable(ConfigKey, _previousConfig);
|
||||
Environment.SetEnvironmentVariable(MachineDataKey, _previousMachineData);
|
||||
Environment.SetEnvironmentVariable(PepperKey, _previousPepper);
|
||||
Environment.SetEnvironmentVariable(LdapPasswordKey, _previousLdapPassword);
|
||||
Environment.SetEnvironmentVariable(JwtSigningKeyKey, _previousJwtSigningKey);
|
||||
|
||||
@@ -96,7 +96,7 @@ public class CentralCompositionRootTests : IDisposable
|
||||
_previousEnv = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT");
|
||||
Environment.SetEnvironmentVariable("DOTNET_ENVIRONMENT", "Central");
|
||||
|
||||
// Supply the pepper, MachineDataDb and the G-4 secret-backed keys
|
||||
// Supply the pepper 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
|
||||
|
||||
@@ -20,7 +20,6 @@ public class StartupValidatorTests
|
||||
["ScadaBridge:Node:NodeHostname"] = "central-node1",
|
||||
["ScadaBridge:Node:RemotingPort"] = "8081",
|
||||
["ScadaBridge:Database:ConfigurationDb"] = "Server=localhost;Database=Config;",
|
||||
["ScadaBridge:Database:MachineDataDb"] = "Server=localhost;Database=MachineData;",
|
||||
["ScadaBridge:Security:Ldap:Server"] = "ldap.example.com",
|
||||
["ScadaBridge:Security:JwtSigningKey"] = "test-signing-key-at-least-32-chars-long",
|
||||
["ScadaBridge:Cluster:SeedNodes:0"] = "akka.tcp://scadabridge@central-node1:8081",
|
||||
@@ -303,24 +302,6 @@ public class StartupValidatorTests
|
||||
Assert.Contains("ConfigurationDb connection string required for Central", ex.Message);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a central node missing machine data database fails validation.</summary>
|
||||
/// <returns>The result.</returns>
|
||||
[Fact]
|
||||
public void Central_MissingMachineDataDb_FailsValidation()
|
||||
{
|
||||
// The host requirements require MachineDataDb to be
|
||||
// validated at startup for Central nodes, and the shipped docker appsettings
|
||||
// (docker/central-node-a/appsettings.Central.json and central-node-b) carry
|
||||
// the key. The earlier decision (which removed the Require) is reversed
|
||||
// here: a missing MachineDataDb must fail fast with a clear error.
|
||||
var values = ValidCentralConfig();
|
||||
values.Remove("ScadaBridge:Database:MachineDataDb");
|
||||
var config = BuildConfig(values);
|
||||
|
||||
var ex = Assert.Throws<InvalidOperationException>(() => StartupValidator.Validate(config));
|
||||
Assert.Contains("MachineDataDb connection string required for Central", ex.Message);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a central node missing LDAP server fails validation.</summary>
|
||||
/// <returns>The result.</returns>
|
||||
[Fact]
|
||||
|
||||
@@ -40,7 +40,6 @@ public class ScadaBridgeWebApplicationFactory : WebApplicationFactory<Program>
|
||||
["ScadaBridge__Cluster__SeedNodes__0"] = "akka.tcp://scadabridge@localhost:8081",
|
||||
["ScadaBridge__Cluster__SeedNodes__1"] = "akka.tcp://scadabridge@localhost:8082",
|
||||
["ScadaBridge__Database__ConfigurationDb"] = "Server=localhost;Database=ScadaBridge_Test;TrustServerCertificate=True",
|
||||
["ScadaBridge__Database__MachineDataDb"] = "Server=localhost;Database=ScadaBridge_MachineData_Test;TrustServerCertificate=True",
|
||||
["ScadaBridge__Database__SkipMigrations"] = "true",
|
||||
["ScadaBridge__Security__JwtSigningKey"] = "integration-test-signing-key-must-be-at-least-32-chars-long",
|
||||
// The inbound API-key pepper is a REQUIRED Central config value (StartupValidator
|
||||
|
||||
@@ -48,7 +48,6 @@ public class StartupValidationTests
|
||||
["ScadaBridge__Cluster__SeedNodes__0"] = "akka.tcp://scadabridge@localhost:8081",
|
||||
["ScadaBridge__Cluster__SeedNodes__1"] = "akka.tcp://scadabridge@localhost:8082",
|
||||
["ScadaBridge__Database__ConfigurationDb"] = "Server=x;Database=x",
|
||||
["ScadaBridge__Database__MachineDataDb"] = "Server=x;Database=x",
|
||||
["ScadaBridge__Security__Ldap__Server"] = "localhost",
|
||||
// Deliberately missing JwtSigningKey
|
||||
});
|
||||
@@ -92,7 +91,6 @@ public class StartupValidationTests
|
||||
"ScadaBridge__Cluster__SeedNodes__0",
|
||||
"ScadaBridge__Cluster__SeedNodes__1",
|
||||
"ScadaBridge__Database__ConfigurationDb",
|
||||
"ScadaBridge__Database__MachineDataDb",
|
||||
"ScadaBridge__Database__SkipMigrations",
|
||||
"ScadaBridge__Security__JwtSigningKey",
|
||||
"ScadaBridge__Security__Ldap__Server",
|
||||
|
||||
Reference in New Issue
Block a user