From 7147c5f05aa9e509c60fcdab0236fc8382fd91ca Mon Sep 17 00:00:00 2001 From: Brian Pandola Date: Thu, 1 Jul 2021 21:28:41 -0700 Subject: [PATCH] SES domains are case-insensitive (#4050) --- moto/ses/models.py | 3 ++- tests/test_ses/test_ses_boto3.py | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/moto/ses/models.py b/moto/ses/models.py index f5ebcefc4..8c252cc08 100644 --- a/moto/ses/models.py +++ b/moto/ses/models.py @@ -137,7 +137,8 @@ class SESBackend(BaseBackend): self.email_addresses.append(address) def verify_domain(self, domain): - self.domains.append(domain) + if domain.lower() not in self.domains: + self.domains.append(domain.lower()) def list_identities(self): return self.domains + self.addresses diff --git a/tests/test_ses/test_ses_boto3.py b/tests/test_ses/test_ses_boto3.py index a3a273e85..de91b5522 100644 --- a/tests/test_ses/test_ses_boto3.py +++ b/tests/test_ses/test_ses_boto3.py @@ -8,7 +8,7 @@ from six.moves.email_mime_text import MIMEText import pytest -# import sure # noqa +import sure # noqa from moto import mock_ses @@ -598,3 +598,19 @@ def test_update_ses_template(): result["Template"]["HtmlPart"].should.equal( "

Hello {{name}},

Your favorite color is {{color}}

" ) + + +@mock_ses +def test_domains_are_case_insensitive(): + client = boto3.client("ses", region_name="us-east-1") + duplicate_domains = [ + "EXAMPLE.COM", + "EXAMple.Com", + "example.com", + ] + for domain in duplicate_domains: + client.verify_domain_identity(Domain=domain) + client.verify_domain_dkim(Domain=domain) + identities = client.list_identities(IdentityType="Domain")["Identities"] + identities.should.have.length_of(1) + identities[0].should.equal("example.com")