]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
mlmm-unsub: Add basic test suite
authorBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 28 Oct 2021 15:10:37 +0000 (17:10 +0200)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 28 Oct 2021 15:10:37 +0000 (17:10 +0200)
tests/mlmmj-sub.sh

index d453394720f9e6315be785146a7178febb34ebfa..c1b89f1fc703cd058517f32717f28e9e16584a2f 100644 (file)
@@ -6,7 +6,11 @@ tests_init \
        add_normal \
        add_normal_owner \
        add_nomail \
-       add_digest
+       add_digest \
+       remove_normal \
+       remove_normal_owner \
+       remove_nomail \
+       remove_digest
 
 add_normal_body()
 {
@@ -54,3 +58,61 @@ add_nomail_body()
        atf_check -s exit:0 $mlmmjsub -L ml -a john@doe.org -n
        atf_check -o inline:"john@doe.org\n" cat ml/nomailsubs.d/j
 }
+
+remove_normal_body()
+{
+       init_ml ml
+       mlmmjsub=$(command -v mlmmj-unsub)
+       printf "To: test@mlmmjtest1\r\nSubject: test\n\nplop" > mail
+       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
+       atf_check -s exit:0 $mlmmjsub -L ml -a john@doe.org
+       atf_check -o inline:"bob@doe.org\nrebecca@doe.org\n" cat ml/subscribers.d/j
+       atf_check -s exit:0 $mlmmjsub -L ml -a jane@doe.org
+       atf_check -o inline:"bob@doe.org\nrebecca@doe.org\n" cat ml/subscribers.d/j
+}
+
+remove_normal_owner_body()
+{
+       init_ml ml
+       mlmmjsub=$(command -v mlmmj-unsub)
+       printf "To: test@mlmmjtest1\r\nSubject: test\n\nplop" > mail
+       echo 25678 > ml/control/smtpport
+       echo test@mlmmjtest > ml/control/listaddress
+       echo owner@mlmmjtest > ml/control/owner
+       echo "john@doe.org" > ml/subscribers.d/j
+       echo "bob@doe.org" >> ml/subscribers.d/j
+       echo "rebecca@doe.org" >> ml/subscribers.d/j
+       touch ml/control/notifysub
+       socat TCP-LISTEN:25678,bind=127.0.0.1,reuseport OPEN:output.log,creat,append &
+       atf_check -s exit:0 $mlmmjsub -L ml -a john@doe.org
+       atf_check -o inline:"bob@doe.org\nrebecca@doe.org\n" cat ml/subscribers.d/j
+       atf_check -o inline:"MAIL FROM:<test+bounces-help@mlmmjtest>\r\nRSET\r\n" cat output.log
+}
+
+remove_digest_body()
+{
+       init_ml ml
+       mlmmjsub=$(command -v mlmmj-unsub)
+       printf "To: test@mlmmjtest1\r\nSubject: test\n\nplop" > mail
+       echo test@mlmmjtest > ml/control/listaddress
+       echo "john@doe.org" > ml/digesters.d/j
+       echo "bob@doe.org" >> ml/digesters.d/j
+       atf_check -s exit:0 $mlmmjsub -L ml -a john@doe.org -d
+       atf_check -o inline:"bob@doe.org\n" cat ml/digesters.d/j
+}
+
+remove_nomail_body()
+{
+       init_ml ml
+       mlmmjsub=$(command -v mlmmj-unsub)
+       printf "To: test@mlmmjtest1\r\nSubject: test\n\nplop" > mail
+       echo test@mlmmjtest > ml/control/listaddress
+       echo "john@doe.org" > ml/nomailsubs.d/j
+       echo "bob@doe.org" >> ml/nomailsubs.d/j
+       echo "rebecca@doe.org" >> ml/nomailsubs.d/j
+       atf_check -s exit:0 $mlmmjsub -L ml -a john@doe.org -n
+       atf_check -o inline:"bob@doe.org\nrebecca@doe.org\n" cat ml/nomailsubs.d/j
+}