| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Test the basic behavior of post |
| 4 |
# |
| 5 |
|
| 6 |
set -e |
| 7 |
|
| 8 |
if test -z "${MH_OBJ_DIR}"; then |
| 9 |
srcdir=`dirname "$0"`/../.. |
| 10 |
MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR |
| 11 |
fi |
| 12 |
|
| 13 |
. "${srcdir}/test/post/test-post-common.sh" |
| 14 |
|
| 15 |
check_exit '-eq 1' "$MH_LIBEXEC_DIR/post" - |
| 16 |
|
| 17 |
# |
| 18 |
# Basic test - Simple message, single user, single recipient. Note that |
| 19 |
# we test dot-stuffing here as well. |
| 20 |
# |
| 21 |
start_test 'simple message' |
| 22 |
cat > "${MH_TEST_DIR}/Mail/draft" <<EOF |
| 23 |
From: Mr Nobody <[email protected]> |
| 24 |
To: Somebody Else <[email protected]> |
| 25 |
Subject: Test |
| 26 |
|
| 27 |
This is a test |
| 28 |
. |
| 29 |
EOF |
| 30 |
|
| 31 |
cat > "${testname}.expected" <<EOF |
| 32 |
EHLO nosuchhost.example.com |
| 33 |
MAIL FROM:<[email protected]> |
| 34 |
RCPT TO:<[email protected]> |
| 35 |
DATA |
| 36 |
From: Mr Nobody <[email protected]> |
| 37 |
To: Somebody Else <[email protected]> |
| 38 |
Subject: Test |
| 39 |
MIME-Version: 1.0 |
| 40 |
Content-Type: text/plain; charset="us-ascii" |
| 41 |
Date: |
| 42 |
|
| 43 |
This is a test |
| 44 |
.. |
| 45 |
. |
| 46 |
QUIT |
| 47 |
EOF |
| 48 |
|
| 49 |
test_post "${testname}.actual" "${testname}.expected" |
| 50 |
|
| 51 |
# |
| 52 |
# Make sure a draft without a From: is rejected |
| 53 |
# |
| 54 |
start_test 'reject draft without a From:' |
| 55 |
cat > "${MH_TEST_DIR}/Mail/draft" <<EOF |
| 56 |
To: Somebody Else <[email protected]> |
| 57 |
Subject: Blank Test |
| 58 |
|
| 59 |
This is a blank test |
| 60 |
EOF |
| 61 |
|
| 62 |
run_test "send -draft -server 127.0.0.1 -port $localport" \ |
| 63 |
"post: message has no From: header |
| 64 |
post: See default components files for examples |
| 65 |
post: re-format message and try again |
| 66 |
send: message not delivered to anyone" |
| 67 |
|
| 68 |
# |
| 69 |
# Make sure that empty Nmh-* header lines are ignored, and that post |
| 70 |
# warns about non-empty ones. |
| 71 |
# |
| 72 |
start_test 'ignore Nmh-* header lines' |
| 73 |
cat > "${MH_TEST_DIR}/Mail/draft" <<EOF |
| 74 |
From: Mr Nobody <[email protected]> |
| 75 |
To: Somebody Else <[email protected]> |
| 76 |
Nmh-Attachment: |
| 77 |
Nmh-Unused: suppress this line |
| 78 |
Subject: Test |
| 79 |
|
| 80 |
This is a test |
| 81 |
. |
| 82 |
EOF |
| 83 |
|
| 84 |
cat > "${testname}.expected" <<EOF |
| 85 |
EHLO nosuchhost.example.com |
| 86 |
MAIL FROM:<[email protected]> |
| 87 |
RCPT TO:<[email protected]> |
| 88 |
DATA |
| 89 |
From: Mr Nobody <[email protected]> |
| 90 |
To: Somebody Else <[email protected]> |
| 91 |
Subject: Test |
| 92 |
MIME-Version: 1.0 |
| 93 |
Content-Type: text/plain; charset="us-ascii" |
| 94 |
Date: |
| 95 |
|
| 96 |
This is a test |
| 97 |
.. |
| 98 |
. |
| 99 |
QUIT |
| 100 |
EOF |
| 101 |
|
| 102 |
cat > "${testname}.expected_send_output" <<EOF |
| 103 |
post: ignoring header line -- Nmh-Unused: suppress this line |
| 104 |
EOF |
| 105 |
|
| 106 |
test_post "${testname}.actual" "${testname}.expected" \ |
| 107 |
>${testname}.send_output 2>&1 |
| 108 |
|
| 109 |
check "${testname}.send_output" "${testname}.expected_send_output" |
| 110 |
|
| 111 |
# |
| 112 |
# 8-bit without 8BITMIME support |
| 113 |
# |
| 114 |
start_test '8-bit without 8BITMIME support' |
| 115 |
cat > "${MH_TEST_DIR}/Mail/draft" <<EOF |
| 116 |
From: Mr Nobody <[email protected]> |
| 117 |
To: Somebody Else <[email protected]> |
| 118 |
Subject: Test |
| 119 |
MIME-Version: 1.0 |
| 120 |
Content-Type: text/plain; charset="utf-8" |
| 121 |
Content-Transfer-Encoding: 8bit |
| 122 |
|
| 123 |
This is a test |
| 124 |
. |
| 125 |
EOF |
| 126 |
|
| 127 |
cat > "${testname}.expected" <<EOF |
| 128 |
EHLO nosuchhost.example.com |
| 129 |
RSET |
| 130 |
QUIT |
| 131 |
EOF |
| 132 |
|
| 133 |
cat > "${testname}.err.expected" <<EOF |
| 134 |
post: SMTP server does not support 8BITMIME, not sending. |
| 135 |
Suggest encoding message for 7-bit transport by setting your |
| 136 |
locale to C, and/or specifying *b64 in mhbuild directives. |
| 137 |
post: problem initializing server; [BHST] ready; I'll buy that for a dollar! |
| 138 |
send: message not delivered to anyone |
| 139 |
EOF |
| 140 |
|
| 141 |
set +e |
| 142 |
test_post "${testname}.actual" "${testname}.expected" 2>"${testname}.err" |
| 143 |
set +e |
| 144 |
check "${testname}.err" "${testname}.err.expected" |
| 145 |
|
| 146 |
# |
| 147 |
# 8-bit with 8BITMIME support |
| 148 |
# |
| 149 |
start_test '8-bit with 8BITMIME support' |
| 150 |
# Cheat: SMTPUTF8 enables 8BITMIME in fakestmp |
| 151 |
SMTPUTF8=1; export SMTPUTF8 |
| 152 |
cat > "${testname}.expected" <<EOF |
| 153 |
EHLO nosuchhost.example.com |
| 154 |
MAIL FROM:<[email protected]> BODY=8BITMIME |
| 155 |
RCPT TO:<[email protected]> |
| 156 |
DATA |
| 157 |
From: Mr Nobody <[email protected]> |
| 158 |
To: Somebody Else <[email protected]> |
| 159 |
Subject: Test |
| 160 |
MIME-Version: 1.0 |
| 161 |
Content-Type: text/plain; charset="utf-8" |
| 162 |
Content-Transfer-Encoding: 8bit |
| 163 |
Date: |
| 164 |
|
| 165 |
This is a test |
| 166 |
.. |
| 167 |
. |
| 168 |
QUIT |
| 169 |
EOF |
| 170 |
test_post "${testname}.actual" "${testname}.expected" |
| 171 |
|
| 172 |
|
| 173 |
# |
| 174 |
# 8-bit with 8BITMIME support, inferred from content |
| 175 |
# |
| 176 |
start_test '8-bit, inferred, with 8BITMIME support' |
| 177 |
cat > "${MH_TEST_DIR}/Mail/draft" <<EOF |
| 178 |
From: Mr Nobody <[email protected]> |
| 179 |
To: Somebody Else <[email protected]> |
| 180 |
Subject: Test |
| 181 |
MIME-Version: 1.0 |
| 182 |
Content-Type: text/plain; charset="utf-8" |
| 183 |
|
| 184 |
This is a test, with a non-ascii character: § |
| 185 |
. |
| 186 |
EOF |
| 187 |
|
| 188 |
cat > "${testname}.expected" <<EOF |
| 189 |
EHLO nosuchhost.example.com |
| 190 |
MAIL FROM:<[email protected]> BODY=8BITMIME |
| 191 |
RCPT TO:<[email protected]> |
| 192 |
DATA |
| 193 |
From: Mr Nobody <[email protected]> |
| 194 |
To: Somebody Else <[email protected]> |
| 195 |
Subject: Test |
| 196 |
MIME-Version: 1.0 |
| 197 |
Content-Type: text/plain; charset="utf-8" |
| 198 |
Date: |
| 199 |
|
| 200 |
This is a test, with a non-ascii character: § |
| 201 |
.. |
| 202 |
. |
| 203 |
QUIT |
| 204 |
EOF |
| 205 |
test_post "${testname}.actual" "${testname}.expected" |
| 206 |
|
| 207 |
|
| 208 |
finish_test |
| 209 |
exit ${failed:-0} |