]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
mlmmj-unsub: test notifysub
authorBaptiste Daroussin <bapt@FreeBSD.org>
Mon, 6 Mar 2023 10:22:58 +0000 (11:22 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Mon, 6 Mar 2023 10:22:58 +0000 (11:22 +0100)
tests/mlmmj-sub.sh

index b50633fe219705875135563c79798a3f8214ad78..c8556ea7cddfef1531e81934833997e52982e380 100755 (executable)
@@ -27,6 +27,7 @@ tests_init \
        remove_basics \
        remove_normal \
        remove_normal_confirm \
+       remove_normal_confirm_and_send_owner \
        remove_normal_owner \
        remove_nomail \
        remove_digest
@@ -502,6 +503,147 @@ EOF
        atf_check -s exit:1 test -f mail-5.txt
 }
 
+remove_normal_confirm_and_send_owner_body()
+{
+       init_ml ml
+       mlmmjsub=$(command -v mlmmj-unsub)
+       atf_check $srcdir/fakesmtpd
+       trap kill_fakesmtp EXIT TERM
+       echo test@mlmmjtest > ml/control/listaddress
+       echo "john@doe.org" > ml/subscribers.d/j
+       echo "bob@doe.org" >> ml/subscribers.d/j
+       echo "rebecca@doe.org" >> ml/subscribers.d/j
+       echo "25678" > ml/control/smtpport
+       echo "heloname" > ml/control/smtphelo
+       touch ml/control/notifysub
+       rmdir ml/text
+       ln -s ${srcdir}/../listtexts/en ml/text
+       atf_check -s exit:0 $mlmmjsub -L ml -c -a john@doe.org
+       atf_check -o inline:"bob@doe.org\nrebecca@doe.org\n" cat ml/subscribers.d/j
+       cat > expected.txt << EOF
+EHLO heloname\r
+MAIL FROM:<test+bounces-help@mlmmjtest>\r
+RCPT TO:<john@doe.org>\r
+DATA\r
+Subject: =?utf-8?q?Goodbye_from_test=40mlmmjtest?=\r
+From: test+help@mlmmjtest\r
+To: john@doe.org\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: 8bit\r
+\r
+Hi, this is the Mlmmj program managing the <test@mlmmjtest> mailing list.\r
+\r
+An administrator has removed you from the list.\r
+\r
+\r
+.\r
+QUIT\r
+EOF
+       atf_check -s exit:0 test -f mail-2.txt
+       atf_check -o file:expected.txt sed -e "/^Message-ID:/d; /^Date:/d" mail-1.txt
+       cat > notify.txt << EOF
+EHLO heloname\r
+MAIL FROM:<test+bounces-help@mlmmjtest>\r
+RCPT TO:<test+owner@mlmmjtest>\r
+DATA\r
+Subject: =?utf-8?q?Unsubscribed_from_test=40mlmmjtest:_john=40doe.org?=\r
+From: test+owner@mlmmjtest\r
+To: test+owner@mlmmjtest\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: 8bit\r
+\r
+Hi, this is the Mlmmj program managing the <test@mlmmjtest> mailing list.\r
+\r
+The address <john@doe.org> has been unsubscribed from the list because an\r
+administrator commanded it.\r
+\r
+\r
+.\r
+QUIT\r
+EOF
+       atf_check -o file:notify.txt sed -e "/^Message-ID:/d; /^Date:/d" mail-2.txt
+       touch ml/control/notifysub
+       atf_check -s exit:0 $mlmmjsub -L ml -c -a john@doe.org
+       atf_check -o inline:"bob@doe.org\nrebecca@doe.org\n" cat ml/subscribers.d/j
+       cat > expected2.txt << EOF
+EHLO heloname\r
+MAIL FROM:<test+bounces-help@mlmmjtest>\r
+RCPT TO:<john@doe.org>\r
+DATA\r
+Subject: =?utf-8?q?Unable_to_unsubscribe_from_test=40mlmmjtest?=\r
+From: test+help@mlmmjtest\r
+To: john@doe.org\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: 8bit\r
+\r
+Hi, this is the Mlmmj program managing the <test@mlmmjtest> mailing list.\r
+\r
+You were unable to be unsubscribed from the list because you are not\r
+subscribed.\r
+\r
+If you are receiving messages, perhaps a different email address is\r
+subscribed. To find out which address you are subscribed with, refer to the\r
+message welcoming you to the list, or look at the envelope "Return-Path"\r
+header of a message you receive from the list.\r
+\r
+\r
+.\r
+QUIT\r
+EOF
+       atf_check -o file:expected2.txt sed -e "/^Message-ID:/d; /^Date:/d" mail-3.txt
+
+       echo "john@doe.org" >> ml/subscribers.d/j
+       atf_check -s exit:0 $mlmmjsub -L ml -c -a john@doe.org
+       atf_check -o inline:"bob@doe.org\nrebecca@doe.org\n" cat ml/subscribers.d/j
+       cat > expected3.txt << EOF
+EHLO heloname\r
+MAIL FROM:<test+bounces-help@mlmmjtest>\r
+RCPT TO:<john@doe.org>\r
+DATA\r
+Subject: =?utf-8?q?Goodbye_from_test=40mlmmjtest?=\r
+From: test+help@mlmmjtest\r
+To: john@doe.org\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: 8bit\r
+\r
+Hi, this is the Mlmmj program managing the <test@mlmmjtest> mailing list.\r
+\r
+An administrator has removed you from the list.\r
+\r
+\r
+.\r
+QUIT\r
+EOF
+       atf_check -o file:expected3.txt sed -e "/^Message-ID:/d; /^Date:/d" mail-4.txt
+       cat > expected4.txt << EOF
+EHLO heloname\r
+MAIL FROM:<test+bounces-help@mlmmjtest>\r
+RCPT TO:<test+owner@mlmmjtest>\r
+DATA\r
+Subject: =?utf-8?q?Unsubscribed_from_test=40mlmmjtest:_john=40doe.org?=\r
+From: test+owner@mlmmjtest\r
+To: test+owner@mlmmjtest\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: 8bit\r
+\r
+Hi, this is the Mlmmj program managing the <test@mlmmjtest> mailing list.\r
+\r
+The address <john@doe.org> has been unsubscribed from the list because an\r
+administrator commanded it.\r
+\r
+\r
+.\r
+QUIT\r
+EOF
+       atf_check -o file:expected4.txt sed -e "/^Message-ID:/d; /^Date:/d" mail-5.txt
+       atf_check -s exit:1 test -f mail-6.txt
+}
+
 remove_normal_owner_body()
 {
        init_ml ml