SES: Ensure service is region-aware (#5862)

This commit is contained in:
Bert Blommers 2023-01-21 17:10:55 -01:00 committed by GitHub
parent c81bd9a1aa
commit 90e63c1cb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View File

@ -115,7 +115,7 @@ class SESBackend(BaseBackend):
from moto.core import DEFAULT_ACCOUNT_ID
from moto.ses import ses_backends
ses_backend = ses_backends[DEFAULT_ACCOUNT_ID]["global"]
ses_backend = ses_backends[DEFAULT_ACCOUNT_ID][region]
messages = ses_backend.sent_messages # sent_messages is a List of Message objects
Note that, as this is an internal API, the exact format may differ per versions.
@ -585,6 +585,4 @@ class SESBackend(BaseBackend):
return attributes_by_identity
ses_backends: Mapping[str, SESBackend] = BackendDict(
SESBackend, "ses", use_boto3_regions=False, additional_regions=["global"]
)
ses_backends: Mapping[str, SESBackend] = BackendDict(SESBackend, "ses")

View File

@ -11,7 +11,7 @@ class EmailResponse(BaseResponse):
@property
def backend(self):
return ses_backends[self.current_account]["global"]
return ses_backends[self.current_account][self.region]
def verify_email_identity(self):
address = self.querystring.get("EmailAddress")[0]

View File

@ -19,6 +19,15 @@ def test_verify_email_identity():
address.should.equal("test@example.com")
@mock_ses
def test_identities_are_region_specific():
us_east = boto3.client("ses", region_name="us-east-1")
us_east.verify_email_identity(EmailAddress="test@example.com")
us_west = boto3.client("ses", region_name="us-west-1")
us_west.list_identities()["Identities"].should.have.length_of(0)
@mock_ses
def test_verify_email_identity_idempotency():
conn = boto3.client("ses", region_name="us-east-1")