]> diplodocus.org Git - nmh/blob - test/post/test-post-basic
Replace getcpy() with mh_xstrdup() where the string isn't NULL.
[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
136 post: problem initializing server; [BHST] ready; I'll buy that for a dollar!
137 send: message not delivered to anyone
138 EOF
139
140 set +e
141 test_post "${testname}.actual" "${testname}.expected" 2>"${testname}.err"
142 set +e
143 check "${testname}.err" "${testname}.err.expected"
144
145 #
146 # 8-bit with 8BITMIME support
147 #
148 start_test '8-bit with 8BITMIME support'
149 # Cheat: SMTPUTF8 enables 8BITMIME in fakestmp
150 SMTPUTF8=1; export SMTPUTF8
151 cat > "${testname}.expected" <<EOF
152 EHLO nosuchhost.example.com
153 MAIL FROM:<nobody@example.com> BODY=8BITMIME
154 RCPT TO:<somebody@example.com>
155 DATA
156 From: Mr Nobody <nobody@example.com>
157 To: Somebody Else <somebody@example.com>
158 Subject: Test
159 MIME-Version: 1.0
160 Content-Type: text/plain; charset="utf-8"
161 Content-Transfer-Encoding: 8bit
162 Date:
163
164 This is a test
165 ..
166 .
167 QUIT
168 EOF
169 test_post "${testname}.actual" "${testname}.expected"
170
171
172 #
173 # 8-bit with 8BITMIME support, inferred from content
174 #
175 start_test '8-bit, inferred, with 8BITMIME support'
176 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
177 From: Mr Nobody <nobody@example.com>
178 To: Somebody Else <somebody@example.com>
179 Subject: Test
180 MIME-Version: 1.0
181 Content-Type: text/plain; charset="utf-8"
182
183 This is a test, with a non-ascii character: §
184 .
185 EOF
186
187 cat > "${testname}.expected" <<EOF
188 EHLO nosuchhost.example.com
189 MAIL FROM:<nobody@example.com> BODY=8BITMIME
190 RCPT TO:<somebody@example.com>
191 DATA
192 From: Mr Nobody <nobody@example.com>
193 To: Somebody Else <somebody@example.com>
194 Subject: Test
195 MIME-Version: 1.0
196 Content-Type: text/plain; charset="utf-8"
197 Date:
198
199 This is a test, with a non-ascii character: §
200 ..
201 .
202 QUIT
203 EOF
204 test_post "${testname}.actual" "${testname}.expected"
205
206
207 finish_test
208 exit ${failed:-0}