@@ -3003,6 +3003,49 @@ def check_subscription():
3003
3003
3004
3004
retry (check_subscription , retries = PUBLICATION_RETRIES , sleep = PUBLICATION_TIMEOUT )
3005
3005
3006
+ @markers .aws .only_localstack
3007
+ def test_email_sender (
3008
+ self ,
3009
+ sns_create_topic ,
3010
+ sns_subscription ,
3011
+ aws_client ,
3012
+ monkeypatch ,
3013
+ ):
3014
+ # make sure to reset all received emails in SES
3015
+ requests .delete ("http://localhost:4566/_aws/ses" )
3016
+
3017
+ topic_arn = sns_create_topic ()["TopicArn" ]
3018
+ sns_subscription (
3019
+ TopicArn = topic_arn ,
3020
+ Protocol = "email" ,
3021
+ Endpoint = "localstack@yopmail.com" ,
3022
+ )
3023
+
3024
+ aws_client .sns .publish (
3025
+ Message = "Test message" ,
3026
+ TopicArn = topic_arn ,
3027
+ )
3028
+
3029
+ def _get_messages (amount : int ) -> list [dict ]:
3030
+ response = requests .get ("http://localhost:4566/_aws/ses" ).json ()
3031
+ assert len (response ["messages" ]) == amount
3032
+ return response ["messages" ]
3033
+
3034
+ messages = retry (lambda : _get_messages (1 ), retries = PUBLICATION_RETRIES , sleep = 1 )
3035
+ # legacy default value, should be replaced at some point
3036
+ assert messages [0 ]["Source" ] == "admin@localstack.com"
3037
+ requests .delete ("http://localhost:4566/_aws/ses" )
3038
+
3039
+ sender_address = "no-reply@sns.localstack.cloud"
3040
+ monkeypatch .setattr (config , "SNS_SES_SENDER_ADDRESS" , sender_address )
3041
+
3042
+ aws_client .sns .publish (
3043
+ Message = "Test message" ,
3044
+ TopicArn = topic_arn ,
3045
+ )
3046
+ messages = retry (lambda : _get_messages (1 ), retries = PUBLICATION_RETRIES , sleep = 1 )
3047
+ assert messages [0 ]["Source" ] == sender_address
3048
+
3006
3049
3007
3050
class TestSNSPlatformEndpoint :
3008
3051
@markers .aws .only_localstack
0 commit comments