Debian Codegraph @

tests/test_plugin_ses.py

raw symbols SCIP
1 # BSD 2-Clause License
2 #
3 # Apprise - Push Notification Library.
4 # Copyright (c) 2026, Chris Caron <[email protected]>
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are met:
8 #
9 # 1. Redistributions of source code must retain the above copyright notice,
10 # this list of conditions and the following disclaimer.
11 #
12 # 2. Redistributions in binary form must reproduce the above copyright notice,
13 # this list of conditions and the following disclaimer in the documentation
14 # and/or other materials provided with the distribution.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 # POSSIBILITY OF SUCH DAMAGE.
27
28 # Disable logging for a cleaner testing output
29 import logging
30 import os
31 import sys
32 from unittest import mock
33
34 from helpers import AppriseURLTester
35 import pytest
36 import requests
37
38 from apprise import Apprise, AppriseAttachment
39 from apprise.plugins.ses import NotifySES
40
41 logging.disable(logging.CRITICAL)
42
43 if hasattr(sys, "pypy_version_info"):
44 raise pytest.skip(
45 reason="Skipping test cases which stall on PyPy",
46 allow_module_level=True,
47 )
48
49 # Attachment Directory
50 TEST_VAR_DIR = os.path.join(os.path.dirname(__file__), "var")
51
52 AWS_SES_GOOD_RESPONSE = """
53 <SendRawEmailResponse
54 xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
55 <SendRawEmailResult>
56 <MessageId>
57 010f017d87656ee2-a2ea291f-79ea-
58 44f3-9d25-00d041de3007-000000</MessageId>
59 </SendRawEmailResult>
60 <ResponseMetadata>
61 <RequestId>7abb454e-904b-4e46-a23c-2f4d2fc127a6</RequestId>
62 </ResponseMetadata>
63 </SendRawEmailResponse>
64 """
65
66 TEST_ACCESS_KEY_ID = "AHIAJGNT76XIMXDBIJYA"
67 TEST_ACCESS_KEY_SECRET = "bu1dHSdO22pfaaVy/wmNsdljF4C07D3bndi9PQJ9"
68 TEST_REGION = "us-east-2"
69 TEST_SESSION_TOKEN = "FwoGZXIvYXdzSESSIONTOKENABCDEFGHIJKLMNOPQRS"
70
71 # Our Testing URLs
72 apprise_url_tests = (
73 (
74 "ses://",
75 {
76 "instance": TypeError,
77 },
78 ),
79 (
80 "ses://:@/",
81 {
82 "instance": TypeError,
83 },
84 ),
85 (
86 "ses://[email protected]/T1JJ3T3L2",
87 {
88 # Just Token 1 provided
89 "instance": TypeError,
90 },
91 ),
92 (
93 "ses://[email protected]/T1JJ3TD4JD/TIiajkdnlazk7FQ/",
94 {
95 # Missing a region
96 "instance": TypeError,
97 },
98 ),
99 (
100 "ses://T1JJ3T3L2/A1BRTD4JD/TIiajkdnlazkcevi7FQ/us-west-2",
101 {
102 # No email
103 "instance": TypeError,
104 },
105 ),
106 (
107 "ses://[email protected]/T1JJ3TD4JD/TIiajkdnlazk7FQ/[email protected]",
108 {
109 # Missing a region (but has email)
110 "instance": TypeError,
111 },
112 ),
113 (
114 (
115 "ses://[email protected]/T1JJ3T3L2/A1BRTD4JD/TIiajkdnlazkcevi7FQ/"
116 "us-west-2?reply=invalid-email"
117 ),
118 {
119 # An invalid reply-to address
120 "instance": TypeError,
121 # Our response expected server response
122 "requests_response_text": AWS_SES_GOOD_RESPONSE,
123 },
124 ),
125 (
126 (
127 "ses://[email protected]/T1JJ3T3L2/A1BRTD4JD/TIiajkdnlazkcevi7FQ/"
128 "us-west-2"
129 ),
130 {
131 # we have a valid URL and we'll use our own email as a target
132 "instance": NotifySES,
133 # Our response expected server response
134 "requests_response_text": AWS_SES_GOOD_RESPONSE,
135 },
136 ),
137 (
138 (
139 "ses://[email protected]/T1JJ3TD4JD/TIiajkdnlazk7FQ/us-west-2/"
140 "[email protected]/[email protected]"
141 ),
142 {
143 # Multi Email Suppport
144 "instance": NotifySES,
145 # Our response expected server response
146 "requests_response_text": AWS_SES_GOOD_RESPONSE,
147 # Our expected url(privacy=True) startswith() response:
148 "privacy_url": "ses://[email protected]/T...D/****/us-west-2",
149 },
150 ),
151 (
152 (
153 "ses://[email protected]/T1JJ3T3L2/A1BRTD4JD/TIiajkdnlaevi7FQ/us-east-1"
154 "[email protected]"
155 ),
156 {
157 # leveraging to: keyword
158 "instance": NotifySES,
159 # Our response expected server response
160 "requests_response_text": AWS_SES_GOOD_RESPONSE,
161 },
162 ),
163 (
164 (
165 "ses://[email protected]&region=us-west-2&access=T1JJ3T3L2"
166 "&secret=A1BRTD4JD/TIiajkdnlaevi7FQ"
167 "&reply=No One <[email protected]>"
168 "&[email protected],[email protected],invalid-email"
169 "&[email protected],[email protected],invalid-email"
170 "&[email protected]"
171 ),
172 {
173 # leveraging a ton of our keywords
174 # We also test invlid emails specified on the bcc and cc list
175 "instance": NotifySES,
176 # Our response expected server response
177 "requests_response_text": AWS_SES_GOOD_RESPONSE,
178 },
179 ),
180 (
181 (
182 "ses://[email protected]/T1JJ3T3L2/A1BRTD4JD/TIiacevi7FQ/us-west-2/"
183 "?name=From%20Name&[email protected],invalid-email"
184 ),
185 {
186 # leveraging a ton of our keywords
187 "instance": NotifySES,
188 # Our response expected server response
189 "requests_response_text": AWS_SES_GOOD_RESPONSE,
190 },
191 ),
192 (
193 (
194 "ses://[email protected]/T1JJ3T3L2/A1BRTD4JD/TIiacevi7FQ/us-west-2/"
195 "?format=text"
196 ),
197 {
198 # Send email as a text (instead of HTML)
199 "instance": NotifySES,
200 # Our response expected server response
201 "requests_response_text": AWS_SES_GOOD_RESPONSE,
202 },
203 ),
204 (
205 (
206 "ses://[email protected]/T1JJ3T3L2/A1BRTD4JD/TIiacevi7FQ/us-west-2/"
207 "?to=invalid-email"
208 ),
209 {
210 # An invalid email will get dropped during the initialization
211 # we'll have no targets to notify afterwards
212 "instance": NotifySES,
213 # Our response expected server response
214 "requests_response_text": AWS_SES_GOOD_RESPONSE,
215 # As a result, we won't be able to notify anyone
216 "notify_response": False,
217 },
218 ),
219 (
220 (
221 "ses://[email protected]/T1JJ3T3L2/A1BRTD4JD/TIiacevi7FQ/us-west-2/"
222 "[email protected]"
223 ),
224 {
225 "instance": NotifySES,
226 # Our response expected server response
227 "requests_response_text": AWS_SES_GOOD_RESPONSE,
228 # throw a bizarre code forcing us to fail to look it up
229 "response": False,
230 "requests_response_code": 999,
231 },
232 ),
233 (
234 (
235 "ses://[email protected]/T1JJ3T3L2/A1BRTD4JD/TIiajkdnlavi7FQ/us-west-2/"
236 "[email protected]"
237 ),
238 {
239 "instance": NotifySES,
240 # Our response expected server response
241 "requests_response_text": AWS_SES_GOOD_RESPONSE,
242 # Throws a series of connection and transfer exceptions when this
243 # flag is set and tests that we gracefully handle them
244 "test_requests_exceptions": True,
245 },
246 ),
247 (
248 # Session token via ?token= query parameter
249 "ses://[email protected]/T1JJ3T3L2/A1BRTD4JD/TIiacevi7FQ/us-west-2/"
250 "[email protected]?token=SESSIONTOKEN",
251 {
252 "instance": NotifySES,
253 "requests_response_text": AWS_SES_GOOD_RESPONSE,
254 },
255 ),
256 (
257 # Access key via ?key= alias
258 "ses://[email protected]/?key=T1JJ3T3L2"
259 "&secret=A1BRTD4JD/TIiacevi7FQ&region=us-west-2"
260 "&[email protected]",
261 {
262 "instance": NotifySES,
263 "requests_response_text": AWS_SES_GOOD_RESPONSE,
264 },
265 ),
266 (
267 # Session token + HTTP error
268 "ses://[email protected]/T1JJ3T3L2/A1BRTD4JD/TIiacevi7FQ/us-west-2/"
269 "[email protected]?token=SESSIONTOKEN",
270 {
271 "instance": NotifySES,
272 "requests_response_text": AWS_SES_GOOD_RESPONSE,
273 "response": False,
274 "requests_response_code": 999,
275 },
276 ),
277 (
278 # Session token + request exceptions
279 "ses://[email protected]/T1JJ3T3L2/A1BRTD4JD/TIiacevi7FQ/us-west-2/"
280 "[email protected]?token=SESSIONTOKEN",
281 {
282 "instance": NotifySES,
283 "requests_response_text": AWS_SES_GOOD_RESPONSE,
284 "test_requests_exceptions": True,
285 },
286 ),
287 (
288 # Session token in the URL password field
289 "ses://user:[email protected]/T1JJ3T3L2/A1BRTD4JD/"
290 "TIiacevi7FQ/us-west-2/[email protected]",
291 {
292 "instance": NotifySES,
293 "requests_response_text": AWS_SES_GOOD_RESPONSE,
294 },
295 ),
296 )
297
298
299 def test_plugin_ses_urls():
300 """NotifySES() Apprise URLs."""
301
302 # Run our general tests
303 AppriseURLTester(tests=apprise_url_tests).run_all()
304
305
306 # We initialize a post object just incase a test fails below
307 # we don't want it sending any notifications upstream
308 @mock.patch("requests.post")
309 def test_plugin_ses_edge_cases(mock_post):
310 """NotifySES() Edge Cases."""
311
312 # Initializes the plugin with a valid access, but invalid access key
313 with pytest.raises(TypeError):
314 # No access_key_id specified
315 NotifySES(
316 from_addr="[email protected]",
317 access_key_id=None,
318 secret_access_key=TEST_ACCESS_KEY_SECRET,
319 region_name=TEST_REGION,
320 targets="[email protected]",
321 )
322
323 with pytest.raises(TypeError):
324 # No secret_access_key specified
325 NotifySES(
326 from_addr="[email protected]",
327 access_key_id=TEST_ACCESS_KEY_ID,
328 secret_access_key=None,
329 region_name=TEST_REGION,
330 targets="[email protected]",
331 )
332
333 with pytest.raises(TypeError):
334 # No region_name specified
335 NotifySES(
336 from_addr="[email protected]",
337 access_key_id=TEST_ACCESS_KEY_ID,
338 secret_access_key=TEST_ACCESS_KEY_SECRET,
339 region_name=None,
340 targets="[email protected]",
341 )
342
343 # No recipients
344 obj = NotifySES(
345 from_addr="[email protected]",
346 access_key_id=TEST_ACCESS_KEY_ID,
347 secret_access_key=TEST_ACCESS_KEY_SECRET,
348 region_name=TEST_REGION,
349 targets=None,
350 )
351
352 # The object initializes properly but would not be able to send anything
353 assert obj.notify(body="test", title="test") is False
354
355 # The phone number is invalid, and without it, there is nothing
356 # to notify; we
357 obj = NotifySES(
358 from_addr="[email protected]",
359 access_key_id=TEST_ACCESS_KEY_ID,
360 secret_access_key=TEST_ACCESS_KEY_SECRET,
361 region_name=TEST_REGION,
362 targets="invalid-email",
363 )
364
365 # The object initializes properly but would not be able to send anything
366 assert obj.notify(body="test", title="test") is False
367
368
369 def test_plugin_ses_url_parsing():
370 """NotifySES() URL Parsing."""
371
372 # No recipients
373 results = NotifySES.parse_url(
374 "ses://{}/{}/{}/{}/".format(
375 "[email protected]",
376 TEST_ACCESS_KEY_ID,
377 TEST_ACCESS_KEY_SECRET,
378 TEST_REGION,
379 )
380 )
381
382 # Confirm that there were no recipients found
383 assert len(results["targets"]) == 0
384 assert "region_name" in results
385 assert results["region_name"] == TEST_REGION
386 assert "access_key_id" in results
387 assert results["access_key_id"] == TEST_ACCESS_KEY_ID
388 assert "secret_access_key" in results
389 assert results["secret_access_key"] == TEST_ACCESS_KEY_SECRET
390
391 # Detect recipients
392 results = NotifySES.parse_url(
393 "ses://{}/{}/{}/{}/{}/{}/".format(
394 "[email protected]",
395 TEST_ACCESS_KEY_ID,
396 TEST_ACCESS_KEY_SECRET,
397 # Uppercase Region won't break anything
398 TEST_REGION.upper(),
399 "[email protected]",
400 "[email protected]",
401 )
402 )
403
404 # Confirm that our recipients were found
405 assert len(results["targets"]) == 2
406 assert "[email protected]" in results["targets"]
407 assert "[email protected]" in results["targets"]
408 assert "region_name" in results
409 assert results["region_name"] == TEST_REGION
410 assert "access_key_id" in results
411 assert results["access_key_id"] == TEST_ACCESS_KEY_ID
412 assert "secret_access_key" in results
413 assert results["secret_access_key"] == TEST_ACCESS_KEY_SECRET
414
415
416 def test_plugin_ses_aws_response_handling():
417 """NotifySES() AWS Response Handling."""
418 # Not a string
419 response = NotifySES.aws_response_to_dict(None)
420 assert response["type"] is None
421 assert response["request_id"] is None
422
423 # Invalid XML
424 response = NotifySES.aws_response_to_dict(
425 '<Bad Response xmlns="http://ses.amazonaws.com/doc/2010-03-31/">'
426 )
427 assert response["type"] is None
428 assert response["request_id"] is None
429
430 # Single Element in XML
431 response = NotifySES.aws_response_to_dict(
432 "<SingleElement></SingleElement>"
433 )
434 assert response["type"] == "SingleElement"
435 assert response["request_id"] is None
436
437 # Empty String
438 response = NotifySES.aws_response_to_dict("")
439 assert response["type"] is None
440 assert response["request_id"] is None
441
442 response = NotifySES.aws_response_to_dict("""
443 <SendRawEmailResponse
444 xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
445 <SendRawEmailResult>
446 <MessageId>
447 010f017d87656ee2-a2ea291f-79ea-44f3-9d25-00d041de307</MessageId>
448 </SendRawEmailResult>
449 <ResponseMetadata>
450 <RequestId>7abb454e-904b-4e46-a23c-2f4d2fc127a6</RequestId>
451 </ResponseMetadata>
452 </SendRawEmailResponse>
453 """)
454 assert response["type"] == "SendRawEmailResponse"
455 assert response["request_id"] == "7abb454e-904b-4e46-a23c-2f4d2fc127a6"
456 assert (
457 response["message_id"]
458 == "010f017d87656ee2-a2ea291f-79ea-44f3-9d25-00d041de307"
459 )
460
461 response = NotifySES.aws_response_to_dict("""
462 <ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-03-31/">
463 <Error>
464 <Type>Sender</Type>
465 <Code>InvalidParameter</Code>
466 <Message>Invalid parameter</Message>
467 </Error>
468 <RequestId>b5614883-babe-56ca-93b2-1c592ba6191e</RequestId>
469 </ErrorResponse>
470 """)
471 assert response["type"] == "ErrorResponse"
472 assert response["request_id"] == "b5614883-babe-56ca-93b2-1c592ba6191e"
473 assert response["error_type"] == "Sender"
474 assert response["error_code"] == "InvalidParameter"
475 assert response["error_message"] == "Invalid parameter"
476
477
478 @mock.patch("requests.post")
479 def test_plugin_ses_attachments(mock_post):
480 """NotifySES() Attachment Checks."""
481
482 # Prepare Mock return object
483 response = mock.Mock()
484 response.content = AWS_SES_GOOD_RESPONSE
485 response.status_code = requests.codes.ok
486 mock_post.return_value = response
487
488 # prepare our attachment
489 attach = AppriseAttachment(os.path.join(TEST_VAR_DIR, "apprise-test.gif"))
490
491 # Test our markdown
492 obj = Apprise.instantiate(
493 "ses://{}/{}/{}/{}/".format(
494 "[email protected]",
495 TEST_ACCESS_KEY_ID,
496 TEST_ACCESS_KEY_SECRET,
497 TEST_REGION,
498 )
499 )
500
501 # Send a good attachment
502 assert obj.notify(body="test", attach=attach) is True
503
504 # Reset our mock object
505 mock_post.reset_mock()
506
507 # Add another attachment so we drop into the area of the PushBullet code
508 # that sends remaining attachments (if more detected)
509 attach.add(os.path.join(TEST_VAR_DIR, "apprise-test.gif"))
510
511 # Send our attachments
512 assert obj.notify(body="test", attach=attach) is True
513
514 # Test our call count
515 assert mock_post.call_count == 1
516
517 # Reset our mock object
518 mock_post.reset_mock()
519
520 # An invalid attachment will cause a failure
521 path = os.path.join(TEST_VAR_DIR, "/invalid/path/to/an/invalid/file.jpg")
522 attach = AppriseAttachment(path)
523 assert obj.notify(body="test", attach=attach) is False
524
525
526 @mock.patch("requests.post")
527 def test_plugin_ses_session_token(mock_post):
528 """NotifySES() session token for temporary/IAM credentials."""
529
530 response = mock.MagicMock()
531 response.status_code = requests.codes.ok
532 response.content = AWS_SES_GOOD_RESPONSE
533 mock_post.return_value = response
534
535 # Init with session token
536 obj = NotifySES(
537 access_key_id=TEST_ACCESS_KEY_ID,
538 secret_access_key=TEST_ACCESS_KEY_SECRET,
539 region_name=TEST_REGION,
540 from_addr="[email protected]",
541 targets=["[email protected]"],
542 session_token=TEST_SESSION_TOKEN,
543 )
544 assert obj.aws_session_token == TEST_SESSION_TOKEN
545
546 # send() must include X-Amz-Security-Token in request headers
547 assert obj.notify(body="test") is True
548 call_kwargs = mock_post.call_args[1]
549 assert "X-Amz-Security-Token" in call_kwargs["headers"]
550 assert call_kwargs["headers"]["X-Amz-Security-Token"] == TEST_SESSION_TOKEN
551
552 # x-amz-security-token must appear in the Authorization SignedHeaders
553 auth = call_kwargs["headers"]["Authorization"]
554 assert "x-amz-security-token" in auth
555
556 # URL round-trip: token appears in the password field, not ?token=
557 url = obj.url()
558 assert f":{TEST_SESSION_TOKEN}@" in url
559 assert "token=" not in url
560
561 results = NotifySES.parse_url(url)
562 assert results["session_token"] == TEST_SESSION_TOKEN
563 assert results["access_key_id"] == TEST_ACCESS_KEY_ID
564
565 obj2 = NotifySES(**results)
566 assert obj2.aws_session_token == TEST_SESSION_TOKEN
567 assert obj2.url_identifier == obj.url_identifier
568
569 # Privacy URL must mask the token value (in the password position)
570 priv_url = obj.url(privacy=True)
571 assert TEST_SESSION_TOKEN not in priv_url
572 assert "token=" not in priv_url
573
574 # Without a session token no X-Amz-Security-Token header is sent
575 mock_post.reset_mock()
576 obj_plain = NotifySES(
577 access_key_id=TEST_ACCESS_KEY_ID,
578 secret_access_key=TEST_ACCESS_KEY_SECRET,
579 region_name=TEST_REGION,
580 from_addr="[email protected]",
581 targets=["[email protected]"],
582 )
583 assert obj_plain.aws_session_token is None
584 assert obj_plain.notify(body="test") is True
585 call_kwargs = mock_post.call_args[1]
586 assert "X-Amz-Security-Token" not in call_kwargs["headers"]
587
588 # url() without token has no token= param
589 plain_url = obj_plain.url()
590 assert "token=" not in plain_url
591
592
593 def test_plugin_ses_session_token_via_kwarg():
594 """NotifySES() session token parsed from ?token= kwarg."""
595
596 url = (
597 f"ses://[email protected]/{TEST_ACCESS_KEY_ID}"
598 f"/{TEST_ACCESS_KEY_SECRET}/{TEST_REGION}"
599 f"/[email protected]?token={TEST_SESSION_TOKEN}"
600 )
601 results = NotifySES.parse_url(url)
602 assert results["session_token"] == TEST_SESSION_TOKEN
603 assert results["access_key_id"] == TEST_ACCESS_KEY_ID
604
605 obj = NotifySES(**results)
606 assert obj.aws_session_token == TEST_SESSION_TOKEN
607
608
609 def test_plugin_ses_key_alias():
610 """NotifySES() ?key= alias for access_key_id."""
611
612 url = (
613 "ses://[email protected]/"
614 f"?key={TEST_ACCESS_KEY_ID}"
615 f"&secret={TEST_ACCESS_KEY_SECRET}"
616 f"&region={TEST_REGION}"
617 "&[email protected]"
618 )
619 results = NotifySES.parse_url(url)
620 assert results["access_key_id"] == TEST_ACCESS_KEY_ID
621
622 obj = NotifySES(**results)
623 assert obj.aws_access_key_id == TEST_ACCESS_KEY_ID
624
625 # ?key= takes priority over ?access= when both appear
626 url_both = (
627 "ses://[email protected]/"
628 f"?key={TEST_ACCESS_KEY_ID}&access=OTHERID"
629 f"&secret={TEST_ACCESS_KEY_SECRET}"
630 f"&region={TEST_REGION}"
631 "&[email protected]"
632 )
633 results2 = NotifySES.parse_url(url_both)
634 assert results2["access_key_id"] == TEST_ACCESS_KEY_ID
635
636
637 def test_plugin_ses_session_token_via_password_field():
638 """NotifySES() session token parsed from URL password position."""
639
640 # Token in the password field:
641 # ses://sender:{token}@example.com/{access_key_id}/...
642 url = (
643 f"ses://sender:{TEST_SESSION_TOKEN}@example.com"
644 f"/{TEST_ACCESS_KEY_ID}/{TEST_ACCESS_KEY_SECRET}"
645 f"/{TEST_REGION}/[email protected]"
646 )
647 results = NotifySES.parse_url(url)
648 assert results["session_token"] == TEST_SESSION_TOKEN
649 assert results["access_key_id"] == TEST_ACCESS_KEY_ID
650
651 obj = NotifySES(**results)
652 assert obj.aws_session_token == TEST_SESSION_TOKEN
653 assert obj.from_addr == "[email protected]"
654
655 # Round-trip: url() emits password-field form, which re-parses correctly
656 regenerated = obj.url()
657 assert f":{TEST_SESSION_TOKEN}@" in regenerated
658 assert "token=" not in regenerated
659
660 results2 = NotifySES.parse_url(regenerated)
661 assert results2["session_token"] == TEST_SESSION_TOKEN
662
663 obj2 = NotifySES(**results2)
664 assert obj2.aws_session_token == TEST_SESSION_TOKEN
665 assert obj2.from_addr == obj.from_addr
666
667 # ?token= takes priority over the password field when both are present
668 url_both = (
669 f"ses://sender:[email protected]"
670 f"/{TEST_ACCESS_KEY_ID}/{TEST_ACCESS_KEY_SECRET}"
671 f"/{TEST_REGION}/[email protected]"
672 f"?token={TEST_SESSION_TOKEN}"
673 )
674 results3 = NotifySES.parse_url(url_both)
675 assert results3["session_token"] == TEST_SESSION_TOKEN
676
677 obj3 = NotifySES(**results3)
678 assert obj3.aws_session_token == TEST_SESSION_TOKEN