fix(audit): persist config audit rows written after the final save (DEP-1, MGT-1, TPL-3, WP1 task 1.4)
IAuditService.LogAsync only stages the row; every caller that audited after its last SaveChangesAsync, outside the configuration-command transaction, lost the row with the DI scope (rig: zero Disable/Enable/ Delete/DeployArtifacts rows, 16 Deploy rows for 62 deployments, one Create/Instance row for ids up to 3876). - New IAuditService.LogAndSaveAsync: stage + save, best-effort (logs and swallows any failure incl. cancellation, detaches the unsaved row). - DeploymentService (deploy/failed/reconciled/lifecycle + timeouts), ArtifactDeploymentService (DeployArtifacts now before the best-effort stamp, RetryArtifactDeployment, DeploySiteSecrets), InstanceService, AreaService, SiteService: post-save LogAsync -> LogAndSaveAsync. - ManagementActor: AuditAndSaveAsync for the non-configuration handlers (API keys, shared schemas, ES methods, data-connection move); move now audits the scrubbed public shape (MGT-4) so the fix does not start writing protocol credentials into AuditLogEntries. - HandleCreateInstance no longer stages a second Create row on top of InstanceService's own. Tests: real-context (SQLite) tests per family read the row back through a second context - DeploymentService, ArtifactDeploymentService, InstanceService, ManagementActor; each fails against the old code. Test projects gain a ConfigurationDatabase + EF Sqlite reference.
This commit is contained in:
@@ -334,9 +334,10 @@ public class SchemaLibraryHandlerTests : TestKit, IDisposable
|
||||
actor.Tell(envelope);
|
||||
|
||||
ExpectMsg<ManagementSuccess>(TimeSpan.FromSeconds(5));
|
||||
// LogAsync(user, action, entityType, entityId, entityName, afterState, ct):
|
||||
// entityId is the id ("5"), entityName is the resolved name ("Addr").
|
||||
_auditService.Received(1).LogAsync(
|
||||
// LogAndSaveAsync(user, action, entityType, entityId, entityName, afterState, ct):
|
||||
// entityId is the id ("5"), entityName is the resolved name ("Addr"). Saved, not
|
||||
// just staged: DeleteSharedSchema is not a configuration command (MGT-1).
|
||||
_auditService.Received(1).LogAndSaveAsync(
|
||||
Arg.Any<string>(), "Delete", "SharedSchema", "5", "Addr",
|
||||
Arg.Any<object?>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user