Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secret filtering on fetch unit test is unclear #65

Open
davidchavezgrant opened this issue Apr 20, 2022 · 1 comment
Open

Secret filtering on fetch unit test is unclear #65

davidchavezgrant opened this issue Apr 20, 2022 · 1 comment
Assignees

Comments

@davidchavezgrant
Copy link

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.

@Kralizek Kralizek self-assigned this Apr 20, 2022
@Kralizek
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants