]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
listcontrol: add test when receiving a wrong reject email
authorBaptiste Daroussin <bapt@FreeBSD.org>
Fri, 14 Apr 2023 09:53:22 +0000 (11:53 +0200)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Fri, 14 Apr 2023 09:53:22 +0000 (11:53 +0200)
tests/mlmmj-receive.sh

index 883ac0c64d44f0addc920677048d9912c64e3de5..02283c8b8d62adb47484ac54c8abfa98dbe48d2d 100755 (executable)
@@ -17,7 +17,8 @@ tests_init \
        ctrl_get \
        subscription_moderation \
        moderation \
-       moderation_notmetoo
+       moderation_notmetoo \
+       moderation_reject_invalid
 
 mlmmjreceive=$(command -v mlmmj-receive)
 
@@ -2085,3 +2086,91 @@ QUIT
 EOF
        atf_check -o file:expected-3.txt sed -e "/^Message-ID:/d; /^Date:/d;" mail-3.txt
 }
+
+moderation_reject_invalid_body() {
+       atf_check $srcdir/fakesmtpd
+       trap kill_fakesmtp EXIT TERM
+       init_ml list
+       rmdir list/text
+       ln -s ${srcdir}/../listtexts/en list/text
+       echo test@mlmmjtest > list/control/listaddress
+       echo "25678" > list/control/smtpport
+       echo "heloname" > list/control/smtphelo
+
+       echo "me@modos" > list/control/moderators
+       touch list/control/moderated
+       touch list/control/notmetoo
+       printf "user@test\nuser2@test" > list/subscribers.d/u
+
+cat > first <<EOF
+From: bob@test
+To: test@mlmmjtest
+Return-path: bob@test
+Subject: yeah
+
+Let's go, first email
+EOF
+       atf_check -s exit:0 $mlmmjreceive -L list -F <first
+
+cat > expected-1.txt <<EOF
+EHLO heloname\r
+MAIL FROM:<test+owner@mlmmjtest>\r
+RCPT TO:<me@modos>\r
+DATA\r
+Subject: =?utf-8?q?Please_moderate_test=40mlmmjtest:_yeah?=\r
+MIME-Version: 1.0\r
+Content-Type: multipart/mixed;\r
+ boundary="boundary"\r
+Content-Transfer-Encoding: 8bit\r
+From: test+owner@mlmmjtest\r
+To: test-moderators@mlmmjtest\r
+Reply-To: test+release-@mlmmjtest\r
+\r
+--=boundary=\r
+Content-Type: text/plain; charset=utf8\r
+Content-Transfer-Encoding: 8bit\r
+\r
+Hi, this is the Mlmmj program managing the <test@mlmmjtest> mailing list.\r
+\r
+A message from <bob@test> with subject "yeah" has been submitted for\r
+posting. You are being asked to moderate because this is a moderated list.\r
+The message is below.\r
+\r
+To release it to the list, please send a message to\r
+<test+release-@mlmmjtest> which can usually be done simply\r
+by replying to this message.\r
+\r
+If you do not want to do any of this, either send a message to\r
+<test+reject-@mlmmjtest> or simply ignore this message.\r
+\r
+The following moderators have received this mail:\r
+- me@modos\r
+\r
+--=boundary=\r
+Content-Type: message/rfc822\r
+Content-Transfer-Encoding: 8bit\r
+Content-Disposition: inline; filename="message.eml"\r
+\r
+From: bob@test\r
+To: test@mlmmjtest\r
+Subject: yeah\r
+\r
+Let's go, first email\r
+--=boundary=--\r
+\r
+.\r
+QUIT\r
+EOF
+       atf_check -o file:expected-1.txt sed -e "/^Message-ID:/d; /^Date:/d; s/release-.*@mlmmjtest/release-@mlmmjtest/g; s/reject-.*@mlmmjtest/reject-@mlmmjtest/g; s/boundary=\".*\"/boundary=\"boundary\"/g; s/^--=.*=/--=boundary=/g" mail-1.txt
+       atf_check -s exit:1 test -f mail-2.txt
+       var=$(ls list/moderation/ | grep -v omit)
+       atf_check -o inline:"bob@test" cat list/moderation/${var}.omit
+       cat > reject << EOF
+From: test@modos
+To: test+reject-nopenope@mlmmjtest
+Return-path: test@modos
+EOF
+       atf_check -s exit:0 $mlmmjreceive -L list -F <reject
+       atf_check -s exit:0 test -f list/moderation/${var}
+       atf_check -s exit:0 test -f list/moderation/${var}.omit
+}