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