]> diplodocus.org Git - nmh/blob - test/imap/test-inc-missing-msg
expect this commit to be force-replaced periodically
[nmh] / test / imap / test-inc-missing-msg
1 #!/bin/sh
2
3 # TODO FIX uh oh this and the other missing msg cases passed by accident after inc uses ESEARCH
4 # and now switching inc to leave mailbox open has broken it completely!
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 start_test 'message disappears between FETCH UID and FETCH BODY'
60 # test the case where a message goes missing between the time inc first
61 # notices it and when it goes to download it, e.g. inc starts, sees a message,
62 # and then another client deletes it before inc can fetch it.
63
64 # I'm kinda surprised this just worked on the first try... hmm or not.
65 # I see. The ServerData::Fetch loop doesn't know if it's procesinsg a
66 # response from our request for a range of UIDS or from our request of a
67 # message body.
68 # TODO Teach it the difference so we can log when a message goes missing.
69
70 # Documented behaviors:
71 # https://datatracker.ietf.org/doc/html/rfc3501#section-6.4.8 says:
72 # A non-existent unique identifier is ignored without any error
73 # message generated. Thus, it is possible for a UID FETCH command
74 # to return an OK without any data or a UID COPY or UID STORE to
75 # return an OK without performing any operations.
76 # This seems to match the Panda behavior I see.
77
78 # https://datatracker.ietf.org/doc/html/rfc2180#section-4.1.1 has an example:
79 # => B003 FETCH 4:7 RFC822
80 # <= B003 NO Messages 4:7 are no longer available.
81 # and in 4.1.2:
82 # => B001 FETCH 3:5 ENVELOPE
83 # <= * 3 FETCH ENVELOPE . . . (ENVELOPE info returned)
84 # <= B001 NO Some of the requested messages no longer exist
85 # and in 4.1.3:
86 # If all of the messages in the subsequent FETCH command have been
87 # expunged, the server SHOULD return only a tagged NO.
88 # and mayb it can return NIL or empty string for BODY[] ?
89
90 # Observed behaviors
91 # Panda: no data but just an OK!
92 # (tls-encrypted) => fetch1 UID FETCH 101 BODY.PEEK[]
93 # (tls-decrypted) <= fetch1 OK UID FETCH completed
94 # Dovecot: same
95 # => fetch1 UID FETCH 101 BODY.PEEK[]
96 # <= fetch1 OK Fetch completed (0.001 + 0.000 secs).
97 # Cyrus: same
98 # => fetch1 UID FETCH 101 BODY.PEEK[]
99 # <= fetch1 OK Completed (0.000 sec)
100 # Gandi: same
101 # (tls-encrypted) => fetch1 UID FETCH 101 BODY.PEEK[]
102 # (tls-decrypted) <= fetch1 OK Fetch completed (0.001 + 0.000 secs).
103 # Gmail
104 # (tls-encrypted) => fetch1 UID FETCH 101 BODY.PEEK[]
105 # (tls-decrypted) <= fetch1 OK Success
106
107 cat > "$imapd" <<EOSCRIPT
108 #!/bin/sh
109 cat <<EOF
110 * PREAUTH [CAPABILITY IMAP4REV1 UIDPLUS] authenticated
111 * LIST (\NoInferiors \UnMarked) "/" test/fold
112 1 OK LIST completed
113 * 1 EXISTS
114 * OK [UIDVALIDITY 1603585238] UID validity status
115 * OK [UIDNEXT 12] Predicted next UID
116 1 OK [READ-WRITE] SELECT completed
117 * 1 FETCH (UID 1 FLAGS (\Seen))
118 1 OK UID FETCH completed
119 fetch11 OK UID FETCH completed
120 1 OK SEARCH ALL completed
121 1 OK CLOSE completed
122 EOF
123 while read line; do :; done
124 EOSCRIPT
125 chmod 755 "$imapd"
126
127 check_exit '-eq 0' inc +imap
128
129 finish_test
130 exit ${failed:-0}