]> diplodocus.org Git - nmh/blob - test/imap/test-quirks-gmail
expect this commit to be force-replaced periodically
[nmh] / test / imap / test-quirks-gmail
1 #!/bin/sh
2
3 # Test illegal or questionable behaviors of GMail.
4
5 if test -z "$MH_OBJ_DIR"; then
6 srcdir=`dirname "$0"`/../..
7 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
8 fi
9
10 . "${srcdir}/test/oauth/common.sh"
11
12 # common.sh sets this to something crazy; did i do that?!
13 testname=${0#$srcdir/}
14
15 setup_test_without_data Mail
16
17 setup_service
18 fake_creds <<EOF
19 access-testuser: test-access
20 refresh-testuser: test-refresh
21 expire-testuser: 2000000000
22 EOF
23
24 imap_cleanup() {
25 #### Save exit status to use as status for this program.
26 status=$?
27 set +e
28
29 rm -f "$imapd"
30
31 [ -n "$imapd_pid" ] && kill $imapd_pid
32 "$MH_OBJ_DIR/target/debug/mhimap" imap shutdown
33
34 # TODO have cleanup allow additional cleanup registration?
35 # Or just allow it to accept status as argument.
36 (exit $status)
37 cleanup
38 }
39 trap imap_cleanup 0
40
41 covdir="$MH_OBJ_DIR/covdata/${MH_COVERAGE_PROFILE:-default}/$testname"
42 install -d "$covdir"
43 export LLVM_PROFILE_FILE="$covdir/$profile-%m.profraw"
44
45 imapd="$MH_TEST_DIR/$$.imapd"
46 start_fakeinetd "$imapd"
47 imapd_pid=$fakeinetd_pid
48
49 cat >> "$MH" <<EOF
50 Managed-Folders: imap
51 imap-manager: $MH_OBJ_DIR/target/debug/imap-folder-manager
52 imap-socket: $MH_TEST_DIR/Mail/imap.d/socket
53 imap-db: $MH_TEST_DIR/Mail/imap.d
54 imap-host: 127.0.0.1
55 imap-port: $fakeinetd_port
56 imap-tls: don't protect my data i know what i'm doing
57 imap-auth: SASL
58 imap-user: testuser
59 imap-saslmech: xoauth2
60 imap-authservice: test
61 EOF
62 if [ -n "$MH_TEST_IMAP_LOG_LEVEL" ]; then
63 echo "imap-log-level: $MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
64 echo "imap-log-$MH_TEST_IMAP_LOG_LEVEL-to: $MH_TEST_DIR/$profile/imap.d/log.$MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
65 fi
66
67 # It's the "* OK [HIGHESTMODSEQ 8869]" that's illegal: a space is required after the close bracket.
68 cat > "$imapd" <<EOSCRIPT
69 #!/bin/sh
70 cat <<EOF
71 * OK Gimap ready for requests
72 * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN AUTH=OAUTHBEARER AUTH=XOAUTH
73 1 OK capability response
74 * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT LIST-EXTENDED LIST-STATUS LITERAL- SPECIAL-USE APPENDLIMIT=35651584
75 1 OK authenticate response
76 1 OK Success
77 * FLAGS (\Answered \Flagged \Draft \Deleted \Seen $NotPhishing $Phishing)
78 * OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen $NotPhishing $Phishing \*)] Flags permitted.
79 * OK [UIDVALIDITY 62] UIDs valid.
80 * 0 EXISTS
81 * 0 RECENT
82 * OK [UIDNEXT 1] Predicted next UID.
83 * OK [HIGHESTMODSEQ 8869]
84 1 OK [READ-WRITE] imap/foo selected. (Success)
85 1 OK Returned to authenticated state. (Success)
86 EOF
87 while read line; do :; done
88 EOSCRIPT
89 chmod 755 "$imapd"
90
91 folder -create +imap/foo
92
93 finish_test
94 exit ${failed:-0}