diff --git a/moto/secretsmanager/models.py b/moto/secretsmanager/models.py index f7cb855eb..b46e04d6c 100644 --- a/moto/secretsmanager/models.py +++ b/moto/secretsmanager/models.py @@ -46,7 +46,7 @@ class SecretsManagerBackend(BaseBackend): def get_secret_value(self, secret_id, version_id, version_stage): if not self._is_valid_identifier(secret_id): - raise ResourceNotFoundException("Secrets Manager can't find the specified secret") + raise ResourceNotFoundException("Secrets Manager can’t find the specified secret.") if not version_id and version_stage: # set version_id to match version_stage @@ -56,7 +56,7 @@ class SecretsManagerBackend(BaseBackend): version_id = ver_id break if not version_id: - raise ResourceNotFoundException("Secrets Manager can't find the specified secret") + raise ResourceNotFoundException("Secrets Manager can’t find the specified secret.") # TODO check this part if 'deleted_date' in self.secrets[secret_id]: @@ -175,7 +175,7 @@ class SecretsManagerBackend(BaseBackend): def describe_secret(self, secret_id): if not self._is_valid_identifier(secret_id): - raise ResourceNotFoundException("Secrets Manager can't find the specified secret") + raise ResourceNotFoundException("Secrets Manager can’t find the specified secret.") secret = self.secrets[secret_id] @@ -204,7 +204,7 @@ class SecretsManagerBackend(BaseBackend): rotation_days = 'AutomaticallyAfterDays' if not self._is_valid_identifier(secret_id): - raise ResourceNotFoundException("Secrets Manager can't find the specified secret") + raise ResourceNotFoundException("Secrets Manager can’t find the specified secret.") if 'deleted_date' in self.secrets[secret_id]: raise InvalidRequestException( @@ -346,7 +346,7 @@ class SecretsManagerBackend(BaseBackend): def delete_secret(self, secret_id, recovery_window_in_days, force_delete_without_recovery): if not self._is_valid_identifier(secret_id): - raise ResourceNotFoundException("Secrets Manager can't find the specified secret") + raise ResourceNotFoundException("Secrets Manager can’t find the specified secret.") if 'deleted_date' in self.secrets[secret_id]: raise InvalidRequestException( @@ -376,7 +376,7 @@ class SecretsManagerBackend(BaseBackend): secret = self.secrets.get(secret_id, None) if not secret: - raise ResourceNotFoundException("Secrets Manager can't find the specified secret") + raise ResourceNotFoundException("Secrets Manager can’t find the specified secret.") arn = secret_arn(self.region, secret['secret_id']) name = secret['name'] @@ -386,7 +386,7 @@ class SecretsManagerBackend(BaseBackend): def restore_secret(self, secret_id): if not self._is_valid_identifier(secret_id): - raise ResourceNotFoundException("Secrets Manager can't find the specified secret") + raise ResourceNotFoundException("Secrets Manager can’t find the specified secret.") self.secrets[secret_id].pop('deleted_date', None) diff --git a/tests/test_secretsmanager/test_secretsmanager.py b/tests/test_secretsmanager/test_secretsmanager.py index b77fa70d0..7273b5c21 100644 --- a/tests/test_secretsmanager/test_secretsmanager.py +++ b/tests/test_secretsmanager/test_secretsmanager.py @@ -38,7 +38,11 @@ def test_get_secret_value_binary(): def test_get_secret_that_does_not_exist(): conn = boto3.client('secretsmanager', region_name='us-west-2') - with assert_raises(ClientError): + with assert_raises_regexp( + ClientError, + r"An error occurred \(ResourceNotFoundException\) when calling the GetSecretValue " + r"operation: Secrets Manager can’t find the specified secret." + ): result = conn.get_secret_value(SecretId='i-dont-exist') @@ -48,7 +52,11 @@ def test_get_secret_that_does_not_match(): create_secret = conn.create_secret(Name='java-util-test-password', SecretString="foosecret") - with assert_raises(ClientError): + with assert_raises_regexp( + ClientError, + r"An error occurred \(ResourceNotFoundException\) when calling the GetSecretValue " + r"operation: Secrets Manager can’t find the specified secret." + ): result = conn.get_secret_value(SecretId='i-dont-match') diff --git a/tests/test_secretsmanager/test_server.py b/tests/test_secretsmanager/test_server.py index 25fc1676b..a1491dc8f 100644 --- a/tests/test_secretsmanager/test_server.py +++ b/tests/test_secretsmanager/test_server.py @@ -49,7 +49,7 @@ def test_get_secret_that_does_not_exist(): "X-Amz-Target": "secretsmanager.GetSecretValue"}, ) json_data = json.loads(get_secret.data.decode("utf-8")) - assert json_data['message'] == "Secrets Manager can't find the specified secret" + assert json_data['message'] == "Secrets Manager can’t find the specified secret." assert json_data['__type'] == 'ResourceNotFoundException' @mock_secretsmanager @@ -70,7 +70,7 @@ def test_get_secret_that_does_not_match(): "X-Amz-Target": "secretsmanager.GetSecretValue"}, ) json_data = json.loads(get_secret.data.decode("utf-8")) - assert json_data['message'] == "Secrets Manager can't find the specified secret" + assert json_data['message'] == "Secrets Manager can’t find the specified secret." assert json_data['__type'] == 'ResourceNotFoundException' @mock_secretsmanager @@ -178,7 +178,7 @@ def test_describe_secret_that_does_not_exist(): ) json_data = json.loads(describe_secret.data.decode("utf-8")) - assert json_data['message'] == "Secrets Manager can't find the specified secret" + assert json_data['message'] == "Secrets Manager can’t find the specified secret." assert json_data['__type'] == 'ResourceNotFoundException' @mock_secretsmanager @@ -202,7 +202,7 @@ def test_describe_secret_that_does_not_match(): ) json_data = json.loads(describe_secret.data.decode("utf-8")) - assert json_data['message'] == "Secrets Manager can't find the specified secret" + assert json_data['message'] == "Secrets Manager can’t find the specified secret." assert json_data['__type'] == 'ResourceNotFoundException' @mock_secretsmanager @@ -303,7 +303,7 @@ def test_rotate_secret_that_does_not_exist(): ) json_data = json.loads(rotate_secret.data.decode("utf-8")) - assert json_data['message'] == "Secrets Manager can't find the specified secret" + assert json_data['message'] == "Secrets Manager can’t find the specified secret." assert json_data['__type'] == 'ResourceNotFoundException' @mock_secretsmanager @@ -327,7 +327,7 @@ def test_rotate_secret_that_does_not_match(): ) json_data = json.loads(rotate_secret.data.decode("utf-8")) - assert json_data['message'] == "Secrets Manager can't find the specified secret" + assert json_data['message'] == "Secrets Manager can’t find the specified secret." assert json_data['__type'] == 'ResourceNotFoundException' @mock_secretsmanager