From 5cce7a774a7a1db533be6c00e374f83ed338025d Mon Sep 17 00:00:00 2001 From: Mira Limbeck Date: Fri, 15 May 2020 16:49:06 +0200 Subject: [PATCH] add testcase for accepted/blocked/quarantined mail 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 --- .../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@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 to spam quarantine - 612405EAAD648755DD (rule: testrule) +Apr 30 15:40:40 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: block mail to (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@test@localdomain> +Apr 30 15:40:41 pmg6 postfix/qmgr[23452]: E1C6561393: from=, 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 (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= to= proto=ESMTP helo= +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=, 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 : 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@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@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=, relay=test@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@test@localdomain> +TO:5EAAF179:E1C6561393:R: from to (192.0.2.69[192.0.2.69]:25) +TO:5EAAF178:E1C6561393:B: from to (none) +TO:5EAAF178:E1C6561393:Q: from to (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= to= proto=ESMTP helo= +FILTER: 611D85EAAD6477B053 +L00000008 Apr 30 15:40:39 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: new mail message-id=<20200430134439.GE6794@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 to spam quarantine - 612405EAAD648755DD (rule: testrule) +L0000000B Apr 30 15:40:40 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: block mail to (rule: Blacklist) +L00000011 Apr 30 15:40:41 pmg6 pmg-smtp-filter[21528]: 611D85EAAD6477B053: accept mail to (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@test@localdomain> +L0000000F Apr 30 15:40:41 pmg6 postfix/qmgr[23452]: E1C6561393: from=, size=1436, nrcpt=1 (queue active) +L00000015 Apr 30 15:40:41 pmg6 postfix/smtp[21626]: E1C6561393: to=, 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 : 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 b18cf10..e654cab 100644 --- a/tests/tests_before_queue.rs +++ b/tests/tests_before_queue.rs @@ -205,3 +205,25 @@ fn before_queue_from_to() { 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); +}