]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
mlmmj-sub: improve testing
authorBaptiste Daroussin <bapt@FreeBSD.org>
Fri, 17 Feb 2023 13:13:34 +0000 (14:13 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Fri, 17 Feb 2023 16:05:04 +0000 (17:05 +0100)
tests/mlmmj-sub.sh

index 871cf856f2866056b3d3826f01daab008de5e544..62b1f7c3df25a58867526e5089a982f01b5a2ed8 100755 (executable)
@@ -2,9 +2,18 @@
 
 . $(atf_get_srcdir)/test_env.sh
 
+kill_fakesmtp()
+{
+       pid=$(cat fakesmtp.pid)
+       kill -15 $pid
+}
+
 tests_init \
        add_basics \
        add_normal \
+       add_normal_welcome \
+       add_normal_welcome_confirm \
+       add_normal_welcome_moderate \
        add_normal_owner \
        add_nomail \
        add_digest \
@@ -32,6 +41,214 @@ add_normal_body()
        atf_check -o inline:"john@doe.org\njane@doe.org\n" cat ml/subscribers.d/j
 }
 
+add_normal_welcome_body()
+{
+       init_ml ml
+       mlmmjsub=$(command -v mlmmj-sub)
+       atf_check $srcdir/fakesmtpd
+       trap kill_fakesmtp EXIT TERM
+       echo test@mlmmjtest > ml/control/listaddress
+       echo "25678" > ml/control/smtpport
+       echo "heloname" > ml/control/smtphelo
+       rmdir ml/text
+       ln -s ${srcdir}/../listtexts/en ml/text
+       atf_check -s exit:0 $mlmmjsub -L ml -c -a john@doe.org
+       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?Welcome_to_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 subscribed you to the normal version of the list.\r
+\r
+The email address you are subscribed with is <john@doe.org>.\r
+\r
+If you ever wish to unsubscribe, send a message to\r
+<test+unsubscribe@mlmmjtest> using this email address. The subject and the\r
+body of the message can be anything. You will then receive confirmation or\r
+further instructions.\r
+\r
+For other information and help about this list, send a message to\r
+<test+help@mlmmjtest>.\r
+\r
+\r
+.\r
+QUIT\r
+EOF
+
+       atf_check -o file:expected.txt sed -e "/^Message-ID:/d; /^Date:/d" mail-1.txt
+       atf_check -o inline:"john@doe.org\n" cat ml/subscribers.d/j
+       atf_check -s exit:1 test -f mail-2.txt
+}
+
+add_normal_welcome_confirm_body()
+{
+       init_ml ml
+       mlmmjsub=$(command -v mlmmj-sub)
+       atf_check $srcdir/fakesmtpd
+       trap kill_fakesmtp EXIT TERM
+       echo test@mlmmjtest > ml/control/listaddress
+       echo "25678" > ml/control/smtpport
+       echo "heloname" > ml/control/smtphelo
+       rmdir ml/text
+       ln -s ${srcdir}/../listtexts/en ml/text
+       atf_check -s exit:0 $mlmmjsub -L ml -c -C -a john@doe.org
+       cat > expected.txt <<EOF
+EHLO heloname\r
+MAIL FROM:<test+bounces-confsub-@mlmmjtest>\r
+RCPT TO:<john@doe.org>\r
+DATA\r
+Subject: =?utf-8?q?Confirm_subscription_to_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
+Reply-To: test+confsub-@mlmmjtest\r
+\r
+Hi, this is the Mlmmj program managing the <test@mlmmjtest> mailing list.\r
+\r
+An administrator has requested that your email address <john@doe.org> be\r
+added to the list. This means every time a post is sent to the list, you\r
+will receive a copy of it.\r
+\r
+To confirm you want to do this, please send a message to\r
+<test+confsub-@mlmmjtest> which can usually be done simply\r
+by replying to this message. The subject and the body of the message can be\r
+anything.\r
+\r
+After doing so, you should receive a reply informing you that the operation\r
+succeeded.\r
+\r
+If you do not want to do this, simply ignore this message.\r
+\r
+\r
+.\r
+QUIT\r
+EOF
+
+       atf_check -o file:expected.txt sed -e "/^Message-ID:/d; /^Date:/d; s/confsub-.*@mlmmjtest/confsub-@mlmmjtest/g" mail-1.txt
+       atf_check -s exit:1 test -f ml/subscribers.d/j
+       atf_check -o match:"^ml/subconf/.*" find ml/subconf/ -type f
+       atf_check -s exit:1 test -f mail-2.txt
+}
+
+add_normal_welcome_moderate_body()
+{
+       init_ml ml
+       mlmmjsub=$(command -v mlmmj-sub)
+       atf_check $srcdir/fakesmtpd
+       trap kill_fakesmtp EXIT TERM
+       echo test@mlmmjtest > ml/control/listaddress
+       echo "25678" > ml/control/smtpport
+       echo "heloname" > ml/control/smtphelo
+       rmdir ml/text
+       ln -s ${srcdir}/../listtexts/en ml/text
+       cat > ml/control/submod <<EOF
+modo1@test
+modo2@test
+EOF
+       atf_check -s exit:0 $mlmmjsub -L ml -c -a john@doe.org
+       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?Awaiting_permission_to_join_test=40mlmmjtest?=\r
+From: test+owner@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
+Your request to join the list has been received. However, the gatekeepers\r
+are being asked to review it before permitting you to join.\r
+\r
+\r
+.\r
+QUIT\r
+EOF
+
+       cat > expected-modos.txt <<EOF
+EHLO heloname\r
+MAIL FROM:<test+owner@mlmmjtest>\r
+RCPT TO:<modo1@test>\r
+DATA\r
+Subject: =?utf-8?q?Subscription_request_for_test=40mlmmjtest:_john=40doe.org?=\r
+From: test+owner@mlmmjtest\r
+To: test-moderators@mlmmjtest\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: 8bit\r
+Reply-To: test+permit-@mlmmjtest\r
+\r
+Hi, this is the Mlmmj program managing the <test@mlmmjtest> mailing list.\r
+\r
+There has been a request from <john@doe.org> to join the normal version of\r
+the list.\r
+\r
+To permit this, please send a message to\r
+<test+permit-@mlmmjtest> which can usually be done simply\r
+by replying to this message.\r
+\r
+If you do not want to do this, either send a message to\r
+<test+obstruct-@mlmmjtest> or simply ignore this message.\r
+\r
+The following gatekeepers have received this mail:\r
+- modo1@test\r
+- modo2@test\r
+\r
+\r
+.\r
+MAIL FROM:<test+owner@mlmmjtest>\r
+RCPT TO:<modo2@test>\r
+DATA\r
+Subject: =?utf-8?q?Subscription_request_for_test=40mlmmjtest:_john=40doe.org?=\r
+From: test+owner@mlmmjtest\r
+To: test-moderators@mlmmjtest\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: 8bit\r
+Reply-To: test+permit-@mlmmjtest\r
+\r
+Hi, this is the Mlmmj program managing the <test@mlmmjtest> mailing list.\r
+\r
+There has been a request from <john@doe.org> to join the normal version of\r
+the list.\r
+\r
+To permit this, please send a message to\r
+<test+permit-@mlmmjtest> which can usually be done simply\r
+by replying to this message.\r
+\r
+If you do not want to do this, either send a message to\r
+<test+obstruct-@mlmmjtest> or simply ignore this message.\r
+\r
+The following gatekeepers have received this mail:\r
+- modo1@test\r
+- modo2@test\r
+\r
+\r
+.\r
+QUIT\r
+EOF
+       atf_check -o file:expected.txt sed -e "/^Message-ID:/d; /^Date:/d" mail-1.txt
+       atf_check -s exit:1 test -f ml/subscribers.d/j
+       atf_check -o file:expected-modos.txt sed -e "/^Message-ID:/d; /^Date:/d; s/permit-.*@mlmmjtest/permit-@mlmmjtest/g; s/obstruct-.*@mlmmjtest/obstruct-@mlmmjtest/g" mail-2.txt
+       atf_check -s exit:1 test -f mail-3.txt
+       atf_check -o match:"^ml/moderation/subscribe.*" find ml/moderation/ -type f
+       atf_check -o inline:"john@doe.org\nSUB_NORMAL\n" cat ml/moderation/subscribe*
+}
+
 add_normal_then_nomail_body()
 {
        init_ml ml