]>
diplodocus.org Git - nmh/blob - test/post/test-messageid
8 if test -z "${MH_OBJ_DIR}"; then
9 srcdir
=`dirname "$0"`/..
/..
10 MH_OBJ_DIR
=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
13 .
"${MH_OBJ_DIR}/test/common.sh"
16 testname
="${MH_TEST_DIR}/$$"
19 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
20 From: Mr Nobody <nobody@example.com>
21 To: Somebody Else <somebody@example.com>
27 cat > "${testname}.expected" <<EOF
28 EHLO nosuchhost.example.com
29 MAIL FROM:<nobody@example.com>
30 RCPT TO:<somebody@example.com>
32 From: Mr Nobody <nobody@example.com>
33 To: Somebody Else <somebody@example.com>
36 Content-Type: text/plain; charset="us-ascii"
44 # check invalid -messageid selection
45 start_test
"invalid -messageid selection"
46 run_test
"send -draft -messageid invalid" \
47 "post: unsupported messageid \"invalid\"
48 send: message not delivered to anyone"
50 #### Rely on sendmail/pipe below to override default mts.
51 mts_fakesendmail
="${MHMTSCONF}-fakesendmail"
52 cp "${MHMTSCONF}" "$mts_fakesendmail"
53 printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
54 MHMTSCONF
="$mts_fakesendmail"
56 # $1: -messageid switch selection
57 # arguments: expected output(s)
61 run_prog send
-draft -mts sendmail
/pipe
-msgid -messageid "$msgid_style"
64 # fakesendmail drops the message and any cc's into this mbox.
65 mbox
="${MH_TEST_DIR}"/Mail
/fakesendmail.mbox
66 inc
-silent -file "$mbox"
70 for expected
in "$@"; do
72 # Verify that Message-ID is of the right form. We'll see how
73 # portable these grep regular expressions are.
76 # e.g., Message-ID: <5348.1342884222@localhost.localdomain>
77 id
='^Message-ID: <[0-9]\{1,\}\.[0-9]\{1,\}@'
80 # e.g., Message-ID: <5364-1342884222.165897@ldYM.FXwU.bBqK>
81 id
='^Message-ID: <[0-9]\{1,\}-[0-9]\{1,\}\.[0-9]\{6,6\}@[-_0-9A-Za-z]\{4,4\}\.[-_0-9A-Za-z]\{4,4\}\.[-_0-9A-Za-z]\{4,4\}'
83 *) printf '%s: unexpected messageid: %s\n' "$0" "$msgid_style"; exit 1 ;;
86 if grep "$id" "$cur" >/dev
/null
; then
89 mv "$cur" "${testname}.actual"
90 printf '%s: unexpected %s Message-ID format, see %s\n' "$0" \
91 "$msgid_style" "${testname}.actual"
96 # It's hard to calculate the exact Date: header post is going to
97 # use, so we'll just use sed to remove the actual date so we can easily
98 # compare it against our "correct" output. And same for
101 sed -e 's/^Date:.*/Date:/' \
102 -e 's/^Message-ID:.*/Message-ID:/' \
103 "$cur" > "${testname}.actual$n"
105 check
"${testname}.actual$n" "$expected"
107 if [ "$cur" != "`mhpath last`" ]; then
108 folder next
>/dev
/null
109 arith_eval
$n + 1; n
=$arith_val
114 # check -messageid localname (the default)
115 start_test
"-messageid localname (the default)"
116 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
117 From: Mr Nobody <nobody@example.com>
118 To: Somebody Else <somebody@example.com>
125 cat > "${testname}.expected" <<EOF
126 From: Mr Nobody <nobody@example.com>
127 To: Somebody Else <somebody@example.com>
130 Content-Type: text/plain; charset="us-ascii"
138 test_messageid localname
"${testname}.expected"
140 # check -messageid random
141 start_test
"-messageid random"
142 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
143 From: Mr Nobody <nobody@example.com>
144 To: Somebody Else <somebody@example.com>
151 cat > "${testname}.expected" <<EOF
152 From: Mr Nobody <nobody@example.com>
153 To: Somebody Else <somebody@example.com>
156 Content-Type: text/plain; charset="us-ascii"
164 test_messageid random
"${testname}.expected"