From: Baptiste Daroussin Date: Thu, 13 Apr 2023 09:12:52 +0000 (+0200) Subject: moderation: cover with tests the subscribtion moderation X-Git-Tag: RELEASE_1_4_0b1~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5b960b0f376bdd672b9ed9d2ad2092548bdb384;p=thirdparty%2Fmlmmj.git moderation: cover with tests the subscribtion moderation --- diff --git a/tests/mlmmj-receive.sh b/tests/mlmmj-receive.sh index 2068b5d1..fcffcc35 100755 --- a/tests/mlmmj-receive.sh +++ b/tests/mlmmj-receive.sh @@ -14,7 +14,8 @@ tests_init \ ctrl_list \ ctrl_help \ ctrl_faq \ - ctrl_get + ctrl_get \ + subscription_moderation mlmmjreceive=$(command -v mlmmj-receive) @@ -1647,4 +1648,191 @@ EOF atf_check -o file:expected-1.txt sed -e "/^Message-ID:/d; /^Date:/d" mail-2.txt } +subscription_moderation_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/owner + touch list/control/submod + +cat > subs < expected-1.txt < +RCPT TO: +DATA +Subject: =?utf-8?q?Confirm_subscription_to_test=40mlmmjtest?= +From: test+help@mlmmjtest +To: bob@test +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8bit +Reply-To: test+confsub-@mlmmjtest + +Hi, this is the Mlmmj program managing the mailing list. + +Somebody (and we hope it was you) has requested that your email address + be added to the list. This means every time a post is sent to +the list, you will receive a copy of it. + +To confirm you want to do this, please send a message to + which can usually be done simply +by replying to this message. The subject and the body of the message can be +anything. + +After doing so, you should receive a reply informing you that the operation +succeeded. + +If you do not want to do this, simply ignore this message. + + +. +QUIT +EOF + atf_check -o file:expected-1.txt sed -e "/^Message-ID:/d; /^Date:/d; s/confsub-.*@mlmmjtest/confsub-@mlmmjtest/g" mail-1.txt + var=$(ls list/subconf) + cat > confirm << EOF +From: bob@test +To: test+confsub-${var##*/}@mlmmjtest +Return-Path: bob@test +Subject: subscribe + +this is a subscribtion test +EOF + atf_check $mlmmjreceive -L list -F expected-2.txt < +RCPT TO: +DATA +Subject: =?utf-8?q?Awaiting_permission_to_join_test=40mlmmjtest?= +From: test+owner@mlmmjtest +To: bob@test +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8bit + +Hi, this is the Mlmmj program managing the mailing list. + +Your request to join the list has been received. However, the gatekeepers +are being asked to review it before permitting you to join. + + +. +QUIT +EOF + atf_check -o file:expected-2.txt sed -e "/^Message-ID:/d; /^Date:/d" mail-2.txt + cat > expected-3.txt << EOF +EHLO heloname +MAIL FROM: +RCPT TO: +DATA +Subject: =?utf-8?q?Subscription_request_for_test=40mlmmjtest:_bob=40test?= +From: test+owner@mlmmjtest +To: test-moderators@mlmmjtest +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8bit +Reply-To: test+permit-@mlmmjtest + +Hi, this is the Mlmmj program managing the mailing list. + +There has been a request from to join the normal version of the +list. + +To permit this, please send a message to + which can usually be done simply +by replying to this message. + +If you do not want to do this, either send a message to + or simply ignore this message. + +The following gatekeepers have received this mail: +- me@modos + + +. +QUIT +EOF + atf_check -o file:expected-3.txt sed -e "/^Message-ID:/d; /^Date:/d; s/permit-.*@mlmmjtest/permit-@mlmmjtest/g; s/obstruct-.*@mlmmjtest/obstruct-@mlmmjtest/g" mail-3.txt + var=$(ls list/moderation/subscribe*) + cat > reject << EOF +From: me@modos +To: test+obstruct-${var##*/subscribe}@mlmmjtest +Return-Path: bob@test +Subject: subscribe + +this is a subscribtion test +EOF + atf_check $mlmmjreceive -L list -F confirm << EOF +From: bob@test +To: test+confsub-${var##*/}@mlmmjtest +Return-Path: bob@test +Subject: subscribe + +this is a subscribtion test +EOF + atf_check $mlmmjreceive -L list -F permit << EOF +From: me@modos +To: test+permit-${var##*/subscribe}@mlmmjtest +Return-Path: bob@test +Subject: subscribe +this is a subscribtion test +EOF + atf_check $mlmmjreceive -L list -F expected-7.txt << EOF +EHLO heloname +MAIL FROM: +RCPT TO: +DATA +Subject: =?utf-8?q?Welcome_to_test=40mlmmjtest?= +From: test+help@mlmmjtest +To: bob@test +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8bit + +Hi, this is the Mlmmj program managing the mailing list. + +A gatekeeper has permitted you to join us. You have now been added to the +normal version of the list. + +The email address you are subscribed with is . + +If you ever wish to unsubscribe, send a message to + using this email address. The subject and the +body of the message can be anything. You will then receive confirmation or +further instructions. + +For other information and help about this list, send a message to +. + + +. +QUIT +EOF + atf_check -o file:expected-7.txt sed -e "/^Message-ID:/d; /^Date:/d;" mail-7.txt +}