Secret filtering on fetch unit test is unclear
This passing test in SecretsManagerConfigurationProviderTests appears to be attempting a test on filtering:
[Test, CustomAutoData]
public void Secrets_can_be_filtered_out_via_options_on_fetching([...])
{
options.ListSecretsFilters = new List<Filter> { new Filter { Key = FilterNameStringType.Name, Values = new List<string> { testEntry.Name } } };
Mock.Get(secretsManager).Setup(p => p.ListSecretsAsync(It.Is<ListSecretsRequest>(request => request.Filters == options.ListSecretsFilters), It.IsAny<CancellationToken>())).ReturnsAsync(listSecretsResponse);
sut.Load();
Mock.Get(secretsManager).Verify(p => p.ListSecretsAsync(It.Is<ListSecretsRequest>(request => request.Filters == options.ListSecretsFilters), It.IsAny<CancellationToken>()));
Assert.That(sut.Get(testEntry.Name), Is.Null);
}
However removing the first line where the filters are set still yields a passing test:
// options.ListSecretsFilters = new List<Filter> { new Filter { Key = FilterNameStringType.Name, Values = new List<string> { testEntry.Name } } };
As does changing the final assert statement to a random key:
Assert.That(sut.Get("hello"), IsNull);
It appears that the only behavior being tested is that ListSecretsAsync() is being called when the request filters match the options list filters.
I honestly can't tell whether setting options.ListSecretsFilters is intended to omit results in the filter list or include them.
The documentation seems to say include, but asserting that the filtered value will be null appears to indicate the opposite.
Either way, the test doesn't appear check the intended behavior because sut.Get(testEntry.Name) always returns null.
Maybe I'm missing something, but it seems like a more useful test would be a check to see whether a filtered request does return the desired values.
Hi @davidchavezgrant, thank you for opening this issue. Right now I'm quite busy at work but I'll try to get back to you as soon as possible.