fix(secrets-ui): preserve metadata on rotate + audit unexpected mutation/reveal failures
This commit is contained in:
@@ -20,6 +20,12 @@ public sealed class RecordingSecretStore : ISecretStore
|
||||
/// <summary>Delete calls (name + recorded actor), in call order.</summary>
|
||||
public IReadOnlyList<(SecretName Name, string? Actor)> Deletes => _deletes.ToArray();
|
||||
|
||||
/// <summary>When set, <see cref="UpsertAsync"/> throws this to drive the mutation-failure path.</summary>
|
||||
public Exception? UpsertFault { get; set; }
|
||||
|
||||
/// <summary>When set, <see cref="DeleteAsync"/> throws this to drive the mutation-failure path.</summary>
|
||||
public Exception? DeleteFault { get; set; }
|
||||
|
||||
/// <summary>Seeds a row so <see cref="GetAsync"/> and <see cref="ListAsync"/> can return it.</summary>
|
||||
/// <param name="row">The row to seed.</param>
|
||||
public void Seed(StoredSecret row) => _rows[row.Name.Value] = row;
|
||||
@@ -31,6 +37,11 @@ public sealed class RecordingSecretStore : ISecretStore
|
||||
/// <inheritdoc />
|
||||
public Task UpsertAsync(StoredSecret row, CancellationToken ct)
|
||||
{
|
||||
if (UpsertFault is not null)
|
||||
{
|
||||
throw UpsertFault;
|
||||
}
|
||||
|
||||
_rows[row.Name.Value] = row;
|
||||
_upserts.Enqueue(row);
|
||||
return Task.CompletedTask;
|
||||
@@ -39,6 +50,11 @@ public sealed class RecordingSecretStore : ISecretStore
|
||||
/// <inheritdoc />
|
||||
public Task<bool> DeleteAsync(SecretName name, string? actor, CancellationToken ct)
|
||||
{
|
||||
if (DeleteFault is not null)
|
||||
{
|
||||
throw DeleteFault;
|
||||
}
|
||||
|
||||
_deletes.Enqueue((name, actor));
|
||||
return Task.FromResult(_rows.TryRemove(name.Value, out _));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user