Эх сурвалжийг харах

fix tests to run in temp dir

Pi 1 жил өмнө
parent
commit
6b7ea64cd6

+ 3 - 2
cropswap-register.sh

@@ -4,8 +4,9 @@ GROUP="$1"
 ALIAS="$2"
 EMAIL="$3"
 
-./cropswap-postmaster.sh SIGNUP "$GROUP" "$EMAIL" <<EOF
+SCRIPTDIR=$(readlink -e "${BASH_SOURCE[0]%/*}")
+${SCRIPTDIR}/cropswap-postmaster.sh SIGNUP "$GROUP" "$EMAIL" <<EOF
 X-MEMBER-ALIAS: $ALIAS
 X-AUTH:
 EOF
-./cropswap-postmaster.sh SUBSCRIBE "$GROUP" "$EMAIL"
+${SCRIPTDIR}/cropswap-postmaster.sh SUBSCRIBE "$GROUP" "$EMAIL"

+ 62 - 18
test.sh

@@ -2,53 +2,97 @@
 set -euo pipefail
 export DEBUG=1
 export TEST=1
-MAILDROPDIR=$(pwd) #$(mktemp -d)
-mkdir -p ${MAILDROPDIR}/cropswap@shandan.one
+MAILDROPDIR=$(mktemp -d)
 cleanup (){
-	#rm -rf "$MAILDROPDIR"
-	echo
+	rm -rf "$MAILDROPDIR"
 }
 trap cleanup EXIT
 
 export MAILDROPDIR
-./cropswap-register.sh cropswap@shandan.one "Member" "member1@mail.com" &>/dev/null
-./cropswap-register.sh cropswap@shandan.one "Member" "member2@mail.com" &>/dev/null
-./cropswap-postmaster.sh SIGNUP cropswap@shandan.one organizer1@mail.com <<EOF &>/dev/null
+
+SCRIPTDIR=$(readlink -e "${BASH_SOURCE[0]%/*}")
+cd "$MAILDROPDIR"
+
+#
+# TEST cropswap@shandan.one
+mkdir cropswap@shandan.one
+${SCRIPTDIR}/cropswap-register.sh cropswap@shandan.one "Member" "member1@mail.com" &>/dev/null
+${SCRIPTDIR}/cropswap-register.sh cropswap@shandan.one "Member" "member2@mail.com" &>/dev/null
+${SCRIPTDIR}/cropswap-postmaster.sh SIGNUP cropswap@shandan.one organizer1@mail.com <<EOF &>/dev/null
 X-MEMBER-ALIAS: Organizer
 X-AUTH: admin
 EOF
-./cropswap-postmaster.sh SUBSCRIBE cropswap@shandan.one organizer1@mail.com &>/dev/null
-./cropswap-postmaster.sh SIGNUP cropswap@shandan.one organizer2@mail.com <<EOF &>/dev/null
+${SCRIPTDIR}/cropswap-postmaster.sh SUBSCRIBE cropswap@shandan.one organizer1@mail.com &>/dev/null
+${SCRIPTDIR}/cropswap-postmaster.sh SIGNUP cropswap@shandan.one organizer2@mail.com <<EOF &>/dev/null
 X-MEMBER-ALIAS: Organizer
 X-AUTH: admin
 EOF
-./cropswap-postmaster.sh SUBSCRIBE cropswap@shandan.one organizer2@mail.com &>/dev/null
+${SCRIPTDIR}/cropswap-postmaster.sh SUBSCRIBE cropswap@shandan.one organizer2@mail.com &>/dev/null
 
 set -x
-maildrop -fmember1@mail.com < tests/cropswap@shandan.one/from-member.eml 1>"${MAILDROPDIR}/forward.out" 2>"${MAILDROPDIR}/forward.err"
-grep '^From: Member <cropswap@shandan.one>$' < forward.out
+maildrop -funregistered@mail.com < ${SCRIPTDIR}/tests/cropswap@shandan.one/from-unregistered.eml 1>forward.out 2>forward.err
+grep '^From: A. Person <unregistered@mail.com>$' < forward.out
+grep '^To: A. Person <unregistered@mail.com>$' < forward.out && false
 grep '^To: Organizer <organizer1@mail.com>$' < forward.out
 grep '^To: Organizer 1 <organizer2@mail.com>$' < forward.out
+grep '^To: Member <member1@mail.com>$' < forward.out && false
+grep '^To: Member 1 <member2@mail.com>$' < forward.out && false
 grep '^Subject: \[Crop Swap Query\] .*$' < forward.out
 
-maildrop -funregistered@mail.com < tests/cropswap@shandan.one/from-unregistered.eml 1>"${MAILDROPDIR}/forward.out" 2>"${MAILDROPDIR}/forward.err"
-grep '^From: A. Person <unregistered@mail.com>$' < forward.out
+maildrop -fmember1@mail.com < ${SCRIPTDIR}/tests/cropswap@shandan.one/from-member.eml 1>forward.out 2>forward.err
+grep '^From: Member <cropswap@shandan.one>$' < forward.out
+grep '^To: Member <member1@mail.com>$' < forward.out && false
 grep '^To: Organizer <organizer1@mail.com>$' < forward.out
 grep '^To: Organizer 1 <organizer2@mail.com>$' < forward.out
-grep '^To: Member <member1@mail.com>$' < forward.out && false
-grep '^To: Member 1 <member2@mail.com>$' < forward.out && false
 grep '^Subject: \[Crop Swap Query\] .*$' < forward.out
 
-maildrop -forganizer1@mail.com < tests/cropswap@shandan.one/from-organizer-to-member.eml 1>"${MAILDROPDIR}/forward.out" 2>"${MAILDROPDIR}/forward.err"
+maildrop -forganizer1@mail.com < ${SCRIPTDIR}/tests/cropswap@shandan.one/from-organizer-to-member.eml 1>forward.out 2>forward.err
 grep '^From: Organizer <cropswap@shandan.one>$' < forward.out
+grep '^To: Organizer <organizer1@mail.com>$' < forward.out && false
 grep '^To: Organizer 1 <organizer2@mail.com>$' < forward.out && false
 grep '^To: Member <member1@mail.com>$' < forward.out && false
 grep '^To: Member 1 <member2@mail.com>$' < forward.out
 grep '^Subject: \[Crop Swap Notice\] .*$' < forward.out
 
-maildrop -forganizer2@mail.com < tests/cropswap@shandan.one/from-organizer.eml 1>"${MAILDROPDIR}/forward.out" 2>"${MAILDROPDIR}/forward.err"
+maildrop -forganizer2@mail.com < ${SCRIPTDIR}/tests/cropswap@shandan.one/from-organizer.eml 1>forward.out 2>forward.err
 grep '^From: Organizer 1 <cropswap@shandan.one>$' < forward.out
+grep '^To: Organizer 1 <organizer2@mail.com>$' < forward.out && false
 grep '^To: Organizer <organizer1@mail.com>$' < forward.out
 grep '^To: Member <member1@mail.com>$' < forward.out
 grep '^To: Member 1 <member2@mail.com>$' < forward.out
 grep '^Subject: \[Crop Swap Notice\] .*$' < forward.out
+set +x
+
+#
+# TEST cropswap-members@shandan.one
+mkdir cropswap-members@shandan.one
+${SCRIPTDIR}/cropswap-register.sh cropswap-members@shandan.one "Member" "member1@mail.com" &>/dev/null
+${SCRIPTDIR}/cropswap-register.sh cropswap-members@shandan.one "Member" "member2@mail.com" &>/dev/null
+${SCRIPTDIR}/cropswap-register.sh cropswap-members@shandan.one "Organizer" "organizer1@mail.com" &>/dev/null
+${SCRIPTDIR}/cropswap-register.sh cropswap-members@shandan.one "Organizer" "organizer2@mail.com" &>/dev/null
+
+set -x
+maildrop -funregistered@mail.com < ${SCRIPTDIR}/tests/cropswap-members@shandan.one/from-unregistered.eml 1>forward.out 2>forward.err
+grep '^From: A. Person <unregistered@mail.com>$' < forward.out && false
+grep '^To: A. Person <unregistered@mail.com>$' < forward.out && false
+grep '^To: Organizer <organizer1@mail.com>$' < forward.out && false
+grep '^To: Organizer 1 <organizer2@mail.com>$' < forward.out && false
+grep '^To: Member <member1@mail.com>$' < forward.out && false
+grep '^To: Member 1 <member2@mail.com>$' < forward.out && false
+grep '^Subject: \[Crop Swap Query\] .*$' < forward.out && false
+
+maildrop -fmember1@mail.com < ${SCRIPTDIR}/tests/cropswap-members@shandan.one/from-member.eml 1>forward.out 2>forward.err
+grep '^From: Member <cropswap-members@shandan.one>$' < forward.out
+grep '^To: Member <member1@mail.com>$' < forward.out && false
+grep '^To: Organizer <organizer1@mail.com>$' < forward.out
+grep '^To: Organizer 1 <organizer2@mail.com>$' < forward.out
+grep '^To: Member 1 <member2@mail.com>$' < forward.out
+grep '^Subject: \[Crop Swap Member\] .*$' < forward.out
+
+maildrop -forganizer1@mail.com < ${SCRIPTDIR}/tests/cropswap-members@shandan.one/from-member-to-member.eml 1>forward.out 2>forward.err
+grep '^From: Organizer <cropswap-members@shandan.one>$' < forward.out
+grep '^To: Organizer <organizer1@mail.com>$' < forward.out && false
+grep '^To: Organizer 1 <organizer2@mail.com>$' < forward.out && false
+grep '^To: Member <member1@mail.com>$' < forward.out && false
+grep '^To: Member 1 <member2@mail.com>$' < forward.out
+grep '^Subject: \[Crop Swap Member\] .*$' < forward.out

+ 36 - 0
tests/cropswap-members@shandan.one/from-member-to-member.eml

@@ -0,0 +1,36 @@
+From: Organizer <organizer1@mail.com>
+To: Member 1 <cropswap-members@shandan.one>
+Subject: Question for Member 1
+MIME-Version: 1.0
+Content-Type: multipart/alternative; 
+	boundary="----=_Part_16_6098270.1706251408890"
+
+------=_Part_16_6098270.1706251408890
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 7bit
+
+
+
+This should be forwarded to addressed member only
+
+------=_Part_16_6098270.1706251408890
+Content-Type: text/html; charset=UTF-8
+Content-Transfer-Encoding: 7bit
+
+<html>
+ <head>
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ </head>
+ <body>
+  <div style="font-family: sans-serif;">
+   <div style="font-family: sans-serif;">
+    <div style="font-family: sans-serif;">
+     <br>
+     <br><span dir="ltr" style="margin-top:0; margin-bottom:0;"><span style="font-family:sans-serif;"><span style="font-family:sans-serif;">This should be forwarded addressed member only</span></span></span>
+     <br>
+    </div>
+   </div>
+  </div>
+ </body>
+</html>
+------=_Part_16_6098270.1706251408890--

+ 36 - 0
tests/cropswap-members@shandan.one/from-member.eml

@@ -0,0 +1,36 @@
+From: Member <member1@mail.com>
+To: cropswap-members@shandan.one
+Subject: Question for all
+MIME-Version: 1.0
+Content-Type: multipart/alternative; 
+	boundary="----=_Part_16_6098270.1706251408890"
+
+------=_Part_16_6098270.1706251408890
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 7bit
+
+
+
+This should be forwarded to all other members
+
+------=_Part_16_6098270.1706251408890
+Content-Type: text/html; charset=UTF-8
+Content-Transfer-Encoding: 7bit
+
+<html>
+ <head>
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ </head>
+ <body>
+  <div style="font-family: sans-serif;">
+   <div style="font-family: sans-serif;">
+    <div style="font-family: sans-serif;">
+     <br>
+     <br><span dir="ltr" style="margin-top:0; margin-bottom:0;"><span style="font-family:sans-serif;"><span style="font-family:sans-serif;">This should be forwarded to all other members</span></span></span>
+     <br>
+    </div>
+   </div>
+  </div>
+ </body>
+</html>
+------=_Part_16_6098270.1706251408890--

+ 36 - 0
tests/cropswap-members@shandan.one/from-unregistered.eml

@@ -0,0 +1,36 @@
+From: A. Person <unregistered@mail.com>
+To: cropswap-members@shandan.one
+Subject: Question for Shannon
+MIME-Version: 1.0
+Content-Type: multipart/alternative; 
+	boundary="----=_Part_16_6098270.1706251408890"
+
+------=_Part_16_6098270.1706251408890
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 7bit
+
+
+
+This should be dropped
+
+------=_Part_16_6098270.1706251408890
+Content-Type: text/html; charset=UTF-8
+Content-Transfer-Encoding: 7bit
+
+<html>
+ <head>
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ </head>
+ <body>
+  <div style="font-family: sans-serif;">
+   <div style="font-family: sans-serif;">
+    <div style="font-family: sans-serif;">
+     <br>
+     <br><span dir="ltr" style="margin-top:0; margin-bottom:0;"><span style="font-family:sans-serif;"><span style="font-family:sans-serif;">This should be dropped</span></span></span>
+     <br>
+    </div>
+   </div>
+  </div>
+ </body>
+</html>
+------=_Part_16_6098270.1706251408890--