Fix: SecretsManager - Added missing pop() override to get_secret_name… (#3057)

* Fix: SecretsManager - Added missing pop() override to get_secret_name_from_arn (#3056)

* Added test case for delete_secret_force_with_arn (#3057)

* Fixed lint for test_delete_secret_force_with_arn (#3057)
This commit is contained in:
Kristopher Chun 2020-06-10 00:54:03 -07:00 committed by GitHub
parent b1d515c929
commit fbc5769b74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -38,6 +38,10 @@ class SecretsStore(dict):
new_key = get_secret_name_from_arn(key)
return dict.__contains__(self, new_key)
def pop(self, key, *args, **kwargs):
new_key = get_secret_name_from_arn(key)
return super(SecretsStore, self).pop(new_key, *args, **kwargs)
class SecretsManagerBackend(BaseBackend):
def __init__(self, region_name=None, **kwargs):

View File

@ -211,6 +211,24 @@ def test_delete_secret_force():
result = conn.get_secret_value(SecretId="test-secret")
@mock_secretsmanager
def test_delete_secret_force_with_arn():
conn = boto3.client("secretsmanager", region_name="us-west-2")
create_secret = conn.create_secret(Name="test-secret", SecretString="foosecret")
result = conn.delete_secret(
SecretId=create_secret["ARN"], ForceDeleteWithoutRecovery=True
)
assert result["ARN"]
assert result["DeletionDate"] > datetime.fromtimestamp(1, pytz.utc)
assert result["Name"] == "test-secret"
with assert_raises(ClientError):
result = conn.get_secret_value(SecretId="test-secret")
@mock_secretsmanager
def test_delete_secret_that_does_not_exist():
conn = boto3.client("secretsmanager", region_name="us-west-2")