From 37cb6cee94ffe294e7d02c7d252bcfb252179177 Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Wed, 31 May 2023 23:09:08 +0000 Subject: [PATCH] SecretsManager - update_secret() now supports the Description-parameter (#6352) --- moto/secretsmanager/models.py | 3 ++- moto/secretsmanager/responses.py | 2 ++ tests/test_secretsmanager/test_secretsmanager.py | 8 +++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/moto/secretsmanager/models.py b/moto/secretsmanager/models.py index 53d049ef0..2d5c572d0 100644 --- a/moto/secretsmanager/models.py +++ b/moto/secretsmanager/models.py @@ -352,6 +352,7 @@ class SecretsManagerBackend(BaseBackend): secret_binary: Optional[str] = None, client_request_token: Optional[str] = None, kms_key_id: Optional[str] = None, + description: Optional[str] = None, ) -> str: # error if secret does not exist @@ -366,7 +367,7 @@ class SecretsManagerBackend(BaseBackend): secret = self.secrets[secret_id] tags = secret.tags - description = secret.description + description = description or secret.description secret = self._add_secret( secret_id, diff --git a/moto/secretsmanager/responses.py b/moto/secretsmanager/responses.py index 3fa1e3983..d5bff4bce 100644 --- a/moto/secretsmanager/responses.py +++ b/moto/secretsmanager/responses.py @@ -71,6 +71,7 @@ class SecretsManagerResponse(BaseResponse): secret_id = self._get_param("SecretId") secret_string = self._get_param("SecretString") secret_binary = self._get_param("SecretBinary") + description = self._get_param("Description") client_request_token = self._get_param("ClientRequestToken") kms_key_id = self._get_param("KmsKeyId", if_none=None) return self.backend.update_secret( @@ -79,6 +80,7 @@ class SecretsManagerResponse(BaseResponse): secret_binary=secret_binary, client_request_token=client_request_token, kms_key_id=kms_key_id, + description=description, ) def get_random_password(self) -> str: diff --git a/tests/test_secretsmanager/test_secretsmanager.py b/tests/test_secretsmanager/test_secretsmanager.py index f2f78ec22..66a921dc2 100644 --- a/tests/test_secretsmanager/test_secretsmanager.py +++ b/tests/test_secretsmanager/test_secretsmanager.py @@ -1346,7 +1346,11 @@ def test_update_secret(pass_arn): secret = conn.get_secret_value(SecretId=secret_id) 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["Name"] == "test-secret" @@ -1356,6 +1360,8 @@ def test_update_secret(pass_arn): assert secret["SecretString"] == "barsecret" assert created_secret["VersionId"] != updated_secret["VersionId"] + assert conn.describe_secret(SecretId=secret_id)["Description"] == "new desc" + @mock_secretsmanager @pytest.mark.parametrize("pass_arn", [True, False])