-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathReceiveMailTest.yml
65 lines (61 loc) · 2.09 KB
/
ReceiveMailTest.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
- import_playbook: ../_prepare/sut.yml
- hosts: client
tasks:
- name: Send a mail from client to an address SUT is responsible for
ansible.builtin.shell: |
echo "Test-Body" | mailx -s "Test" [email protected]
- hosts: sut
tasks:
- name: Get path of mail in maildir
become: true
become_user: vmail
block:
- ansible.builtin.wait_for:
path: /srv/mail/jane/Maildir/new/
timeout: 10
- ansible.builtin.find:
paths: /srv/mail/jane/Maildir/new/
register: find_result
- name: Assert mail is received and delivered at SUT
compare:
file: "{{ find_result.files[0].path }}"
with_content: |
Return-Path: <vagrant@localhost>
Delivered-To: [email protected]
Received: from sut.mydomain.test
$$ \t $$by sut.mydomain.test with LMTP
$$ \t $$id $$ .* $$
$$ \t $$(envelope-from <vagrant@localhost>)
$$ \t $$for <[email protected]>; $$ .* $$
Received: from localhost (ip-192.168.56.201.someisp.test [192.168.56.201])
$$ \t $$by sut.mydomain.test (Postfix) with ESMTP id $$ .* $$
$$ \t $$for <[email protected]>; $$ .* $$
...
Received: by localhost (Postfix, from userid 1000)
...
Date: $$ .* $$
Subject: Test
...
From: vagrant@localhost
...
Test-Body
become: true
become_user: vmail
- name: Assert the received mail is tagged as Spam due to sending from client with hostname localhost (ip-192.168.56.201.someisp.test)
compare:
file: "{{ find_result.files[0].path }}"
with_content: |
...
Subject: Test
...
X-Spamd-Result: default: False [7.70 / 15.00];
$$ \t $$HFILTER_FROMHOST_NOT_FQDN(3.00)[localhost];
$$ \t $$HFILTER_HELO_5(3.00)[localhost];
...
X-Spam: Yes
Test-Body
become: true
become_user: vmail