Filter out all Nmh-* headers in post(1). Do that silently for empty
[mmh] / 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
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 Date:
38
39 This is a test
40 ..
41 .
42 QUIT
43 EOF
44
45 test_post "${testname}.actual" "${testname}.expected"
46
47 #
48 # Make sure a draft without a From: is rejected
49 #
50
51 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
52 To: Somebody Else <somebody@example.com>
53 Subject: Blank Test
54
55 This is a blank test
56 EOF
57
58 run_test "send -draft -server 127.0.0.1 -port $localport" \
59          "post: message has no From: header
60 post: See default components files for examples
61 post: re-format message and try again
62 send: message not delivered to anyone"
63
64 #
65 # Make sure that empty Nmh-* header lines are ignored, and that post
66 # warns about non-empty ones.
67 #
68 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
69 From: Mr Nobody <nobody@example.com>
70 To: Somebody Else <somebody@example.com>
71 Nmh-Attachment:
72 Nmh-Unused: suppress this line
73 Subject: Test
74
75 This is a test
76 .
77 EOF
78
79 cat > "${testname}.expected" <<EOF
80 EHLO nosuchhost.example.com
81 MAIL FROM:<nobody@example.com>
82 RCPT TO:<somebody@example.com>
83 DATA
84 From: Mr Nobody <nobody@example.com>
85 To: Somebody Else <somebody@example.com>
86 Subject: Test
87 Date:
88
89 This is a test
90 ..
91 .
92 QUIT
93 EOF
94
95 cat > "${testname}.expected_send_output" <<EOF
96 post: ignoring header line -- Nmh-Unused: suppress this line
97 EOF
98
99 test_post "${testname}.actual" "${testname}.expected" \
100           >${testname}.send_output 2>&1
101
102 check "${testname}.send_output" "${testname}.expected_send_output"
103
104
105 exit ${failed:-0}