From 42c2634653c1ca5dca48ccb51a6c1949212ca6ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Gaspard?= Date: Wed, 25 Dec 2024 18:32:06 +0100 Subject: [PATCH] nixos/opensmtpd: fix opensmtpd test --- nixos/tests/opensmtpd.nix | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/nixos/tests/opensmtpd.nix b/nixos/tests/opensmtpd.nix index 6e848354c103..d5b5d0fcc356 100644 --- a/nixos/tests/opensmtpd.nix +++ b/nixos/tests/opensmtpd.nix @@ -22,12 +22,8 @@ import ./make-test-python.nix { extraServerArgs = [ "-v" ]; serverConfiguration = '' listen on 0.0.0.0 - action do_relay relay - # DO NOT DO THIS IN PRODUCTION! - # Setting up authentication requires a certificate which is painful in - # a test environment, but THIS WOULD BE DANGEROUS OUTSIDE OF A - # WELL-CONTROLLED ENVIRONMENT! - match from any for any action do_relay + action relay_smtp2 relay host "smtp://192.168.1.2" + match from any for any action relay_smtp2 ''; }; }; @@ -87,7 +83,7 @@ import ./make-test-python.nix { import smtplib, sys with smtplib.SMTP('192.168.1.1') as smtp: - smtp.sendmail('alice@[192.168.1.1]', 'bob@[192.168.1.2]', """ + smtp.sendmail('alice@smtp1', 'bob@smtp2', """ From: alice@smtp1 To: bob@smtp2 Subject: Test @@ -105,8 +101,8 @@ import ./make-test-python.nix { imap.select() status, refs = imap.search(None, 'ALL') assert status == 'OK' - assert len(refs) == 1 - status, msg = imap.fetch(refs[0], 'BODY[TEXT]') + assert len(refs) == 1 and refs[0] != "" + status, msg = imap.fetch(refs[0], '(BODY[TEXT])') assert status == 'OK' content = msg[0][1] print("===> content:", content)