From d1dde9d3e1cad87bd31998189a16b428835742ba Mon Sep 17 00:00:00 2001 From: Stoiko Ivanov Date: Thu, 30 Apr 2020 17:01:50 +0200 Subject: [PATCH] add test for before queue dstatus Reviewed-By: Mira Limbeck Tested-By: Mira Limbeck Signed-off-by: Stoiko Ivanov --- tests/test_input_mixed | 32 +++++++++++++++++++ .../test_output_before_queue_mixed_downstream | 21 ++++++++++++ tests/tests_before_queue.rs | 21 ++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 tests/test_output_before_queue_mixed_downstream diff --git a/tests/test_input_mixed b/tests/test_input_mixed index d3ce10d..3d2e319 100644 --- a/tests/test_input_mixed +++ b/tests/test_input_mixed @@ -100,3 +100,35 @@ Dec 18 15:55:44 pmg pmg-smtp-filter[1565]: 3802E45DFA503808B06: block mail to

, relay=127.0.0.1[127.0.0.1]:10023, delay=0.07, delays=0.02/0.01/0.02/0.02, dsn=2.7.0, status=sent (250 2.7.0 BLOCKED (3802E45DFA503808B06)) Dec 18 15:55:44 pmg postfix/qmgr[24651]: 0022C3801B5: removed +Dec 18 16:00:00 pmg something[12345]: BEFORE QUEUE LOGS2 START +Dec 18 16:00:50 pmg postfix/postscreen[26369]: CONNECT from [2001:DB8:1:12::75]:38768 to [2001:DB8:1:12::66]:25 +Dec 18 16:00:50 pmg postfix/postscreen[26369]: WHITELISTED [2001:DB8:1:12::75]:38768 +Dec 18 16:00:50 pmg postfix/smtpd[26419]: connect from unknown[2001:DB8:1:12::75] +Dec 18 16:00:50 pmg postfix/smtpd[26419]: 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) +Dec 18 16:00:50 pmg postfix/smtpd[26419]: NOQUEUE: client=unknown[2001:DB8:1:12::75] +Dec 18 16:00:50 pmg pmg-smtp-filter[26453]: 2020/04/28-19:13:50 CONNECT TCP Peer: "[127.0.0.1]:33692" Local: "[127.0.0.1]:10024" +Dec 18 16:00:50 pmg pmg-smtp-filter[26453]: 636D55EA8644E0FE2B: new mail message-id=<20200428171349.GC5963@test.localdomain> +Dec 18 16:00:50 pmg pmg-smtp-filter[26443]: starting database maintainance +Dec 18 16:00:50 pmg pmg-smtp-filter[26443]: end database maintainance (21 ms) +Dec 18 16:00:50 pmg pmg-smtp-filter[26453]: 636D55EA8644E0FE2B: SA score=1/5 time=0.674 bayes=undefined autolearn=disabled hits=BODY_SINGLE_WORD(0.001),KAM_DMARC_STATUS(0.01),RDNS_NONE(1.274),SPF_HELO_PASS(-0.001),SPF_PASS(-0.001) +Dec 18 16:00:50 pmg postfix/smtpd[26461]: connect from localhost[127.0.0.1] +Dec 18 16:00:50 pmg postfix/smtpd[26461]: B8010636D6: client=localhost[127.0.0.1], orig_client=unknown[2001:DB8:1:12::75] +Dec 18 16:00:50 pmg postfix/cleanup[26374]: B8010636D6: message-id=<20200428171349.GC5963@test.localdomain> +Dec 18 16:00:50 pmg postfix/qmgr[23452]: B8010636D6: from=, size=1436, nrcpt=3 (queue active) +Dec 18 16:00:50 pmg postfix/smtpd[26461]: disconnect from localhost[127.0.0.1] ehlo=1 xforward=1 mail=1 rcpt=3 data=1 commands=7 +Dec 18 16:00:50 pmg pmg-smtp-filter[26453]: 636D55EA8644E0FE2B: accept mail to (B8010636D6) (rule: default-accept) +Dec 18 16:00:50 pmg pmg-smtp-filter[26453]: 636D55EA8644E0FE2B: accept mail to (B8010636D6) (rule: default-accept) +Dec 18 16:00:50 pmg pmg-smtp-filter[26453]: 636D55EA8644E0FE2B: accept mail to (B8010636D6) (rule: default-accept) +Dec 18 16:00:50 pmg postfix/smtp[26376]: Untrusted TLS connection established to 192.0.2.0.69[192.0.2.0.69]:25: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) +Dec 18 16:00:50 pmg pmg-smtp-filter[26453]: 636D55EA8644E0FE2B: processing time: 0.701 seconds (0.674, 0.007, 0) +Dec 18 16:00:50 pmg postfix/smtpd[26419]: proxy-accept: END-OF-MESSAGE: 250 2.5.0 OK (636D55EA8644E0FE2B); from= to= proto=ESMTP helo= +Dec 18 16:00:50 pmg postfix/smtpd[26419]: disconnect from unknown[2001:DB8:1:12::75] ehlo=2 starttls=1 mail=1 rcpt=3 data=1 quit=1 commands=9 +Dec 18 16:00:50 pmg postfix/smtp[26376]: B8010636D6: to=, relay=192.0.2.0.69[192.0.2.0.69]:25, delay=0.06, delays=0.01/0/0.04/0.01, dsn=4.7.1, status=deferred (host 192.0.2.0.69[192.0.2.0.69] said: 450 4.7.1 : Recipient address rejected: no mail now for defer@ (in reply to RCPT TO command)) +Dec 18 16:00:50 pmg postfix/smtp[26376]: B8010636D6: to=, relay=192.0.2.0.69[192.0.2.0.69]:25, delay=0.07, delays=0.01/0/0.04/0.01, dsn=5.7.1, status=bounced (host 192.0.2.0.69[192.0.2.0.69] said: 554 5.7.1 : Recipient address rejected: no mail for reject@ (in reply to RCPT TO command)) +Dec 18 16:00:50 pmg postfix/smtp[26376]: B8010636D6: to=, relay=192.0.2.0.69[192.0.2.0.69]:25, delay=0.17, delays=0.01/0/0.04/0.12, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as C69576019F) +Dec 18 16:00:50 pmg postfix/cleanup[26420]: E2487636D9: message-id=<20200428171350.E2487636D9@pmg6.rosa.proxmox.com> +Dec 18 16:00:50 pmg postfix/bounce[26467]: B8010636D6: sender non-delivery notification: E2487636D9 +Dec 18 16:00:50 pmg postfix/qmgr[23452]: E2487636D9: from=<>, size=3628, nrcpt=1 (queue active) +Dec 18 16:00:50 pmg postfix/smtp[26463]: Untrusted TLS connection established to test.localdomain[192.0.2.0.70]:25: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) +Dec 18 16:00:51 pmg postfix/smtp[26463]: E2487636D9: to=, relay=test.localdomain[192.0.2.0.70]:25, delay=0.08, delays=0.01/0/0.04/0.03, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as F0C696026F) +Dec 18 16:00:51 pmg postfix/qmgr[23452]: E2487636D9: removed diff --git a/tests/test_output_before_queue_mixed_downstream b/tests/test_output_before_queue_mixed_downstream new file mode 100644 index 0000000..450f509 --- /dev/null +++ b/tests/test_output_before_queue_mixed_downstream @@ -0,0 +1,21 @@ +# LogReader: 28404 +# Query options +# Start: 2020-12-18 16:00:00 (1608307200) +# End: 2020-12-18 16:10:00 (1608307800) +# End Query Options + +QENTRY: E2487636D9 +CTIME: 5FDCD233 +SIZE: 3628 +MSGID: <20200428171350.E2487636D9@pmg6.rosa.proxmox.com> +TO:5FDCD233:E2487636D9:2: from <> to (test.localdomain[192.0.2.0.70]:25) + +QENTRY: B8010636D6 +CTIME: 5FDCD233 +SIZE: 1436 +CLIENT: localhost[127.0.0.1], +MSGID: <20200428171349.GC5963@test.localdomain> +TO:5FDCD232:B8010636D6:P: from to (192.0.2.0.69[192.0.2.0.69]:25) +TO:5FDCD232:B8010636D6:R: from to (192.0.2.0.69[192.0.2.0.69]:25) +TO:5FDCD232:B8010636D6:D: from to (192.0.2.0.69[192.0.2.0.69]:25) + diff --git a/tests/tests_before_queue.rs b/tests/tests_before_queue.rs index e6f42a7..4c5d813 100644 --- a/tests/tests_before_queue.rs +++ b/tests/tests_before_queue.rs @@ -159,3 +159,24 @@ fn before_queue_to() { let output_reader = BufReader::new(&output.stdout[..]); utils::compare_output(output_reader, expected_output); } + +#[test] +fn before_queue_mixed_downstream() { + let output = Command::new(utils::log_tracker_path()) + .arg("-v") + .arg("-s") + .arg("1608303600") + .arg("-e") + .arg("1608304200") + .arg("-i") + .arg("tests/test_input_mixed") + .output() + .expect("failed to execute pmg-log-tracker"); + + let expected_file = File::open("tests/test_output_before_queue_mixed_downstream") + .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.39.2