fix(secrets-cli): degrade on malformed master-key source + topology note
This commit is contained in:
+21
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user