SecretsManager - update_secret() now supports the Description-parameter (#6352)

This commit is contained in:
Bert Blommers 2023-05-31 23:09:08 +00:00 committed by GitHub
parent 1a8060c70f
commit 37cb6cee94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -352,6 +352,7 @@ class SecretsManagerBackend(BaseBackend):
secret_binary: Optional[str] = None, secret_binary: Optional[str] = None,
client_request_token: Optional[str] = None, client_request_token: Optional[str] = None,
kms_key_id: Optional[str] = None, kms_key_id: Optional[str] = None,
description: Optional[str] = None,
) -> str: ) -> str:
# error if secret does not exist # error if secret does not exist
@ -366,7 +367,7 @@ class SecretsManagerBackend(BaseBackend):
secret = self.secrets[secret_id] secret = self.secrets[secret_id]
tags = secret.tags tags = secret.tags
description = secret.description description = description or secret.description
secret = self._add_secret( secret = self._add_secret(
secret_id, secret_id,

View File

@ -71,6 +71,7 @@ class SecretsManagerResponse(BaseResponse):
secret_id = self._get_param("SecretId") secret_id = self._get_param("SecretId")
secret_string = self._get_param("SecretString") secret_string = self._get_param("SecretString")
secret_binary = self._get_param("SecretBinary") secret_binary = self._get_param("SecretBinary")
description = self._get_param("Description")
client_request_token = self._get_param("ClientRequestToken") client_request_token = self._get_param("ClientRequestToken")
kms_key_id = self._get_param("KmsKeyId", if_none=None) kms_key_id = self._get_param("KmsKeyId", if_none=None)
return self.backend.update_secret( return self.backend.update_secret(
@ -79,6 +80,7 @@ class SecretsManagerResponse(BaseResponse):
secret_binary=secret_binary, secret_binary=secret_binary,
client_request_token=client_request_token, client_request_token=client_request_token,
kms_key_id=kms_key_id, kms_key_id=kms_key_id,
description=description,
) )
def get_random_password(self) -> str: def get_random_password(self) -> str:

View File

@ -1346,7 +1346,11 @@ def test_update_secret(pass_arn):
secret = conn.get_secret_value(SecretId=secret_id) secret = conn.get_secret_value(SecretId=secret_id)
assert secret["SecretString"] == "foosecret" assert secret["SecretString"] == "foosecret"
updated_secret = conn.update_secret(SecretId=secret_id, SecretString="barsecret") updated_secret = conn.update_secret(
SecretId=secret_id,
SecretString="barsecret",
Description="new desc",
)
assert updated_secret["ARN"] assert updated_secret["ARN"]
assert updated_secret["Name"] == "test-secret" assert updated_secret["Name"] == "test-secret"
@ -1356,6 +1360,8 @@ def test_update_secret(pass_arn):
assert secret["SecretString"] == "barsecret" assert secret["SecretString"] == "barsecret"
assert created_secret["VersionId"] != updated_secret["VersionId"] assert created_secret["VersionId"] != updated_secret["VersionId"]
assert conn.describe_secret(SecretId=secret_id)["Description"] == "new desc"
@mock_secretsmanager @mock_secretsmanager
@pytest.mark.parametrize("pass_arn", [True, False]) @pytest.mark.parametrize("pass_arn", [True, False])