]> diplodocus.org Git - nmh/blob - test/inc/test-pop
Minor autoconf style cleanup.
[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 testport=65413
28
29 HOME="${MH_TEST_DIR}"; export HOME
30 netrc="${HOME}/.netrc"
31 echo "default login ${TESTUSER} password ${TESTPASS}" > "$netrc"
32 chmod 600 "$netrc"
33
34 expected=$MH_TEST_DIR/$$.expected
35 expected_err=$MH_TEST_DIR/$$.expected_err
36 actual=$MH_TEST_DIR/$$.actual
37 actual_err=$MH_TEST_DIR/$$.actual_err
38 testmessage=$MH_TEST_DIR/testmessage
39
40 cat > $testmessage <<EOM
41 Received: From somewhere
42 From: No Such User <nosuch@example.com>
43 To: Some Other User <someother@example.com>
44 Subject: Hello
45 Date: Sun, 17 Dec 2006 12:13:14 -0500
46
47 Hey man, how's it going?
48 .
49 Hope you're doing better.
50 EOM
51
52 pid=`"${MH_OBJ_DIR}/test/fakepop" "$testmessage" "$testport" \
53 "$TESTUSER" "$TESTPASS"`
54
55 run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 80" \
56 "Incorporating new mail into inbox...
57
58 11+ 12/17 No Such User Hello<<Hey man, how's it going? . Hope you're do"
59 check $testmessage `mhpath +inbox 11` 'keep first'
60
61 # check -pack
62 pid=`"${MH_OBJ_DIR}/test/fakepop" "$testmessage" "$testport" \
63 "$TESTUSER" "$TESTPASS"`
64
65 touch "$MH_TEST_DIR/inc.mbox"
66 run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 80 \
67 -pack $MH_TEST_DIR/inc.mbox" \
68 "Incorporating new mail into (null)...
69
70 1 12/17 No Such User Hello<<Hey man, how's it going? . Hope you're do"
71 run_test "inc -file $MH_TEST_DIR/inc.mbox -truncate -width 80" \
72 "Incorporating new mail into inbox...
73
74 11+ 12/17 No Such User Hello<<Hey man, how's it going? . Hope you're do"
75
76 check $testmessage `mhpath +inbox 11` 'keep first'
77 rm -f "$MH_TEST_DIR/inc.mbox" "$MH_TEST_DIR/.inc.map" "$netrc"
78
79 # check credentials: file
80 # Redirect stdin so that inc doesn't wait on the user if it can't
81 # read the netrc file, even though that shouldn't happen.
82 TESTUSER=differenuser
83 TESTPASS=differentpass
84
85 netrc="${HOME}/.mhnetrc"
86 echo "default login ${TESTUSER} password ${TESTPASS}" > "$netrc"
87 chmod 600 "$netrc"
88 echo "credentials: file:${netrc}" >>$MH
89
90 pid=`"${MH_OBJ_DIR}/test/fakepop" "$testmessage" "$testport" \
91 "$TESTUSER" "$TESTPASS"`
92
93 touch "$MH_TEST_DIR/inc.mbox"
94 run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 65 \
95 -pack $MH_TEST_DIR/inc.mbox" \
96 "Incorporating new mail into (null)...
97
98 1 12/17 No Such User Hello<<Hey man, how's it going? ." </dev/null
99 run_test "inc -file $MH_TEST_DIR/inc.mbox -truncate -width 65" \
100 "Incorporating new mail into inbox...
101
102 11+ 12/17 No Such User Hello<<Hey man, how's it going? ." </dev/null
103
104 check $testmessage `mhpath +inbox 11`
105 rm -f "$MH_TEST_DIR/inc.mbox" "$MH_TEST_DIR/.inc.map" "$netrc"
106
107 exit ${failed:-0}