fix(secrets-cli): degrade on malformed master-key source + topology note

This commit is contained in:
Joseph Doherty
2026-07-19 09:08:24 -04:00
parent 83af2b2eaf
commit 9bc1e5852e
2 changed files with 36 additions and 0 deletions
@@ -95,6 +95,27 @@ public sealed class SecretsSessionFactoryTests : IDisposable
Assert.Empty(list);
}
[Fact]
public async Task Opens_degraded_session_when_master_key_source_is_out_of_range()
{
StoreTarget target = new TargetConfigReader().Manual(DbPath, new MasterKeyOptions
{
Source = (MasterKeySource)999,
});
SecretsSession session =
await new SecretsSessionFactory().OpenAsync(target, overrideKek: null, CancellationToken.None);
Assert.False(session.KekAvailable);
Assert.Null(session.Cipher);
Assert.NotEmpty(session.Warnings);
Assert.Contains(session.Warnings, w => w.Contains("999", StringComparison.Ordinal));
// Store is still usable despite the malformed KEK source.
IReadOnlyList<SecretMetadata> list = await session.Store.ListAsync(includeDeleted: false, CancellationToken.None);
Assert.Empty(list);
}
[Fact]
public async Task Override_kek_upgrades_degraded_session()
{