Debian Codegraph @

ansible_collections/community/aws/tests/integration/targets/ses_identity/tasks/main.yaml

raw
1 ---
2 - name: 'aws_ses_identity integration tests'
3 collections:
4 - amazon.aws
5 module_defaults:
6 group/aws:
7 access_key: '{{ aws_access_key }}'
8 secret_key: '{{ aws_secret_key }}'
9 session_token: '{{ security_token | default(omit) }}'
10 region: '{{ aws_region }}'
11 block:
12
13 # ============================================================
14 - name: test register email identity
15 block:
16 - name: register email identity
17 ses_identity:
18 identity: "{{ email_identity }}-email"
19 state: present
20 register: result
21 - name: assert changed is True
22 assert:
23 that:
24 - result.changed == True
25 - import_tasks: assert_defaults.yaml
26 vars:
27 identity: "{{ email_identity }}-email"
28 always:
29 - name: cleanup email identity
30 ses_identity:
31 identity: "{{ email_identity }}-email"
32 state: absent
33 # ============================================================
34 - name: test register domain identity
35 block:
36 - name: register domain identity
37 ses_identity:
38 identity: "{{ domain_identity }}-domain"
39 state: present
40 register: result
41 - name: assert changed is True
42 assert:
43 that:
44 - result.changed == True
45 - import_tasks: assert_defaults.yaml
46 vars:
47 identity: "{{ domain_identity }}-domain"
48 - name: assert verification_attributes.verification_token is defined
49 assert:
50 that:
51 - result.verification_attributes.verification_token | length > 0
52 always:
53 - name: cleanup domain identity
54 ses_identity:
55 identity: "{{ domain_identity }}-domain"
56 state: absent
57 # ============================================================
58 - name: test email_identity unchanged when already existing
59 block:
60 - name: register identity
61 ses_identity:
62 identity: "{{ email_identity }}-duplicate"
63 state: present
64 - name: duplicate register identity
65 ses_identity:
66 identity: "{{ email_identity }}-duplicate"
67 state: present
68 register: result
69 - name: assert changed is False
70 assert:
71 that:
72 - result.changed == False
73 - import_tasks: assert_defaults.yaml
74 vars:
75 identity: "{{ email_identity }}-duplicate"
76 always:
77 - name: cleanup identity
78 ses_identity:
79 identity: "{{ email_identity }}-duplicate"
80 state: absent
81 # ============================================================
82 - name: test domain_identity unchanged when already existing
83 block:
84 - name: register identity
85 ses_identity:
86 identity: "{{ domain_identity }}-duplicate"
87 state: present
88 - name: duplicate register identity
89 ses_identity:
90 identity: "{{ domain_identity }}-duplicate"
91 state: present
92 register: result
93 - name: assert changed is False
94 assert:
95 that:
96 - result.changed == False
97 - import_tasks: assert_defaults.yaml
98 vars:
99 identity: "{{ domain_identity }}-duplicate"
100 always:
101 - name: cleanup identity
102 ses_identity:
103 identity: "{{ domain_identity }}-duplicate"
104 state: absent
105 # ============================================================
106 # Test for https://github.com/ansible/ansible/issues/51531
107 # because aws region is explicitly used rather than just to
108 # obtain a connection, make sure this still works when
109 # region comes from an environment rather than a parameter.
110 - name: test register identity without explicit region
111 block:
112 - name: register email identity without explicit region
113 ses_identity:
114 identity: "{{ email_identity }}-noregion"
115 state: present
116 region: "{{ omit }}"
117 register: result
118 environment:
119 AWS_DEFAULT_REGION: "{{ aws_region }}"
120 - name: assert changed is True
121 assert:
122 that:
123 - result.changed == True
124 - import_tasks: assert_defaults.yaml
125 vars:
126 identity: "{{ email_identity }}-noregion"
127 always:
128 - name: cleanup email identity
129 ses_identity:
130 identity: "{{ email_identity }}-noregion"
131 state: absent
132 # ============================================================
133 - name: test register email identity check mode
134 block:
135 - name: register email identity check mode
136 ses_identity:
137 identity: "{{ email_identity }}-check"
138 state: present
139 register: result
140 check_mode: True
141
142 - name: assert changed is True
143 assert:
144 that:
145 - result.changed == True
146
147 - import_tasks: assert_defaults.yaml
148 vars:
149 identity: "{{ email_identity }}-check"
150
151 always:
152 - name: cleanup email identity
153 ses_identity:
154 identity: "{{ email_identity }}-check"
155 state: absent
156 register: result
157
158 - name: assert nothing to clean up since check mode
159 assert:
160 that:
161 - result.changed == False
162 # ============================================================
163 - name: test register domain identity check mode
164 block:
165 - name: register domain identity check mode
166 ses_identity:
167 identity: "{{ domain_identity }}-domain-check"
168 state: present
169 register: result
170 check_mode: True
171
172 - name: assert changed is True
173 assert:
174 that:
175 - result.changed == True
176
177 - import_tasks: assert_defaults.yaml
178 vars:
179 identity: "{{ domain_identity }}-domain-check"
180
181 always:
182 - name: cleanup domain identity
183 ses_identity:
184 identity: "{{ domain_identity }}-domain-check"
185 state: absent
186 register: result
187
188 - name: assert nothing to clean up since check mode
189 assert:
190 that:
191 - result.changed == False
192 # ============================================================
193 - name: remove non-existent email identity
194 ses_identity:
195 identity: "{{ email_identity }}-missing"
196 state: absent
197 register: result
198 - name: assert changed is False
199 assert:
200 that:
201 - result.changed == False
202 # ============================================================
203 - name: remove non-existent domain identity
204 ses_identity:
205 identity: "{{ domain_identity }}-missing-domain"
206 state: absent
207 register: result
208 - name: assert changed is False
209 assert:
210 that:
211 - result.changed == False
212 # ============================================================
213 - name: test remove email identity check mode
214 block:
215 - name: register email identity
216 ses_identity:
217 identity: "{{ email_identity }}-remove-check"
218 state: present
219 register: result
220
221 - name: remove email identity check mode
222 ses_identity:
223 identity: "{{ email_identity }}-remove-check"
224 state: absent
225 register: result
226 check_mode: True
227
228 - name: assert changed is True
229 assert:
230 that:
231 - result.changed == True
232 always:
233 - name: cleanup email identity
234 ses_identity:
235 identity: "{{ email_identity }}-remove-check"
236 state: absent
237 register: result
238
239 - name: assert something to clean up since remove was check mode
240 assert:
241 that:
242 - result.changed == True
243 # ============================================================
244 - name: test remove domain identity check mode
245 block:
246 - name: register domain identity
247 ses_identity:
248 identity: "{{ domain_identity }}-remove-domain-check"
249 state: present
250 register: result
251
252 - name: remove domain identity check mode
253 ses_identity:
254 identity: "{{ domain_identity }}-remove-domain-check"
255 state: absent
256 register: result
257 check_mode: True
258
259 - name: assert changed is True
260 assert:
261 that:
262 - result.changed == True
263 always:
264 - name: cleanup domain identity
265 ses_identity:
266 identity: "{{ domain_identity }}-remove-domain-check"
267 state: absent
268 register: result
269
270 - name: assert something to clean up since remove was check mode
271 assert:
272 that:
273 - result.changed == True
274 # ============================================================
275 - name: test set notification queues
276 block:
277 - name: test topic
278 sns_topic:
279 name: "{{ notification_queue_name }}-{{ item }}"
280 state: present
281 register: topic_info
282 with_items:
283 - bounce
284 - complaint
285 - delivery
286 - name: register email identity
287 ses_identity:
288 identity: "{{ email_identity }}-topics"
289 state: present
290 bounce_notifications:
291 topic: "{{ topic_info.results[0].sns_arn }}"
292 complaint_notifications:
293 topic: "{{ topic_info.results[1].sns_arn }}"
294 delivery_notifications:
295 topic: "{{ topic_info.results[2].sns_arn }}"
296 register: result
297 - name: assert notification settings
298 assert:
299 that:
300 - result.notification_attributes.bounce_topic == topic_info.results[0].sns_arn
301 - result.notification_attributes.complaint_topic == topic_info.results[1].sns_arn
302 - result.notification_attributes.delivery_topic == topic_info.results[2].sns_arn
303 - name: assert notification headers unchanged
304 assert:
305 that:
306 - result.notification_attributes.headers_in_bounce_notifications_enabled == False
307 - result.notification_attributes.headers_in_complaint_notifications_enabled == False
308 - result.notification_attributes.headers_in_delivery_notifications_enabled == False
309 always:
310 - name: cleanup topics
311 sns_topic:
312 name: "{{ notification_queue_name }}-{{ item }}"
313 state: absent
314 with_items:
315 - bounce
316 - complaint
317 - delivery
318 - name: cleanup email identity
319 ses_identity:
320 identity: "{{ email_identity }}-topics"
321 state: absent
322 # ============================================================
323 - name: test change notification queues after create
324 block:
325 - name: test topic
326 sns_topic:
327 name: "{{ notification_queue_name }}-{{ item }}"
328 state: present
329 register: topic_info
330 with_items:
331 - bounce
332 - complaint
333 - delivery
334 - name: register email identity
335 ses_identity:
336 identity: "{{ email_identity }}-topics-post"
337 state: present
338 - name: set notification topics
339 ses_identity:
340 identity: "{{ email_identity }}-topics-post"
341 state: present
342 bounce_notifications:
343 topic: "{{ topic_info.results[0].sns_arn }}"
344 complaint_notifications:
345 topic: "{{ topic_info.results[1].sns_arn }}"
346 delivery_notifications:
347 topic: "{{ topic_info.results[2].sns_arn }}"
348 register: result
349 - name: assert changed is True
350 assert:
351 that:
352 - result.changed == True
353 - name: assert notification settings
354 assert:
355 that:
356 - result.notification_attributes.bounce_topic == topic_info.results[0].sns_arn
357 - result.notification_attributes.complaint_topic == topic_info.results[1].sns_arn
358 - result.notification_attributes.delivery_topic == topic_info.results[2].sns_arn
359 always:
360 - name: cleanup topics
361 sns_topic:
362 name: "{{ notification_queue_name }}-{{ item }}"
363 state: absent
364 with_items:
365 - bounce
366 - complaint
367 - delivery
368 - name: cleanup email identity
369 ses_identity:
370 identity: "{{ email_identity }}-topics-post"
371 state: absent
372 # ============================================================
373 - name: test clear notification configuration
374 block:
375 - name: test topic
376 sns_topic:
377 name: "{{ notification_queue_name }}-{{ item }}"
378 state: present
379 register: topic_info
380 with_items:
381 - bounce
382 - complaint
383 - delivery
384 - name: register email identity
385 ses_identity:
386 identity: "{{ email_identity }}-topics-clear"
387 state: present
388 bounce_notifications:
389 topic: "{{ topic_info.results[0].sns_arn }}"
390 complaint_notifications:
391 topic: "{{ topic_info.results[1].sns_arn }}"
392 delivery_notifications:
393 topic: "{{ topic_info.results[2].sns_arn }}"
394 - name: Make no change to identity
395 ses_identity:
396 identity: "{{ email_identity }}-topics-clear"
397 state: present
398 register: result
399 - name: assert no change
400 assert:
401 that:
402 - result.changed == False
403
404 - name: clear notification settings
405 ses_identity:
406 identity: "{{ email_identity }}-topics-clear"
407 state: present
408 bounce_notifications: {}
409 complaint_notifications: {}
410 delivery_notifications: {}
411 register: result
412 - name: assert notification settings
413 assert:
414 that:
415 - result.changed == True
416 - "'bounce_topic' not in result.notification_attributes"
417 - "'delivery_topic' not in result.notification_attributes"
418 - "'complaint_topic' not in result.notification_attributes"
419 always:
420 - name: cleanup topics
421 sns_topic:
422 name: "{{ notification_queue_name }}-{{ item }}"
423 state: absent
424 with_items:
425 - bounce
426 - complaint
427 - delivery
428 - name: cleanup email identity
429 ses_identity:
430 identity: "{{ email_identity }}-topics-clear"
431 state: absent
432 # ============================================================
433 - name: test change notification settings check mode
434 block:
435 - name: test topic
436 sns_topic:
437 name: "{{ notification_queue_name }}-{{ item }}"
438 state: present
439 register: topic_info
440 with_items:
441 - bounce
442 - complaint
443 - delivery
444
445 - name: register email identity
446 ses_identity:
447 identity: "{{ email_identity }}-topics-check"
448 state: present
449
450 - name: set notification settings check mode
451 ses_identity:
452 identity: "{{ email_identity }}-topics-check"
453 state: present
454 bounce_notifications:
455 topic: "{{ topic_info.results[0].sns_arn }}"
456 include_headers: Yes
457 complaint_notifications:
458 topic: "{{ topic_info.results[1].sns_arn }}"
459 include_headers: Yes
460 delivery_notifications:
461 topic: "{{ topic_info.results[2].sns_arn }}"
462 include_headers: Yes
463 feedback_forwarding: No
464 register: result
465 check_mode: True
466
467 - name: assert changed is True
468 assert:
469 that:
470 - result.changed == True
471
472 - name: assert notification settings
473 assert:
474 that:
475 - result.notification_attributes.bounce_topic == topic_info.results[0].sns_arn
476 - result.notification_attributes.headers_in_bounce_notifications_enabled == True
477 - result.notification_attributes.delivery_topic == topic_info.results[2].sns_arn
478 - result.notification_attributes.headers_in_delivery_notifications_enabled == True
479 - result.notification_attributes.complaint_topic == topic_info.results[1].sns_arn
480 - result.notification_attributes.headers_in_complaint_notifications_enabled == True
481 - result.notification_attributes.forwarding_enabled == False
482
483 - name: re-register base email identity
484 ses_identity:
485 identity: "{{ email_identity }}-topics-check"
486 state: present
487 register: result
488
489 - name: assert no change since notifications were check mode
490 assert:
491 that:
492 - result.changed == False
493 - "'bounce_topic' not in result.notification_attributes"
494 - result.notification_attributes.headers_in_bounce_notifications_enabled == False
495 - "'delivery_topic' not in result.notification_attributes"
496 - result.notification_attributes.headers_in_delivery_notifications_enabled == False
497 - "'complaint_topic' not in result.notification_attributes"
498 - result.notification_attributes.headers_in_complaint_notifications_enabled == False
499 - result.notification_attributes.forwarding_enabled == True
500 always:
501 - name: cleanup topics
502 sns_topic:
503 name: "{{ notification_queue_name }}-{{ item }}"
504 state: absent
505 with_items:
506 - bounce
507 - complaint
508 - delivery
509
510 - name: cleanup email identity
511 ses_identity:
512 identity: "{{ email_identity }}-topics-check"
513 state: absent
514 # ============================================================
515 - name: test include headers on notification queues
516 block:
517 - name: register email identity
518 ses_identity:
519 identity: "{{ email_identity }}-headers"
520 state: present
521 bounce_notifications:
522 include_headers: Yes
523 complaint_notifications:
524 include_headers: Yes
525 delivery_notifications:
526 include_headers: Yes
527 register: result
528 - name: assert notification headers enabled
529 assert:
530 that:
531 - result.notification_attributes.headers_in_bounce_notifications_enabled == True
532 - result.notification_attributes.headers_in_complaint_notifications_enabled == True
533 - result.notification_attributes.headers_in_delivery_notifications_enabled == True
534 always:
535 - name: cleanup email identity
536 ses_identity:
537 identity: "{{ email_identity }}-headers"
538 state: absent
539 # ============================================================
540 - name: test disable feedback forwarding
541 block:
542 - name: test topic
543 sns_topic:
544 name: "{{ notification_queue_name }}-{{ item }}"
545 state: present
546 register: topic_info
547 with_items:
548 - bounce
549 - complaint
550 - name: register email identity
551 ses_identity:
552 identity: "{{ email_identity }}-feedback"
553 state: present
554 bounce_notifications:
555 topic: "{{ topic_info.results[0].sns_arn }}"
556 complaint_notifications:
557 topic: "{{ topic_info.results[1].sns_arn }}"
558 feedback_forwarding: No
559 register: result
560 - name: assert feedback_forwarding == False
561 assert:
562 that:
563 - result.notification_attributes.forwarding_enabled == False
564 always:
565 - name: cleanup topics
566 sns_topic:
567 name: "{{ notification_queue_name }}-{{ item }}"
568 state: absent
569 with_items:
570 - bounce
571 - complaint
572 - name: cleanup email identity
573 ses_identity:
574 identity: "{{ email_identity }}-feedback"
575 state: absent
576 # ============================================================
577 - name: test disable feedback forwarding fails if no topics
578 block:
579 - name: register identity
580 ses_identity:
581 identity: "{{ domain_identity }}-feedback-nt"
582 state: present
583 feedback_forwarding: No
584 register: result
585 failed_when: result.failed == False
586 - name: assert error message starts with "Invalid Parameter Value"
587 assert:
588 that:
589 - '"Invalid Parameter Value" in result.msg'
590 always:
591 - name: cleanup identity
592 ses_identity:
593 identity: "{{ domain_identity }}-feedback-nt"
594 state: absent
595 # ============================================================
596 - name: test disable feedback forwarding fails if no complaint topic
597 block:
598 - name: test topic
599 sns_topic:
600 name: "{{ notification_queue_name }}-bounce"
601 state: present
602 register: topic_info
603 - name: register email identity
604 ses_identity:
605 identity: "{{ email_identity }}-feedback-nb"
606 state: present
607 bounce_notifications:
608 topic: "{{ topic_info.sns_arn }}"
609 feedback_forwarding: No
610 register: result
611 failed_when: result.failed == False
612 - name: assert error message starts with "Invalid Parameter Value"
613 assert:
614 that:
615 - '"Invalid Parameter Value" in result.msg'
616 always:
617 - name: cleanup topics
618 sns_topic:
619 name: "{{ notification_queue_name }}-bounce"
620 state: absent
621 - name: cleanup identity
622 ses_identity:
623 identity: "{{ email_identity }}-feedback-nb"
624 state: absent
625 # ============================================================
626 - name: test disable feedback forwarding fails if no bounce topic
627 block:
628 - name: test topic
629 sns_topic:
630 name: "{{ notification_queue_name }}-complaint"
631 state: present
632 register: topic_info
633 - name: register email identity
634 ses_identity:
635 identity: "{{ email_identity }}-feedback-nc"
636 state: present
637 complaint_notifications:
638 topic: "{{ topic_info.sns_arn }}"
639 feedback_forwarding: No
640 register: result
641 failed_when: result.failed == False
642 - name: assert error message starts with "Invalid Parameter Value"
643 assert:
644 that:
645 - '"Invalid Parameter Value" in result.msg'
646 always:
647 - name: cleanup topics
648 sns_topic:
649 name: "{{ notification_queue_name }}-complaint"
650 state: absent
651 - name: cleanup identity
652 ses_identity:
653 identity: "{{ email_identity }}-feedback-nc"
654 state: absent