fix(configuration-database): resolve ConfigurationDatabase-002..007 — remove hardcoded sa creds, fail-fast no-arg DI, encrypt secret columns, resilient audit serialization

This commit is contained in:
Joseph Doherty
2026-05-16 21:11:24 -04:00
parent 8fc04d43c2
commit 0c82ffcbe6
17 changed files with 2029 additions and 40 deletions

View File

@@ -372,15 +372,24 @@ public class ServiceRegistrationTests
}
[Fact]
public void AddConfigurationDatabase_NoArgs_DoesNotThrow()
public void AddConfigurationDatabase_NoArgs_FailsFast()
{
// ConfigurationDatabase-003: the no-arg overload previously silently registered
// nothing, which deferred a misconfiguration into an opaque DI failure later.
// It is now [Obsolete(error: true)] (compile-time guard) and throws at runtime.
// Invoked via reflection because the obsolete-error overload cannot be called
// directly from source.
var method = typeof(ServiceCollectionExtensions).GetMethod(
nameof(ServiceCollectionExtensions.AddConfigurationDatabase),
System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static,
binder: null,
types: new[] { typeof(IServiceCollection) },
modifiers: null)!;
var services = new ServiceCollection();
services.AddConfigurationDatabase();
// Should not register DbContext (no-op for backward compatibility)
var provider = services.BuildServiceProvider();
var context = provider.GetService<ScadaLinkDbContext>();
Assert.Null(context);
var invocation = Assert.Throws<System.Reflection.TargetInvocationException>(
() => method.Invoke(null, new object[] { services }));
Assert.IsType<InvalidOperationException>(invocation.InnerException);
}
}