fix(secrets-ui): preserve metadata on rotate + audit unexpected mutation/reveal failures
This commit is contained in:
@@ -80,6 +80,44 @@ public class ConfirmDeleteModalTests : TestContext
|
||||
Assert.Empty(audit.Events);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConfirmDeleteModal_StoreFault_AuditsFailure_ShowsError_DoesNotThrow()
|
||||
{
|
||||
var store = new RecordingSecretStore
|
||||
{
|
||||
DeleteFault = new MasterKeyUnavailableException("KEK unavailable."),
|
||||
};
|
||||
var audit = new CapturingAuditWriter();
|
||||
Services.AddSingleton<ISecretStore>(store);
|
||||
Services.AddSingleton<IAuditWriter>(audit);
|
||||
|
||||
var name = new SecretName("db/primary");
|
||||
var auth = this.AddTestAuthorization();
|
||||
auth.SetAuthorized("carol");
|
||||
auth.SetPolicies(SecretsAuthorization.ManagePolicy);
|
||||
|
||||
bool deleted = false;
|
||||
var cut = RenderComponent<ConfirmDeleteModal>(p => p
|
||||
.Add(c => c.Visible, true)
|
||||
.Add(c => c.Name, name)
|
||||
.Add(c => c.OnDeleted, () => deleted = true));
|
||||
|
||||
// The click must not throw into the Blazor event pipeline.
|
||||
cut.Find("[data-testid=confirm-delete]").Click();
|
||||
|
||||
// OnDeleted not raised; a Failure audit recorded; an error surfaced.
|
||||
Assert.False(deleted);
|
||||
Assert.Single(audit.Events);
|
||||
AuditEvent evt = audit.Events[0];
|
||||
Assert.Equal("secret.delete", evt.Action);
|
||||
Assert.Equal(AuditOutcome.Failure, evt.Outcome);
|
||||
Assert.Equal("Secrets", evt.Category);
|
||||
Assert.Equal("db/primary", evt.Target);
|
||||
Assert.Equal("carol", evt.Actor);
|
||||
|
||||
Assert.NotEmpty(cut.FindAll("[data-testid=delete-error]"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConfirmDeleteModal_NotVisible_RendersNothing()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user