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:
parent
b1d515c929
commit
fbc5769b74
@ -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):
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user