New test suite for "post"; uses fakesmtp to trap the SMTP protocol.
[mmh] / test / post / test-post-multifrom
1 #!/bin/sh
2 #
3 # Test the behavior of post with multiple from addresses
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 # This SHOULD error
17 #
18
19 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
20 From: Mr Nobody One <nobody1@example.com>, Mr Nobody Two <nobody2@example.com>
21 To: Somebody Else <somebody@example.com>
22 Subject: Test multi-from
23
24 This is a test of multi-from.
25 EOF
26
27 #
28 # Since this should fail, don't run fakesmtp
29 #
30
31 run_test "send -draft -server 127.0.0.1 -port $localport" \
32         "post: A Sender: or Envelope-From: header is required with multiple
33 From: addresses
34 post: re-format message and try again
35 send: message not delivered to anyone"
36
37 #
38 # This should also error
39 #
40 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
41 From: Mr Nobody One <nobody1@example.com>, Mr Nobody Two <nobody2@example.com>
42 To: Somebody Else <somebody@example.com>
43 Subject: Test multi-from
44 Envelope-From:
45
46 This is a test of multi-from with blank Envelope-From.
47 EOF
48
49 run_test "send -draft -server 127.0.0.1 -port $localport" \
50         "post: Envelope-From cannot be blank when there is multiple From: addresses
51 and no Sender: header
52 post: re-format message and try again
53 send: message not delivered to anyone"
54
55 exit ${failed:-0}