Moto secretsmanager 模拟一次不能模拟多个秘密对象

问题描述

我有一个方法我想测试它在多个秘密对象上调用 get_secret :

@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")

出现错误:botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets Manager can't find the specified secret

我是否错误地使用了moto?如何创建我的函数可以访问的两个秘密?

编辑

看来这个问题应该已经解决了。我好像还是有这个问题:https://github.com/spulec/moto/issues/1893

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)