From e63fc08db2860cd6f6d830d8fd2eb1664f6d4aaa Mon Sep 17 00:00:00 2001 From: Guriido Date: Thu, 21 Apr 2022 20:27:12 +0900 Subject: [PATCH] fix idempotency on verify_email_identity endpoint (#5043) --- moto/ses/models.py | 3 ++- tests/test_ses/test_ses_boto3.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/moto/ses/models.py b/moto/ses/models.py index fd83e6927..1981f43dd 100644 --- a/moto/ses/models.py +++ b/moto/ses/models.py @@ -132,7 +132,8 @@ class SESBackend(BaseBackend): def verify_email_identity(self, address): _, address = parseaddr(address) - self.addresses.append(address) + if address not in self.addresses: + self.addresses.append(address) def verify_email_address(self, address): _, address = parseaddr(address) diff --git a/tests/test_ses/test_ses_boto3.py b/tests/test_ses/test_ses_boto3.py index fb7ddb525..58660b9bb 100644 --- a/tests/test_ses/test_ses_boto3.py +++ b/tests/test_ses/test_ses_boto3.py @@ -22,6 +22,18 @@ def test_verify_email_identity(): address.should.equal("test@example.com") +@mock_ses +def test_verify_email_identity_idempotency(): + conn = boto3.client("ses", region_name="us-east-1") + address = "test@example.com" + conn.verify_email_identity(EmailAddress=address) + conn.verify_email_identity(EmailAddress=address) + + identities = conn.list_identities() + address_list = identities["Identities"] + address_list.should.equal([address]) + + @mock_ses def test_verify_email_address(): conn = boto3.client("ses", region_name="us-east-1")