Resolve all high-severity architecture review findings

This commit is contained in:
Joseph Doherty
2026-09-09 16:13:58 -04:00
parent 8bfe65512e
commit 146a13238f
192 changed files with 3160 additions and 753 deletions
@@ -17,7 +17,7 @@ namespace ZB.MOM.WW.ScadaBridge.ManagementService.Tests;
/// </summary>
public class ApiMethodTraceAllCallsTests : TestKit, IDisposable
{
private readonly ServiceCollection _services = new();
private readonly ServiceCollection _services = new ServiceCollection().AddTestConfigurationTransaction();
private readonly IInboundApiRepository _apiRepo = Substitute.For<IInboundApiRepository>();
public ApiMethodTraceAllCallsTests()
@@ -0,0 +1,21 @@
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Services;
namespace Microsoft.Extensions.DependencyInjection;
internal static class ConfigurationTransactionTestExtensions
{
public static ServiceCollection AddTestConfigurationTransaction(this ServiceCollection services)
{
services.AddSingleton<IConfigurationCommandTransaction, RepositoryTransaction>();
services.AddScoped<ZB.MOM.WW.ScadaBridge.TemplateEngine.Services.AreaService>();
return services;
}
private sealed class RepositoryTransaction(IServiceScopeFactory scopes) : IConfigurationCommandTransaction
{
public async Task<object?> ExecuteAsync(Func<IServiceProvider, Task<object?>> operation)
{
using var scope = scopes.CreateScope();
return await operation(scope.ServiceProvider);
}
}
}
@@ -42,7 +42,7 @@ public class ManagementActorTests : TestKit, IDisposable
_templateRepo = Substitute.For<ITemplateEngineRepository>();
_auditService = Substitute.For<IAuditService>();
_services = new ServiceCollection();
_services = new ServiceCollection().AddTestConfigurationTransaction();
_services.AddScoped(_ => _templateRepo);
_services.AddScoped(_ => _auditService);
_services.AddScoped<InstanceService>();
@@ -32,6 +32,12 @@ public class RequiredRoleMatrixTests
private static readonly Dictionary<string, string[]?> Expected = new(StringComparer.OrdinalIgnoreCase)
{
// ---- Administrator-only -----------------------------------------------------
["CreateSmtpConfig"] = [Roles.Administrator],
["CreateSmsConfig"] = [Roles.Administrator],
["RenameNotificationList"] = [Roles.Designer],
["AddNotificationRecipient"] = [Roles.Designer],
["DeleteNotificationRecipient"] = [Roles.Designer],
["DeleteInstanceAttributeOverride"] = [Roles.Deployer],
["CreateSite"] = [Roles.Administrator],
["UpdateSite"] = [Roles.Administrator],
["DeleteSite"] = [Roles.Administrator],
@@ -37,7 +37,7 @@ public class RoleMappingValidationTests : TestKit, IDisposable
_securityRepo = Substitute.For<ISecurityRepository>();
_auditService = Substitute.For<IAuditService>();
_services = new ServiceCollection();
_services = new ServiceCollection().AddTestConfigurationTransaction();
_services.AddScoped(_ => _securityRepo);
_services.AddScoped(_ => _auditService);
}
@@ -33,7 +33,7 @@ public class SchemaLibraryHandlerTests : TestKit, IDisposable
_schemaRepo = Substitute.For<ISharedSchemaRepository>();
_auditService = Substitute.For<IAuditService>();
_services = new ServiceCollection();
_services = new ServiceCollection().AddTestConfigurationTransaction();
_services.AddScoped(_ => _schemaRepo);
_services.AddScoped(_ => _auditService);
}
@@ -26,7 +26,7 @@ public class SecretProjectionTests : TestKit, IDisposable
public SecretProjectionTests()
{
_auditService = Substitute.For<IAuditService>();
_services = new ServiceCollection();
_services = new ServiceCollection().AddTestConfigurationTransaction();
_services.AddScoped(_ => _auditService);
}
@@ -47,7 +47,7 @@ public class SecuredWriteHandlerTests : TestKit, IDisposable
_auditRepo = Substitute.For<IAuditLogRepository>();
_comms = new StubCommunicationService();
_services = new ServiceCollection();
_services = new ServiceCollection().AddTestConfigurationTransaction();
_services.AddScoped(_ => _siteRepo);
_services.AddScoped(_ => _securedWriteRepo);
_services.AddScoped(_ => _auditRepo);
@@ -25,7 +25,7 @@ public class TransportGateTests : TestKit, IDisposable
public TransportGateTests()
{
_importer = Substitute.For<IBundleImporter>();
_services = new ServiceCollection();
_services = new ServiceCollection().AddTestConfigurationTransaction();
_services.AddScoped(_ => _importer);
}