Moto secretsmanager mock can't mock more than one secret object at a time

Viewed 2455

I have a method I want to test that calls get_secret on multiple secret objects:

@pytest.fixture(scope="session")
def client():
    conn = boto3.client("secretsmanager", region_name="us-west-1")
    yield conn


@mock_secretsmanager
def test_get_secret_value(client):
   client.create_secret(
       Name="one", SecretString="sdfsdf"
   )
   client.create_secret(
       Name="two", SecretString="werwewe"
   )
   # Function that gets value of 2 secrets- "one" and "two"
   # Only "two" will exist as the second call to create_secret() will override the first it seems
   mymodule.get_one_and_two("one","two")

I get an error: botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets Manager can't find the specified secret

Am I using moto incorrectly? How can I create two secrets that my function will have access to?

Edit

It looks like this issue was supposed to have been solved. I still seem to have this problem: https://github.com/spulec/moto/issues/1893

0 Answers
Related