[pmg-devel] [PATCH pmg-log-tracker 3/3] add testcase for accepted/blocked/quarantined mail

Mira Limbeck m.limbeck at proxmox.com
Fri May 15 16:49:06 CEST 2020


The testcase contains a mail that is accepted for one address, blocked
for another and quarantined for a third address.

Signed-off-by: Mira Limbeck <m.limbeck at proxmox.com>
---
 .../test_input_mixed_accept_block_quarantine  | 32 +++++++++++++++++
 ...before_queue_mixed_accept_block_quarantine | 35 +++++++++++++++++++
 tests/tests_before_queue.rs                   | 22 ++++++++++++
 3 files changed, 89 insertions(+)
 create mode 100644 tests/test_input_mixed_accept_block_quarantine
 create mode 100644 tests/test_output_before_queue_mixed_accept_block_quarantine

diff --git a/tests/test_input_mixed_accept_block_quarantine b/tests/test_input_mixed_accept_block_quarantine
new file mode 100644
index 0000000..29b21fb
--- /dev/null
+++ b/tests/test_input_mixed_accept_block_quarantine
@@ -0,0 +1,32 @@
+Apr 30 15:40:39 pmg6 postfix/postscreen[21614]: CONNECT from [2001:DB8:1:12::75]:38778 to [2001:DB8:1:12::66]:25
+Apr 30 15:40:39 pmg6 postfix/postscreen[21614]: WHITELISTED [2001:DB8:1:12::75]:38778
+Apr 30 15:40:39 pmg6 postfix/smtpd[21615]: connect from unknown[2001:DB8:1:12::75]
+Apr 30 15:40:39 pmg6 postfix/smtpd[21615]: Anonymous TLS connection established from unknown[2001:DB8:1:12::75]: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)
+Apr 30 15:40:39 pmg6 postfix/smtpd[21615]: NOQUEUE: client=unknown[2001:DB8:1:12::75]
+Apr 30 15:40:39 pmg6 pmg-smtp-filter[21528]: 2020/04/30-15:44:39 CONNECT TCP Peer: "[127.0.0.1]:35450" Local: "[127.0.0.1]:10024"
+Apr 30 15:40:39 pmg6 pmg-smtp-filter[21528]: reloading configuration Proxmox_ruledb
+Apr 30 15:40:39 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: new mail message-id=<20200430134439.GE6794 at test@localdomain>
+Apr 30 15:40:40 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: SA score=1/5 time=0.950 bayes=undefined autolearn=disabled hits=KAM_DMARC_STATUS(0.01),RDNS_NONE(1.274),SPF_HELO_PASS(-0.001),SPF_PASS(-0.001)
+Apr 30 15:40:40 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: moved mail for <quarantined at test.recipient.example> to spam quarantine - 612405EAAD648755DD (rule: testrule)
+Apr 30 15:40:40 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: block mail to <blocked at test.recipient.example> (rule: Blacklist)
+Apr 30 15:40:40 pmg6 postfix/smtpd[21631]: connect from localhost[127.0.0.1]
+Apr 30 15:40:40 pmg6 postfix/smtpd[21631]: E1C6561393: client=localhost[127.0.0.1], orig_client=unknown[2001:DB8:1:12::75]
+Apr 30 15:40:40 pmg6 postfix/cleanup[21632]: E1C6561393: message-id=<20200430134439.GE6794 at test@localdomain>
+Apr 30 15:40:41 pmg6 postfix/qmgr[23452]: E1C6561393: from=<senduser at test@localdomain>, size=1436, nrcpt=1 (queue active)
+Apr 30 15:40:41 pmg6 postfix/smtpd[21631]: disconnect from localhost[127.0.0.1] ehlo=1 xforward=1 mail=1 rcpt=1 data=1 commands=5
+Apr 30 15:40:41 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: accept mail to <reject at test.recipient.example> (E1C6561393) (rule: default-accept)
+Apr 30 15:40:41 pmg6 postfix/smtp[21626]: Untrusted TLS connection established to 192.0.2.69[192.0.2.69]:25: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)
+Apr 30 15:40:41 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: processing time: 1.61 seconds (0.95, 0.018, 0)
+Apr 30 15:40:41 pmg6 postfix/smtpd[21615]: proxy-accept: END-OF-MESSAGE: 250 2.5.0 OK (611D85EAAD6477B053); from=<senduser at test@localdomain> to=<blocked at test.recipient.example> proto=ESMTP helo=<test at localdomain>
+Apr 29 15:40:41 pmg6 postfix/smtpd[21615]: disconnect from unknown[2001:DB8:1:12::75] ehlo=2 starttls=1 mail=1 rcpt=3 data=1 quit=1 commands=9
+Apr 30 15:40:41 pmg6 postfix/smtp[21626]: E1C6561393: to=<reject at test.recipient.example>, relay=192.0.2.69[192.0.2.69]:25, delay=0.73, delays=0.19/0/0.05/0.5, dsn=5.7.1, status=bounced (host 192.0.2.69[192.0.2.69] said: 554 5.7.1 <reject at test.recipient.example>: Recipient address rejected: no mail for reject@ (in reply to RCPT TO command))
+Apr 30 15:40:41 pmg6 postfix/cleanup[21632]: A0AC6614A6: message-id=<20200430134441.A0AC6614A6 at pmg6.rosa.proxmox.com>
+Apr 30 15:40:42 pmg6 postfix/bounce[21633]: E1C6561393: sender non-delivery notification: A0AC6614A6
+Apr 30 15:40:42 pmg6 postfix/qmgr[23452]: A0AC6614A6: from=<>, size=3628, nrcpt=1 (queue active)
+Apr 30 15:40:42 pmg6 postfix/qmgr[23452]: E1C6561393: removed
+Apr 30 15:40:42 pmg6 postfix/smtp[21624]: Untrusted TLS connection established to test at localdomain[192.0.2.70]:25: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)
+Apr 30 15:40:42 pmg6 postfix/smtp[21624]: A0AC6614A6: to=<senduser at test@localdomain>, relay=test at localdomain[192.0.2.70]:25, delay=0.68, delays=0.6/0/0.05/0.03, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 4BD25601F4)
+Apr 30 15:40:42 pmg6 postfix/qmgr[23452]: A0AC6614A6: removed
+Apr 30 15:40:51 pmg6 pmg-smtp-filter[21523]: starting database maintainance
+Apr 30 15:40:51 pmg6 pmg-smtp-filter[21523]: end database maintainance (587 ms)
+
diff --git a/tests/test_output_before_queue_mixed_accept_block_quarantine b/tests/test_output_before_queue_mixed_accept_block_quarantine
new file mode 100644
index 0000000..7495a78
--- /dev/null
+++ b/tests/test_output_before_queue_mixed_accept_block_quarantine
@@ -0,0 +1,35 @@
+# LogReader: 9969
+# Query options
+# Start: 2020-04-30 15:40:00 (1588261200)
+# End: 2020-04-30 16:20:00 (1588263600)
+# End Query Options
+
+QENTRY: E1C6561393
+CTIME: 5EAAF183
+SIZE: 1436
+CLIENT: localhost[127.0.0.1],
+MSGID: <20200430134439.GE6794 at test@localdomain>
+TO:5EAAF179:E1C6561393:R: from <senduser at test@localdomain> to <reject at test.recipient.example> (192.0.2.69[192.0.2.69]:25)
+TO:5EAAF178:E1C6561393:B: from <senduser at test@localdomain> to <blocked at test.recipient.example> (none)
+TO:5EAAF178:E1C6561393:Q: from <senduser at test@localdomain> to <quarantined at test.recipient.example> (612405EAAD648755DD)
+SMTP:
+L00000003 Apr 30 15:40:39 pmg6 postfix/smtpd[21615]: connect from unknown[2001:DB8:1:12::75]
+L00000004 Apr 30 15:40:39 pmg6 postfix/smtpd[21615]: Anonymous TLS connection established from unknown[2001:DB8:1:12::75]: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)
+L00000005 Apr 30 15:40:39 pmg6 postfix/smtpd[21615]: NOQUEUE: client=unknown[2001:DB8:1:12::75]
+L0000000C Apr 30 15:40:40 pmg6 postfix/smtpd[21631]: connect from localhost[127.0.0.1]
+L0000000D Apr 30 15:40:40 pmg6 postfix/smtpd[21631]: E1C6561393: client=localhost[127.0.0.1], orig_client=unknown[2001:DB8:1:12::75]
+L00000010 Apr 30 15:40:41 pmg6 postfix/smtpd[21631]: disconnect from localhost[127.0.0.1] ehlo=1 xforward=1 mail=1 rcpt=1 data=1 commands=5
+L00000014 Apr 30 15:40:41 pmg6 postfix/smtpd[21615]: proxy-accept: END-OF-MESSAGE: 250 2.5.0 OK (611D85EAAD6477B053); from=<senduser at test@localdomain> to=<blocked at test.recipient.example> proto=ESMTP helo=<test at localdomain>
+FILTER: 611D85EAAD6477B053
+L00000008 Apr 30 15:40:39 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: new mail message-id=<20200430134439.GE6794 at test@localdomain>
+L00000009 Apr 30 15:40:40 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: SA score=1/5 time=0.950 bayes=undefined autolearn=disabled hits=KAM_DMARC_STATUS(0.01),RDNS_NONE(1.274),SPF_HELO_PASS(-0.001),SPF_PASS(-0.001)
+L0000000A Apr 30 15:40:40 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: moved mail for <quarantined at test.recipient.example> to spam quarantine - 612405EAAD648755DD (rule: testrule)
+L0000000B Apr 30 15:40:40 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: block mail to <blocked at test.recipient.example> (rule: Blacklist)
+L00000011 Apr 30 15:40:41 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: accept mail to <reject at test.recipient.example> (E1C6561393) (rule: default-accept)
+L00000013 Apr 30 15:40:41 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: processing time: 1.61 seconds (0.95, 0.018, 0)
+QMGR:
+L0000000E Apr 30 15:40:40 pmg6 postfix/cleanup[21632]: E1C6561393: message-id=<20200430134439.GE6794 at test@localdomain>
+L0000000F Apr 30 15:40:41 pmg6 postfix/qmgr[23452]: E1C6561393: from=<senduser at test@localdomain>, size=1436, nrcpt=1 (queue active)
+L00000015 Apr 30 15:40:41 pmg6 postfix/smtp[21626]: E1C6561393: to=<reject at test.recipient.example>, relay=192.0.2.69[192.0.2.69]:25, delay=0.73, delays=0.19/0/0.05/0.5, dsn=5.7.1, status=bounced (host 192.0.2.69[192.0.2.69] said: 554 5.7.1 <reject at test.recipient.example>: Recipient address rejected: no mail for reject@ (in reply to RCPT TO command))
+L00000019 Apr 30 15:40:42 pmg6 postfix/qmgr[23452]: E1C6561393: removed
+
diff --git a/tests/tests_before_queue.rs b/tests/tests_before_queue.rs
index 4c5d813..025ac70 100644
--- a/tests/tests_before_queue.rs
+++ b/tests/tests_before_queue.rs
@@ -180,3 +180,25 @@ fn before_queue_mixed_downstream() {
     let output_reader = BufReader::new(&output.stdout[..]);
     utils::compare_output(output_reader, expected_output);
 }
+
+#[test]
+fn before_queue_mixed_accept_block_quarantine() {
+    let output = Command::new(utils::log_tracker_path())
+        .arg("-vv")
+        .arg("-s")
+        .arg("1588254000")
+        .arg("-e")
+        .arg("1588255200")
+        .arg("-i")
+        .arg("tests/test_input_mixed_accept_block_quarantine")
+        .arg("-n")
+        .output()
+        .expect("failed to execute pmg-log-tracker");
+
+    let expected_file = File::open("tests/test_output_before_queue_mixed_accept_block_quarantine")
+        .expect("failed to open test_output");
+
+    let expected_output = BufReader::new(&expected_file);
+    let output_reader = BufReader::new(&output.stdout[..]);
+    utils::compare_output(output_reader, expected_output);
+}
-- 
2.20.1




More information about the pmg-devel mailing list