]> diplodocus.org Git - nmh/blob - test/inc/test-pop
Escape literal leading full stop in man/new.man.
[nmh] / test / inc / test-pop
1 #!/bin/sh
2 ######################################################
3 #
4 # Test POP support in inc
5 # Only tests checking of local maildrop, does not
6 # test checking of POP server.
7 #
8 ######################################################
9
10 set -e
11
12 if test -z "${MH_OBJ_DIR}"; then
13 srcdir=`dirname $0`/../..
14 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 fi
16
17 . "$MH_OBJ_DIR/test/common.sh"
18
19 setup_test
20
21 #
22 # Some extra stuff we need for POP support
23 #
24
25 TESTUSER=testuser
26 TESTPASS=testuserpass
27 arith_eval 64001 + $$ % 1000
28 testport=$arith_val
29
30 HOME="${MH_TEST_DIR}"; export HOME
31 netrc="${HOME}/.netrc"
32 echo "default login ${TESTUSER} password ${TESTPASS}" > "$netrc"
33 chmod 600 "$netrc"
34
35 expected=$MH_TEST_DIR/$$.expected
36 expected_err=$MH_TEST_DIR/$$.expected_err
37 actual=$MH_TEST_DIR/$$.actual
38 actual_err=$MH_TEST_DIR/$$.actual_err
39 testmessage=$MH_TEST_DIR/testmessage
40
41 cat > "$testmessage" <<EOM
42 Received: From somewhere
43 From: No Such User <nosuch@example.com>
44 To: Some Other User <someother@example.com>
45 Subject: Hello
46 Date: Sun, 17 Dec 2006 12:13:14 -0500
47
48 Hey man, how's it going?
49 .
50 Hope you're doing better.
51 EOM
52
53 cat > "${testmessage}.2" <<EOM
54 Received: From somewhere
55 From: A Real User <real@example.com>
56 To: Some Other User <someother@example.com>
57 Subject: Anything new?
58 Date: Monday, 18 Dec 2006 14:13:14 -0500
59
60 What's been happening at your place?
61 EOM
62
63 cat > "${testmessage}.3" <<EOM
64 Received: From somewhere
65 From: Nathan Explosion <nathan@dethklok.com>
66 To: Some Other User <someother@example.com>
67 Subject: Brutal
68 Date: Tuesday, 19 Dec 2006 4:15:16 -0500
69
70 Dude, nmh is totally brutal.
71 EOM
72
73 # Check netrc's permissions test
74 pid=`"${MH_OBJ_DIR}/test/fakepop" "$testport" '' '' "$testmessage"`
75 chmod g=w,o=x $netrc
76 run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport" \
77 "inc: group or other permissions, 0100621, forbidden: $netrc
78 inc: Remove password or correct file permissions."
79 chmod go= $netrc
80
81 pid=`"${MH_OBJ_DIR}/test/fakepop" "$testport" \
82 "$TESTUSER" "$TESTPASS" "$testmessage"`
83
84 run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 80" \
85 "Incorporating new mail into inbox...
86
87 11+ 12/17 No Such User Hello<<Hey man, how's it going? . Hope you're do\
88 i"
89 check "$testmessage" `mhpath +inbox 11` 'keep first'
90
91 # Check multiple messages at once
92
93 pid=`"${MH_OBJ_DIR}/test/fakepop" "$testport" \
94 "$TESTUSER" "$TESTPASS" "$testmessage" \
95 "${testmessage}.2" "${testmessage}.3"`
96
97 run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 80" \
98 "Incorporating new mail into inbox...
99
100 11+ 12/17 No Such User Hello<<Hey man, how's it going? . Hope you're doi
101 12 12/18 A Real User Anything new?<<What's been happening at your plac
102 13 12/19 Nathan Explosion Brutal<<Dude, nmh is totally brutal. >>"
103
104 check "$testmessage" `mhpath +inbox 11` 'keep first'
105 check "${testmessage}.2" `mhpath +inbox 12`
106 check "${testmessage}.3" `mhpath +inbox 13`
107
108 # check -pack
109 pid=`"${MH_OBJ_DIR}/test/fakepop" "$testport" \
110 "$TESTUSER" "$TESTPASS" "$testmessage"`
111
112 touch "$MH_TEST_DIR/inc.mbox"
113 run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 80 \
114 -pack $MH_TEST_DIR/inc.mbox" \
115 "Incorporating new mail into (null)...
116
117 1 12/17 No Such User Hello<<Hey man, how's it going? . Hope you're do\
118 i"
119 run_test "inc -file $MH_TEST_DIR/inc.mbox -truncate -width 80" \
120 "Incorporating new mail into inbox...
121
122 11+ 12/17 No Such User Hello<<Hey man, how's it going? . Hope you're do\
123 i"
124
125 check $testmessage `mhpath +inbox 11` 'keep first'
126 rm -f "$MH_TEST_DIR/inc.mbox" "$MH_TEST_DIR/.inc.map" "$netrc"
127
128 # check credentials: file
129 # Redirect stdin so that inc doesn't wait on the user if it can't
130 # read the netrc file, even though that shouldn't happen.
131 TESTUSER=differenuser
132 TESTPASS=differentpass
133
134 netrc="${HOME}/.mhnetrc"
135 echo "default login ${TESTUSER} password ${TESTPASS}" > "$netrc"
136 chmod 600 "$netrc"
137 echo "credentials: file:${netrc}" >>$MH
138
139 pid=`"${MH_OBJ_DIR}/test/fakepop" "$testport" \
140 "$TESTUSER" "$TESTPASS" "$testmessage"`
141
142 touch "$MH_TEST_DIR/inc.mbox"
143 run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 65 \
144 -pack $MH_TEST_DIR/inc.mbox" \
145 "Incorporating new mail into (null)...
146
147 1 12/17 No Such User Hello<<Hey man, how's it going? . " </dev/null
148 run_test "inc -file $MH_TEST_DIR/inc.mbox -truncate -width 65" \
149 "Incorporating new mail into inbox...
150
151 11+ 12/17 No Such User Hello<<Hey man, how's it going? . " </dev/null
152
153 check $testmessage `mhpath +inbox 11`
154 rm -f "$MH_TEST_DIR/inc.mbox" "$MH_TEST_DIR/.inc.map" "$netrc"
155
156 exit ${failed:-0}