]> diplodocus.org Git - nmh/blob - test/imap/test-bad
expect this commit to be force-replaced periodically
[nmh] / test / imap / test-bad
1 #!/bin/sh
2
3 # TODO rename this file test-bad-list
4 # TODO figure out how to get a server to send a BAD response so we have an accurate fake
5
6 if test -z "$MH_OBJ_DIR"; then
7 srcdir=`dirname "$0"`/../..
8 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
9 fi
10
11 . "$MH_OBJ_DIR/test/common.sh"
12
13 # common.sh sets this to something crazy; did i do that?!
14 testname=${0#$srcdir/}
15
16 setup_test_without_data Mail
17
18 imap_cleanup() {
19 #### Save exit status to use as status for this program.
20 status=$?
21 set +e
22
23 rm -f "$imapd"
24
25 [ -n "$imapd_pid" ] && kill $imapd_pid
26 "$MH_OBJ_DIR/target/debug/mhimap" imap shutdown
27
28 # TODO have cleanup allow additional cleanup registration?
29 # Or just allow it to accept status as argument.
30 (exit $status)
31 cleanup
32 }
33 trap imap_cleanup 0
34
35 covdir="$MH_OBJ_DIR/covdata/${MH_COVERAGE_PROFILE:-default}/$testname"
36 install -d "$covdir"
37 export LLVM_PROFILE_FILE="$covdir/$profile-%m.profraw"
38
39 imapd="$MH_TEST_DIR/$$.imapd"
40 start_fakeinetd "$imapd"
41 imapd_pid=$fakeinetd_pid
42
43 cat >> "$MH" <<EOF
44 Managed-Folders: imap
45 imap-manager: $MH_OBJ_DIR/target/debug/imap-folder-manager
46 imap-socket: $MH_TEST_DIR/Mail/imap.d/socket
47 imap-db: $MH_TEST_DIR/Mail/imap.d
48 imap-host: 127.0.0.1
49 imap-port: $fakeinetd_port
50 imap-tls: don't protect my data i know what i'm doing
51 imap-auth: PREAUTH
52 imap-mailbox-root: test/
53 EOF
54 if [ -n "$MH_TEST_IMAP_LOG_LEVEL" ]; then
55 echo "imap-log-level: $MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
56 echo "imap-log-$MH_TEST_IMAP_LOG_LEVEL-to: $MH_TEST_DIR/$profile/imap.d/log.$MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
57 fi
58
59 expected="$MH_TEST_DIR/$$.expected"
60 actual="$MH_TEST_DIR/$$.actual"
61
62 start_test 'unrecoverable error: BAD LIST'
63
64 cat > "$imapd" <<EOSCRIPT
65 #!/bin/sh
66 cat <<EOF
67 * PREAUTH [CAPABILITY IMAP4REV1 UIDPLUS] authenticated
68 * LIST (\NoInferiors \UnMarked) "/" test/fold
69 1 BAD fake fake fakey fake
70 EOF
71 while read line; do :; done
72 EOSCRIPT
73 chmod 755 "$imapd"
74
75 cat > "$expected" <<EOF
76 inc: failed to inc folder imap: BAD response from LIST: Unknown fake fake fakey fake
77 EOF
78 inc +imap > "$actual" 2>&1 || status=$?
79 check "$actual" "$expected"
80 (exit $status) && fail 'inc exited 0 on error'
81
82 finish_test
83 exit ${failed:-0}