File: test-sendfrom

package info (click to toggle)
nmh 1.8-4
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 7,860 kB
  • sloc: ansic: 50,445; sh: 22,697; makefile: 1,138; lex: 740; perl: 509; yacc: 265
file content (143 lines) | stat: -rwxr-xr-x 3,045 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/sh
######################################################
#
# Test sendfrom
#
######################################################

set -e

if test -z "${MH_OBJ_DIR}"; then
    srcdir=`dirname "$0"`/../..
    MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
fi

. "${srcdir}/test/post/test-post-common.sh"


# TEST
start_test 'sendfrom, using -snoop'

#### Set up profile to use sendfrom by adding a sendfrom-addr.  This one adds
#### -snoop to the send switches.  The output from snoop is constant, and so
#### is easily checked below.
cat >> "$MH" <<EOF
sendfrom-nobody@example.com: -snoop
EOF

cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
From: Mr Nobody <nobody@example.com>
To: Somebody Else <somebody@example.com>
Subject: Test

This is a test.
EOF

cat > "${testname}.expected" <<EOF
EHLO nosuchhost.example.com
MAIL FROM:<nobody@example.com>
RCPT TO:<somebody@example.com>
DATA
From: Mr Nobody <nobody@example.com>
To: Somebody Else <somebody@example.com>
Subject: Test
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date:

This is a test.
.
QUIT
EOF

cat > "${testname}.post-expected" <<EOF
Trying to connect to "127.0.0.1" ...
Connecting to 127.0.0.1:${localport}...
<= 220 Not really an ESMTP server
=> EHLO nosuchhost.example.com
<= 250-ready
<= 250 I'll buy that for a dollar!
=> MAIL FROM:<nobody@example.com>
<= 250 I'll buy that for a dollar!
=> RCPT TO:<somebody@example.com>
<= 250 I'll buy that for a dollar!
=> DATA
<= 354 Go ahead
=> .
<= 250 Thanks for the info!
=> QUIT
<= 221 Later alligator!
EOF

test_post "${testname}.actual" "${testname}.expected" \
    2> ${testname}.post

check "${testname}.post-expected" "${testname}.post"


# TEST
start_test 'sendfrom, using alias in From:'

#### Set up profile to use sendfrom by adding a sendfrom-addr.
cat >> "$MH" <<EOF
sendfrom-nobody: -user nobody@example.com
Aliasfile: MailAliases
EOF
#### And an alias.
cat >> "$MH_TEST_DIR/Mail/MailAliases" <<EOF
noone: nobody@example.com
EOF

cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
From: noone
To: Somebody Else <somebody@example.com>
Subject: Test

This is a test.
EOF

cat > "${testname}.expected" <<EOF
EHLO nosuchhost.example.com
MAIL FROM:<nobody@example.com>
RCPT TO:<somebody@example.com>
DATA
From: nobody@example.com
To: Somebody Else <somebody@example.com>
Subject: Test
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date:

This is a test.
.
QUIT
EOF

cat > "${testname}.post-expected" <<EOF
Trying to connect to "127.0.0.1" ...
Connecting to 127.0.0.1:${localport}...
<= 220 Not really an ESMTP server
=> EHLO nosuchhost.example.com
<= 250-ready
<= 250 I'll buy that for a dollar!
=> MAIL FROM:<nobody@example.com>
<= 250 I'll buy that for a dollar!
=> RCPT TO:<somebody@example.com>
<= 250 I'll buy that for a dollar!
=> DATA
<= 354 Go ahead
=> .
<= 250 Thanks for the info!
=> QUIT
<= 221 Later alligator!
EOF

test_post "${testname}.actual" "${testname}.expected" \
    2> ${testname}.post

check "${testname}.post-expected" "${testname}.post"


finish_test

exit ${failed:-0}