#!/bin/sh ###################################################### # # Test aliases all the way through post # ###################################################### set -e if test -z "${MH_OBJ_DIR}"; then srcdir=`dirname "$0"`/../.. MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR fi . "${srcdir}/test/post/test-post-common.sh" # Note that the last address in the blind list does not end with a # semicolon. cat >"${MH_TEST_DIR}/Mail/aliases" <>"$mts_fakesendmail" MHMTSCONF="$mts_fakesendmail" # $1: -mts switch selection # $2: expected output test_alias () { if [ "$1" = 'sendmail/smtp' ]; then send -draft -alias "${MH_TEST_DIR}/Mail/aliases" -mts sendmail/smtp # fakesendmail drops the message and any cc's into this mbox. mbox="${MH_TEST_DIR}"/Mail/fakesendmail.mbox inc -silent -file "$mbox" rm -f "$mbox" "$mbox.map" # It's hard to calculate the exact Date: header post is going to # use, so we'll just use sed to remove the actual date so we can easily # compare it against our "correct" output. sed -e 's/^Date:.*/Date:/' "`mhpath cur`" >"${testname}.actual" check "${testname}.actual" "$2" if [ "`mhpath cur`" != "`mhpath last`" ]; then folder next >/dev/null arith_eval $n + 1; n=$arith_val fi elif [ "$1" = 'sendmail/pipe' ]; then set +e send -draft -alias "${MH_TEST_DIR}/Mail/aliases" -mts sendmail/pipe \ >"${testname}.actual" 2>&1 if [ $? -eq 0 ]; then printf "$0: sendmail/pipe should have failed but didn't\n" else set -e check "${testname}.actual" "$2" fi else printf "$0: invalid -mts switch selection\n" exit 1 fi } # check blind list cat >"${MH_TEST_DIR}/Mail/draft" < To: blind_list Subject: blind list test This is test of a blind list. EOF cp -p "${MH_TEST_DIR}/Mail/draft" "${MH_TEST_DIR}/Mail/draft2" cat >"${testname}.expected" < To: Blind List: ; Subject: blind list test Date: This is test of a blind list. EOF test_alias sendmail/smtp "${testname}.expected" # Make sure the addresses were expanded correctly. mv "${MH_TEST_DIR}/Mail/draft2" "${MH_TEST_DIR}/Mail/draft" cat > "${testname}.expected" < RCPT TO: RCPT TO: RCPT TO: DATA From: Mr Nobody To: Blind List: ; Subject: blind list test Date: This is test of a blind list. . QUIT EOF test_post "${testname}.actual" "${testname}.expected" \ "-alias ${MH_TEST_DIR}/Mail/aliases" # check named list (alias followed by ;) cat >"${MH_TEST_DIR}/Mail/draft" < To: named.list Subject: named list test This is test of a named list. EOF cat >"${testname}.expected" < To: "named.list" , "named.list" Subject: named list test Date: This is test of a named list. EOF test_alias sendmail/smtp "${testname}.expected" # check blind list with -mts sendmail/pipe, which should fail cat >"${MH_TEST_DIR}/Mail/draft" < To: blind_list Subject: blind list test This is test of a blind list. EOF cat >"${testname}.expected" <