From: Baptiste Daroussin Date: Wed, 8 Mar 2023 17:05:52 +0000 (+0100) Subject: mlmmj-process: add tests for simple reception and subscription X-Git-Tag: RELEASE_1_4_0b1~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5807d1f916971e705ba14e38cdff2e210f563c5b;p=thirdparty%2Fmlmmj.git mlmmj-process: add tests for simple reception and subscription While here ensure we exit with failures in case we have a bad envelop --- diff --git a/src/mlmmj-process.c b/src/mlmmj-process.c index ab6f93a4..5f577e6b 100644 --- a/src/mlmmj-process.c +++ b/src/mlmmj-process.c @@ -749,7 +749,7 @@ int main(int argc, char **argv) free(discardname); free(randomstr); /* TODO: free emailstructs */ - exit(EXIT_SUCCESS); + exit(EXIT_FAILURE); } unlink(mailfile); diff --git a/tests/mlmmj-receive.sh b/tests/mlmmj-receive.sh index f2b83677..dbd9675d 100755 --- a/tests/mlmmj-receive.sh +++ b/tests/mlmmj-receive.sh @@ -3,12 +3,15 @@ . $(atf_get_srcdir)/test_env.sh tests_init \ - basics + basics \ + simple \ + subscribe + +mlmmjreceive=$(command -v mlmmj-receive) basics_body() { - mlmmjreceive=$(command -v mlmmj-receive) helptxt="Usage: $mlmmjreceive -L /path/to/listdir [-s sender@example.org] [-e extension] [-h] [-V] [-P] [-F] -h: This help @@ -65,3 +68,194 @@ EOF *) atf_fail "Extra files left" ;; esac } + +simple_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 + cat > incoming-invalid << EOF +From: bob@test +To: invalid@test +Subject: subscribe + +this is a subscribtion test +EOF + + atf_check -s exit:1 $mlmmjreceive -L list -F incoming << EOF +From: bob@test +To: invalid@test +Return-Path: jane@test +Subject: subscribe + +this is a subscribtion test +EOF + atf_check $mlmmjreceive -L list -F expected-1.txt << EOF +EHLO heloname +MAIL FROM: +RCPT TO: +DATA +Subject: =?utf-8?q?Post_to_test=40mlmmjtest_denied:_subscribe?= +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary +Content-Transfer-Encoding: 8bit +From: test+owner@mlmmjtest +To: bob@test + +--=RANDOM= +Content-Type: text/plain; charset=utf8 +Content-Transfer-Encoding: 8bit + +Hi, this is the Mlmmj program managing the mailing list. + +The message from with subject "subscribe" was unable to be +delivered to the list because the list address was not found in either the +To: or CC: header. + +(The denied message is below.) + +--=RANDOM= +Content-Type: message/rfc822 +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; filename="message.eml" + +From: bob@test +To: invalid@test +Subject: subscribe + +this is a subscribtion test +--=RANDOM=-- + +. +QUIT +EOF + atf_check -o file:expected-1.txt sed -e "/^Message-ID:/d; /^Date:/d; s/boundary=.*/boundary/g; s/--=.*=/--=RANDOM=/g" mail-1.txt + cat > incoming << EOF +From: bob@test +To: test@mlmmjtest +Return-Path: jane@test +Subject: subscribe + +this is a subscribtion test +EOF + cat > archived << EOF +From: bob@test +To: test@mlmmjtest +Subject: subscribe + +this is a subscribtion test +EOF + atf_check $mlmmjreceive -L list -F list/control/listaddress + echo "25678" > list/control/smtpport + echo "heloname" > list/control/smtphelo + + cat > incoming << EOF +From: bob@test +To: test+subscribe@mlmmjtest +Return-Path: jane@test +Subject: subscribe + +this is a subscribtion test +EOF + atf_check $mlmmjreceive -L list -F 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 > incoming << EOF +From: bob@test +To: test+confsub-${var}@mlmmjtest +Return-Path: jane@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?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. + +Thank you for confirming your subscription. 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-2.txt sed -e "/^Message-ID:/d; /^Date:/d" mail-2.txt + atf_check -o inline:"bob@test\n" cat list/subscribers.d/b +}