fix(deployment): drop unused INotificationRepository from ArtifactDeploymentService (review 2026-10-21 04/U4)

This commit is contained in:
Joseph Doherty
2026-10-22 06:28:58 -04:00
parent 7c83a4aa94
commit 58b1e021b2
5 changed files with 23 additions and 26 deletions
@@ -50,7 +50,6 @@ public class SitesPageTests : BunitContext
Substitute.For<IDeploymentManagerRepository>(),
Substitute.For<ITemplateEngineRepository>(),
Substitute.For<IExternalSystemRepository>(),
Substitute.For<INotificationRepository>(),
comms,
Substitute.For<IAuditService>(),
Options.Create(new DeploymentManagerOptions()),
@@ -26,7 +26,6 @@ public class ArtifactDeploymentServiceTests : TestKit
private readonly IDeploymentManagerRepository _deploymentRepo;
private readonly ITemplateEngineRepository _templateRepo;
private readonly IExternalSystemRepository _externalSystemRepo;
private readonly INotificationRepository _notificationRepo;
private readonly IAuditService _audit;
private readonly ArtifactRevisionHashService _hashService = new();
private readonly ISecretStore _secretStore;
@@ -41,7 +40,6 @@ public class ArtifactDeploymentServiceTests : TestKit
// The notification repo is retained only so the
// tests can assert the artifact path NEVER touches it (it is no longer a
// constructor dependency of ArtifactDeploymentService).
_notificationRepo = Substitute.For<INotificationRepository>();
_audit = Substitute.For<IAuditService>();
// Unconfigured GetAsync returns null (NSubstitute default), i.e. "not in the store" —
// exactly the fail-closed posture a test wants unless it explicitly seeds a row.
@@ -208,11 +206,10 @@ public class ArtifactDeploymentServiceTests : TestKit
await _templateRepo.Received(1).GetAllSharedScriptsAsync(Arg.Any<CancellationToken>());
await _externalSystemRepo.Received(1).GetAllExternalSystemsAsync(Arg.Any<CancellationToken>());
await _externalSystemRepo.Received(1).GetAllDatabaseConnectionsAsync(Arg.Any<CancellationToken>());
// Notification lists and SMTP configuration are
// central-only — the artifact path must NEVER fetch them, and the per-site
// command must NEVER carry them.
await _notificationRepo.DidNotReceive().GetAllNotificationListsAsync(Arg.Any<CancellationToken>());
await _notificationRepo.DidNotReceive().GetAllSmtpConfigurationsAsync(Arg.Any<CancellationToken>());
// Notification lists and SMTP configuration are central-only — the service has no
// notification repository at all (see
// Constructor_TakesNoNotificationRepository), and the per-site command must NEVER
// carry them.
Assert.All(recorder.Received, cmd =>
{
Assert.Null(cmd.NotificationLists);
@@ -278,9 +275,7 @@ public class ArtifactDeploymentServiceTests : TestKit
await _templateRepo.Received(1).GetAllSharedScriptsAsync(Arg.Any<CancellationToken>());
await _externalSystemRepo.Received(1).GetAllExternalSystemsAsync(Arg.Any<CancellationToken>());
await _externalSystemRepo.Received(1).GetAllDatabaseConnectionsAsync(Arg.Any<CancellationToken>());
// Central-only — never fetched, never shipped.
await _notificationRepo.DidNotReceive().GetAllNotificationListsAsync(Arg.Any<CancellationToken>());
await _notificationRepo.DidNotReceive().GetAllSmtpConfigurationsAsync(Arg.Any<CancellationToken>());
// Central-only — never fetched (no notification repository), never shipped.
Assert.All(recorder.Received, cmd =>
{
Assert.Null(cmd.NotificationLists);
@@ -1105,6 +1100,21 @@ public class ArtifactDeploymentServiceTests : TestKit
Assert.DoesNotContain("Ciphertext", json, StringComparison.OrdinalIgnoreCase);
}
/// <summary>
/// review 2026-10-21 04/U4: notification lists and SMTP configs are central-only and never
/// shipped, so the service must not depend on the notification repository at all — a
/// dead DI edge kept a spurious DeploymentManager→Notification dependency alive.
/// </summary>
[Fact]
public void Constructor_TakesNoNotificationRepository()
{
var parameterTypes = typeof(ArtifactDeploymentService).GetConstructors()
.SelectMany(c => c.GetParameters())
.Select(p => p.ParameterType);
Assert.DoesNotContain(typeof(INotificationRepository), parameterTypes);
}
private ArtifactDeploymentService CreateService(ILogger<ArtifactDeploymentService>? logger = null)
{
var comms = new CommunicationService(
@@ -1112,7 +1122,7 @@ public class ArtifactDeploymentServiceTests : TestKit
NullLogger<CommunicationService>.Instance);
return new ArtifactDeploymentService(
_siteRepo, _deploymentRepo, _templateRepo, _externalSystemRepo, _notificationRepo,
_siteRepo, _deploymentRepo, _templateRepo, _externalSystemRepo,
comms, _audit,
Options.Create(new DeploymentManagerOptions()),
logger ?? NullLogger<ArtifactDeploymentService>.Instance,
@@ -1132,7 +1142,7 @@ public class ArtifactDeploymentServiceTests : TestKit
comms.SetCommunicationActor(commActor);
return new ArtifactDeploymentService(
_siteRepo, _deploymentRepo, _templateRepo, _externalSystemRepo, _notificationRepo,
_siteRepo, _deploymentRepo, _templateRepo, _externalSystemRepo,
comms, _audit,
Options.Create(new DeploymentManagerOptions
{
@@ -39,7 +39,6 @@ public class PendingUpdatesEvaluatorTests
private readonly ISiteRepository _siteRepo = Substitute.For<ISiteRepository>();
private readonly ITemplateEngineRepository _templateRepo = Substitute.For<ITemplateEngineRepository>();
private readonly IExternalSystemRepository _externalSystemRepo = Substitute.For<IExternalSystemRepository>();
private readonly INotificationRepository _notificationRepo = Substitute.For<INotificationRepository>();
private readonly IDeploymentManagerRepository _deploymentRepo = Substitute.For<IDeploymentManagerRepository>();
private readonly IFlatteningPipeline _pipeline = Substitute.For<IFlatteningPipeline>();
private readonly IAuditService _audit = Substitute.For<IAuditService>();
@@ -63,7 +62,7 @@ public class PendingUpdatesEvaluatorTests
NullLogger<CommunicationService>.Instance);
_artifactService = new ArtifactDeploymentService(
_siteRepo, _deploymentRepo, _templateRepo, _externalSystemRepo, _notificationRepo,
_siteRepo, _deploymentRepo, _templateRepo, _externalSystemRepo,
comms, _audit,
Options.Create(new DeploymentManagerOptions()),
NullLogger<ArtifactDeploymentService>.Instance,
@@ -81,7 +81,6 @@ public class ManagementActorTests : TestKit, IDisposable
Substitute.For<IDeploymentManagerRepository>(),
Substitute.For<ITemplateEngineRepository>(),
Substitute.For<IExternalSystemRepository>(),
Substitute.For<INotificationRepository>(),
comms,
Substitute.For<IAuditService>(),
Options.Create(new DeploymentManagerOptions()),