]> diplodocus.org Git - nmh/blob - test/inc/test-pop
Convert unqp() to decode_qp(), and make it a public function. Also,
[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 + `id -u` % 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 pid=`"${MH_OBJ_DIR}/test/fakepop" "$testmessage" "$testport" \
54 "$TESTUSER" "$TESTPASS"`
55
56 run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 80" \
57 "Incorporating new mail into inbox...
58
59 11+ 12/17 No Such User Hello<<Hey man, how's it going? . Hope you're do"
60 check $testmessage `mhpath +inbox 11` 'keep first'
61
62 # check -pack
63 pid=`"${MH_OBJ_DIR}/test/fakepop" "$testmessage" "$testport" \
64 "$TESTUSER" "$TESTPASS"`
65
66 touch "$MH_TEST_DIR/inc.mbox"
67 run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 80 \
68 -pack $MH_TEST_DIR/inc.mbox" \
69 "Incorporating new mail into (null)...
70
71 1 12/17 No Such User Hello<<Hey man, how's it going? . Hope you're do"
72 run_test "inc -file $MH_TEST_DIR/inc.mbox -truncate -width 80" \
73 "Incorporating new mail into inbox...
74
75 11+ 12/17 No Such User Hello<<Hey man, how's it going? . Hope you're do"
76
77 check $testmessage `mhpath +inbox 11` 'keep first'
78 rm -f "$MH_TEST_DIR/inc.mbox" "$MH_TEST_DIR/.inc.map" "$netrc"
79
80 # check credentials: file
81 # Redirect stdin so that inc doesn't wait on the user if it can't
82 # read the netrc file, even though that shouldn't happen.
83 TESTUSER=differenuser
84 TESTPASS=differentpass
85
86 netrc="${HOME}/.mhnetrc"
87 echo "default login ${TESTUSER} password ${TESTPASS}" > "$netrc"
88 chmod 600 "$netrc"
89 echo "credentials: file:${netrc}" >>$MH
90
91 pid=`"${MH_OBJ_DIR}/test/fakepop" "$testmessage" "$testport" \
92 "$TESTUSER" "$TESTPASS"`
93
94 touch "$MH_TEST_DIR/inc.mbox"
95 run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 65 \
96 -pack $MH_TEST_DIR/inc.mbox" \
97 "Incorporating new mail into (null)...
98
99 1 12/17 No Such User Hello<<Hey man, how's it going? ." </dev/null
100 run_test "inc -file $MH_TEST_DIR/inc.mbox -truncate -width 65" \
101 "Incorporating new mail into inbox...
102
103 11+ 12/17 No Such User Hello<<Hey man, how's it going? ." </dev/null
104
105 check $testmessage `mhpath +inbox 11`
106 rm -f "$MH_TEST_DIR/inc.mbox" "$MH_TEST_DIR/.inc.map" "$netrc"
107
108 exit ${failed:-0}