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

SecretsManager List Secrets Filter with Key all deviated from boto3 #8421

Closed
obsidian33 opened this issue Dec 20, 2024 · 1 comment · Fixed by #8469
Closed

SecretsManager List Secrets Filter with Key all deviated from boto3 #8421

obsidian33 opened this issue Dec 20, 2024 · 1 comment · Fixed by #8469
Labels

Comments

@obsidian33
Copy link

How to reproduce

@pytest.fixture
def secretsmanager_client():
  with mock_aws():
    yield boto3.client("secretsmanager", region_name="us-east-1")
    
def test_list_secrets(secretsmanager_client):
  secretsmanager_client.create_secret(Name="ThisTestSecret")
  secretsmanager_client.create_secret(Name="RealSecret")
  secretsmanager_client.create_secret(Name="NexttestSecret")
  
  response = secretsmanager_client.list_secrets(
    Filters=[{"Key": "all", "Values": ["test"]}]
  )

With the Filter using the Key of all boto3 documentation states:

Breaks the filter value string into words and then searches all attributes for matches. Not case-sensitive.

The response from moto returns zero results ('SecretList': []) when it should return two secret objects with the Names: ThisTestSecret and NexttestSecret.

I've tested this against an AWS environment and boto3 works as described and does return the expected results.

Versions

Installed using poetry:

  • moto v5.0.24
  • boto3 v1.35.83
@bblommers
Copy link
Collaborator

Hi @obsidian33, thanks for raising this.

Breaks the filter value string into words

It took me some time to figure this out, but I think that AWS determines words by splitting values that are upper-cased.

  • ThisTestSecret is split into three words, This, Test and Secret.
  • Nexttestsecret will be broken down into two words, Nexttest and Secret.

When I execute your example against AWS, it only returns ThisTestSecret. I'm assuming that's because of a typo, and you meant NextTestSecret? That splits into Next, Test and Secret, so that would be found by AWS.

Moto currently doesn't do the word break correctly, we only break words that are separated by a space, so I'll mark this as a bug.

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

Successfully merging a pull request may close this issue.

2 participants