mailhand
mailhand: agents look after a person's email in seeded Omega. Maildir + MIME parsing, JSONL CLI and MCP, rule triage, policy-gated sending, hash-chained audit. Free (Apache-2.0).
Brought by drakestapleton
mailhand / tests / scenarios / 60-imap.txt
| 1 | # IMAP sync (ImapSync): mailhand sync against the fake IMAP server "srv imap" (tests/srv/imap.om), |
| 2 | # over real TLS 1.3 (omtls from DEPS; host name mail.test, the omtls test certificates). Synthetic mail only. |
| 3 | # Each server run picks a random loopback port in 19000..19999; "srv acct" waits for it and writes |
| 4 | # the accounts file (mode 0600, "connect 127.0.0.1"). Maildir names are deterministic: |
| 5 | # INTERNALDATE.V<UIDVALIDITY>U<UID>F<first 8 hex of SHA-256(local folder name)>.mailhand |
| 6 | # INTERNALDATE "05-Nov-2026 12:00:00 +0100" = 1793876400 (Wolfram: UnixTime of 2026-11-05 11:00 UTC); |
| 7 | # SHA-256 prefixes: INBOX 83ecb521, Work 104ab921, Lists.Omega 2a0fa0bb. |
| 8 | mkdir @S/Mail |
| 9 | run 0 - -- mh setup --home @S/h --maildir @S/Mail --me alice@example.test --name Alice |
| 10 | # the credentials live outside the homes here (config "accounts PATH"), so the leak scan below can |
| 11 | # cover every file under the homes; 55-creds checks the default HOME/accounts |
| 12 | mkdir @S/c |
| 13 | append @S/h/config accounts @S/c/accounts\n |
| 14 | |
| 15 | # |
| 16 | # first_sync: two new messages; the \Seen one goes to cur/ with :2,S, the other to new/; |
| 17 | # the bytes are the server's bytes; AUTHENTICATE PLAIN with SASL-IR over TLS |
| 18 | mkdir @S/s1 |
| 19 | write @S/s1/state caps IMAP4rev1 AUTH=PLAIN SASL-IR MOVE UIDPLUS\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 7\nbox Archive 9\nbox Work 11\nmsg INBOX 1 S @R/tests/fixtures/imap/m1.eml\nmsg INBOX 2 - @R/tests/fixtures/imap/m2.eml\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 20 | bg srv imap @S/s1 |
| 21 | run 0 - -- srv acct @S/c/accounts @S/s1 work imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 22 | run 0 - -- mh sync --home @S/h --account work |
| 23 | out-has "op":"sync","folder":"INBOX","ok":true,"uidvalidity":7,"fetched":2,"flags_pushed":0,"moves_pushed":0 |
| 24 | out-not s3cret-SYNTH-pw |
| 25 | err-not s3cret-SYNTH-pw |
| 26 | wait 0 |
| 27 | file-eq @S/Mail/cur/1793876400.V7U1F83ecb521.mailhand:2,S tests/fixtures/imap/m1.eml |
| 28 | file-eq @S/Mail/new/1793876400.V7U2F83ecb521.mailhand tests/fixtures/imap/m2.eml |
| 29 | file-has @S/Mail/mailhand-imap uidvalidity 7 |
| 30 | file-has @S/Mail/mailhand-imap last 2 |
| 31 | file-has @S/Mail/mailhand-imap m 1 1793876400.V7U1F83ecb521.mailhand S |
| 32 | file-has @S/Mail/mailhand-imap m 2 1793876400.V7U2F83ecb521.mailhand - |
| 33 | file-has @S/s1/log AUTH OK |
| 34 | file-has @S/s1/log A5 UID FETCH 1:* (FLAGS) |
| 35 | file-has @S/s1/log A6 UID FETCH 1 (UID FLAGS INTERNALDATE RFC822.SIZE BODY.PEEK[]) |
| 36 | run 0 - -- mh list --home @S/h |
| 37 | out-has Lunch on Friday |
| 38 | out-has Report {draft} (v2) |
| 39 | # |
| 40 | # push_back: mark-read and move locally, then sync: UID STORE +FLAGS.SILENT and UID MOVE (with |
| 41 | # COPYUID: the destination's state gets a "c" record); a new \Flagged message lands in cur/ :2,F |
| 42 | run 0 - -- mh mark-read --home @S/h --id INBOX/1793876400.V7U2F83ecb521.mailhand |
| 43 | run 0 - -- mh move --home @S/h --id INBOX/1793876400.V7U1F83ecb521.mailhand --folder Archive |
| 44 | mkdir @S/s2 |
| 45 | write @S/s2/state caps IMAP4rev1 AUTH=PLAIN SASL-IR MOVE UIDPLUS\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 7\nbox Archive 9\nbox Work 11\nmsg INBOX 1 S @R/tests/fixtures/imap/m1.eml\nmsg INBOX 2 - @R/tests/fixtures/imap/m2.eml\nmsg INBOX 3 F @R/tests/fixtures/imap/m3.eml\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 46 | bg srv imap @S/s2 |
| 47 | run 0 - -- srv acct @S/c/accounts @S/s2 work imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 48 | run 0 - -- mh sync --home @S/h --account work |
| 49 | out-has "fetched":1,"flags_pushed":1,"moves_pushed":1 |
| 50 | wait 0 |
| 51 | file-has @S/s2/log A5 UID MOVE 1 "Archive" |
| 52 | file-has @S/s2/log A6 UID STORE 2 +FLAGS.SILENT (\Seen) |
| 53 | file-has @S/s2/log A7 UID FETCH 3:* (FLAGS) |
| 54 | file-has @S/s2/state.out msg Archive 1 S |
| 55 | file-has @S/s2/state.out msg INBOX 2 S |
| 56 | file-eq @S/Mail/cur/1793876400.V7U3F83ecb521.mailhand:2,F tests/fixtures/imap/m3.eml |
| 57 | file-has @S/Mail/.Archive/mailhand-imap c 9 1 1793876400.V7U1F83ecb521.mailhand S |
| 58 | file-not @S/Mail/mailhand-imap V7U1F |
| 59 | file-has @S/Mail/mailhand-imap m 2 1793876400.V7U2F83ecb521.mailhand S |
| 60 | # |
| 61 | # copyuid_adopt: syncing Archive turns the "c" record into an "m" record: nothing is fetched twice |
| 62 | mkdir @S/s3 |
| 63 | write @S/s3/state caps IMAP4rev1 AUTH=PLAIN SASL-IR MOVE UIDPLUS\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 7\nbox Archive 9\nmsg Archive 1 S @R/tests/fixtures/imap/m1.eml\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 64 | bg srv imap @S/s3 |
| 65 | run 0 - -- srv acct @S/c/accounts @S/s3 work imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 66 | run 0 - -- mh sync --home @S/h --account work --folder Archive |
| 67 | out-has "folder":"Archive","ok":true,"uidvalidity":9,"fetched":0 |
| 68 | wait 0 |
| 69 | file-has @S/Mail/.Archive/mailhand-imap m 1 1793876400.V7U1F83ecb521.mailhand S |
| 70 | file-not @S/s3/log BODY.PEEK |
| 71 | # |
| 72 | # move_uidplus: no MOVE, UIDPLUS: UID COPY, UID STORE \Deleted, UID EXPUNGE of that UID only; |
| 73 | # no SASL-IR: AUTHENTICATE PLAIN answers the server's continuation |
| 74 | run 0 - -- mh move --home @S/h --id INBOX/1793876400.V7U3F83ecb521.mailhand --folder Work |
| 75 | mkdir @S/s4 |
| 76 | write @S/s4/state caps IMAP4rev1 AUTH=PLAIN UIDPLUS\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 7\nbox Work 11\nmsg INBOX 2 S @R/tests/fixtures/imap/m2.eml\nmsg INBOX 3 F @R/tests/fixtures/imap/m3.eml\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 77 | bg srv imap @S/s4 |
| 78 | run 0 - -- srv acct @S/c/accounts @S/s4 work imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 79 | run 0 - -- mh sync --home @S/h --account work |
| 80 | out-has "moves_pushed":1 |
| 81 | out-not "risk" |
| 82 | wait 0 |
| 83 | file-has @S/s4/log AUTH OK |
| 84 | file-has @S/s4/log UID COPY 3 "Work" |
| 85 | file-has @S/s4/log UID STORE 3 +FLAGS.SILENT (\Deleted) |
| 86 | file-has @S/s4/log UID EXPUNGE 3 |
| 87 | file-has @S/s4/state.out msg Work 1 F |
| 88 | file-has @S/Mail/.Work/mailhand-imap c 11 1 1793876400.V7U3F83ecb521.mailhand F |
| 89 | # |
| 90 | # move_no_uidplus: no MOVE, no UIDPLUS, no AUTH=PLAIN: LOGIN (quoted string with \" and \\), |
| 91 | # COPY + STORE \Deleted + EXPUNGE, reported as a risk: the EXPUNGE also removed UID 4, which was |
| 92 | # already \Deleted on the server. No COPYUID: the destination gets a pending "p" record. |
| 93 | run 0 - -- mh move --home @S/h --id INBOX/1793876400.V7U2F83ecb521.mailhand --folder Work |
| 94 | mkdir @S/s5 |
| 95 | write @S/s5/state caps IMAP4rev1\nuser alice@example.test\npass pa"ss\word-SYNTH\nbox INBOX 7\nbox Work 11\nmsg INBOX 2 S @R/tests/fixtures/imap/m2.eml\nmsg INBOX 4 T @R/tests/fixtures/imap/m3.eml\nmsg Work 1 F @R/tests/fixtures/imap/m3.eml\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 96 | bg srv imap @S/s5 |
| 97 | run 0 - -- srv acct @S/c/accounts @S/s5 work imaps mail.test alice@example.test pa"ss\word-SYNTH 600 |
| 98 | run 0 - -- mh sync --home @S/h --account work |
| 99 | out-has "moves_pushed":1 |
| 100 | out-has "risk":"expunge_without_uidplus |
| 101 | out-not pa"ss |
| 102 | wait 0 |
| 103 | file-has @S/s5/log AUTH OK |
| 104 | file-has @S/s5/log UID COPY 2 "Work" |
| 105 | file-has @S/s5/log EXPUNGED 2 |
| 106 | file-has @S/s5/log EXPUNGED 4 |
| 107 | file-has @S/Mail/.Work/mailhand-imap p 1793876400.V7U2F83ecb521.mailhand |
| 108 | # |
| 109 | # pending_adopt: syncing Work fetches UID 2, finds the same bytes in the pending local message and |
| 110 | # adopts it (no second copy); LOGIN with a literal (the password has bytes a quoted string cannot carry) |
| 111 | mkdir @S/s6 |
| 112 | write @S/s6/state caps IMAP4rev1\nuser alice@example.test\npass pässwörd-SYNTH\nbox Work 11\nmsg Work 1 F @R/tests/fixtures/imap/m3.eml\nmsg Work 2 S @R/tests/fixtures/imap/m2.eml\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 113 | bg srv imap @S/s6 |
| 114 | run 0 - -- srv acct @S/c/accounts @S/s6 work imaps mail.test alice@example.test pässwörd-SYNTH 600 |
| 115 | run 0 - -- mh sync --home @S/h --account work --folder Work |
| 116 | out-has "folder":"Work","ok":true,"uidvalidity":11,"fetched":0,"flags_pushed":0,"moves_pushed":0,"adopted":1 |
| 117 | wait 0 |
| 118 | file-has @S/s6/log AUTH OK |
| 119 | absent @S/Mail/.Work/cur/1793876400.V11U2F104ab921.mailhand:2,S |
| 120 | exists @S/Mail/.Work/cur/1793876400.V7U2F83ecb521.mailhand:2,S |
| 121 | file-has @S/Mail/.Work/mailhand-imap m 2 1793876400.V7U2F83ecb521.mailhand S |
| 122 | file-has @S/Mail/.Work/mailhand-imap m 1 1793876400.V7U3F83ecb521.mailhand F |
| 123 | file-not @S/Mail/.Work/mailhand-imap p 1793876400 |
| 124 | # |
| 125 | # auth_refused: a wrong password is a defined refusal (exit 3), nothing is selected |
| 126 | mkdir @S/s7 |
| 127 | write @S/s7/state caps IMAP4rev1 AUTH=PLAIN SASL-IR\nuser alice@example.test\npass another-SYNTH\nbox INBOX 7\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 128 | bg srv imap @S/s7 |
| 129 | run 0 - -- srv acct @S/c/accounts @S/s7 work imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 130 | run 3 - -- mh sync --home @S/h --account work |
| 131 | out-has "refused":"authentication_refused" |
| 132 | wait 0 |
| 133 | file-has @S/s7/log AUTH REFUSED |
| 134 | file-not @S/s7/log SELECT |
| 135 | # |
| 136 | # second account, second Maildir: UIDVALIDITY change, NO/BAD replies, literals, timeouts |
| 137 | mkdir @S/Mail2 |
| 138 | run 0 - -- mh setup --home @S/h2 --maildir @S/Mail2 --me alice@example.test --name Alice |
| 139 | mkdir @S/c2 |
| 140 | append @S/h2/config accounts @S/c2/accounts\n |
| 141 | |
| 142 | mkdir @S/t1 |
| 143 | write @S/t1/state caps IMAP4rev1 AUTH=PLAIN SASL-IR MOVE UIDPLUS\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 7\nmsg INBOX 1 - @R/tests/fixtures/imap/m1.eml\nmsg INBOX 2 R @R/tests/fixtures/imap/m2.eml\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 144 | bg srv imap @S/t1 |
| 145 | run 0 - -- srv acct @S/c2/accounts @S/t1 home imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 146 | run 0 - -- mh sync --home @S/h2 --account home |
| 147 | out-has "fetched":2 |
| 148 | wait 0 |
| 149 | # |
| 150 | # uidvalidity_changed: refused (exit 3) before anything is fetched; the state is unchanged |
| 151 | mkdir @S/t2 |
| 152 | write @S/t2/state caps IMAP4rev1 AUTH=PLAIN SASL-IR MOVE UIDPLUS\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 8\nmsg INBOX 5 - @R/tests/fixtures/imap/m1.eml\nmsg INBOX 6 R @R/tests/fixtures/imap/m2.eml\nmsg INBOX 7 - @R/tests/fixtures/imap/m3.eml\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 153 | bg srv imap @S/t2 |
| 154 | run 0 - -- srv acct @S/c2/accounts @S/t2 home imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 155 | run 3 - -- mh sync --home @S/h2 --account home |
| 156 | out-has "ok":false,"refused":"uidvalidity_changed","uidvalidity":8,"uidvalidity_was":7 |
| 157 | wait 0 |
| 158 | file-not @S/t2/log FETCH |
| 159 | file-has @S/Mail2/mailhand-imap uidvalidity 7 |
| 160 | # |
| 161 | # resync: every record becomes pending and is matched by content: two adopted, one new, no duplicate |
| 162 | mkdir @S/t3 |
| 163 | write @S/t3/state caps IMAP4rev1 AUTH=PLAIN SASL-IR MOVE UIDPLUS\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 8\nmsg INBOX 5 - @R/tests/fixtures/imap/m1.eml\nmsg INBOX 6 R @R/tests/fixtures/imap/m2.eml\nmsg INBOX 7 - @R/tests/fixtures/imap/m3.eml\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 164 | bg srv imap @S/t3 |
| 165 | run 0 - -- srv acct @S/c2/accounts @S/t3 home imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 166 | run 0 - -- mh sync --home @S/h2 --account home --resync |
| 167 | out-has "uidvalidity":8,"uidvalidity_was":7,"fetched":1,"flags_pushed":0,"moves_pushed":0,"adopted":2 |
| 168 | wait 0 |
| 169 | file-has @S/Mail2/mailhand-imap uidvalidity 8 |
| 170 | file-has @S/Mail2/mailhand-imap m 5 1793876400.V7U1F83ecb521.mailhand - |
| 171 | file-has @S/Mail2/mailhand-imap m 6 1793876400.V7U2F83ecb521.mailhand R |
| 172 | file-has @S/Mail2/mailhand-imap m 7 1793876400.V8U7F83ecb521.mailhand - |
| 173 | absent @S/Mail2/new/1793876400.V8U5F83ecb521.mailhand |
| 174 | run 0 - -- mh stats --home @S/h2 |
| 175 | out-has "messages":3 |
| 176 | # |
| 177 | # select_no: a tagged NO to SELECT is a defined refusal |
| 178 | mkdir @S/t4 |
| 179 | write @S/t4/state caps IMAP4rev1 AUTH=PLAIN SASL-IR MOVE UIDPLUS\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 8\nopt select-no INBOX\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 180 | bg srv imap @S/t4 |
| 181 | run 0 - -- srv acct @S/c2/accounts @S/t4 home imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 182 | run 3 - -- mh sync --home @S/h2 --account home |
| 183 | out-has "refused":"select_refused" |
| 184 | wait 0 |
| 185 | # |
| 186 | # fetch_bad: a tagged BAD to one message FETCH: refused (exit 3), counted, and "last" stays below it |
| 187 | mkdir @S/t5 |
| 188 | write @S/t5/state caps IMAP4rev1 AUTH=PLAIN SASL-IR MOVE UIDPLUS\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 8\nmsg INBOX 5 - @R/tests/fixtures/imap/m1.eml\nmsg INBOX 6 R @R/tests/fixtures/imap/m2.eml\nmsg INBOX 7 - @R/tests/fixtures/imap/m3.eml\nmsg INBOX 9 - @R/tests/fixtures/imap/m3.eml\nopt fetch-bad 9\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 189 | bg srv imap @S/t5 |
| 190 | run 0 - -- srv acct @S/c2/accounts @S/t5 home imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 191 | run 3 - -- mh sync --home @S/h2 --account home |
| 192 | out-has "fetched":0 |
| 193 | out-has "refused_by_server":1 |
| 194 | wait 0 |
| 195 | file-has @S/Mail2/mailhand-imap last 7 |
| 196 | # |
| 197 | # store_no: a refused UID STORE keeps the old flags in the state, so the next sync tries again |
| 198 | run 0 - -- mh mark-read --home @S/h2 --id INBOX/1793876400.V8U7F83ecb521.mailhand |
| 199 | mkdir @S/t6 |
| 200 | write @S/t6/state caps IMAP4rev1 AUTH=PLAIN SASL-IR MOVE UIDPLUS\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 8\nmsg INBOX 5 - @R/tests/fixtures/imap/m1.eml\nmsg INBOX 6 R @R/tests/fixtures/imap/m2.eml\nmsg INBOX 7 - @R/tests/fixtures/imap/m3.eml\nopt store-no\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 201 | bg srv imap @S/t6 |
| 202 | run 0 - -- srv acct @S/c2/accounts @S/t6 home imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 203 | run 0 - -- mh sync --home @S/h2 --account home |
| 204 | out-has "flags_pushed":0 |
| 205 | out-has "refused_by_server":1 |
| 206 | wait 0 |
| 207 | file-has @S/Mail2/mailhand-imap m 7 1793876400.V8U7F83ecb521.mailhand - |
| 208 | # |
| 209 | # literals: mailbox names as literals, BODY[] before UID in the FETCH reply, the reply written in |
| 210 | # 7-byte pieces, a message whose text looks like IMAP syntax; --folder all maps "Lists/Omega" to the |
| 211 | # Maildir++ folder .Lists.Omega |
| 212 | mkdir @S/t7 |
| 213 | write @S/t7/state caps IMAP4rev1 AUTH=PLAIN SASL-IR MOVE UIDPLUS\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 8\nbox Lists/Omega 12\nmsg INBOX 5 - @R/tests/fixtures/imap/m1.eml\nmsg INBOX 6 R @R/tests/fixtures/imap/m2.eml\nmsg INBOX 7 - @R/tests/fixtures/imap/m3.eml\nmsg Lists/Omega 1 - @R/tests/fixtures/imap/m2.eml\nopt literal-names\nopt body-first\nopt split-literal\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 214 | bg srv imap @S/t7 |
| 215 | run 0 - -- srv acct @S/c2/accounts @S/t7 home imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 216 | run 0 - -- mh sync --home @S/h2 --account home --folder all |
| 217 | out-lines 2 |
| 218 | out-has "folder":"Lists.Omega","ok":true,"uidvalidity":12,"fetched":1 |
| 219 | wait 0 |
| 220 | file-eq @S/Mail2/.Lists.Omega/new/1793876400.V12U1F2a0fa0bb.mailhand tests/fixtures/imap/m2.eml |
| 221 | file-has @S/t7/log SELECT "Lists/Omega" |
| 222 | # |
| 223 | # refused handshakes (real TLS 1.3, omtls): the server presents a certificate for another name, an |
| 224 | # expired one, or one from a root that is not in the trust store. Each is a defined refusal (exit 6, |
| 225 | # connection_failed, the omtls reason on stderr) before any command: the server logs nothing, so no |
| 226 | # credential was sent. |
| 227 | mkdir @S/r1 |
| 228 | write @S/r1/state caps IMAP4rev1 AUTH=PLAIN SASL-IR\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 7\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-other.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 229 | bg srv imap @S/r1 |
| 230 | run 0 - -- srv acct @S/c2/accounts @S/r1 home imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 231 | run 6 - -- mh sync --home @S/h2 --account home |
| 232 | out-has "refused":"connection_failed" |
| 233 | err-has sync: TLS: certificate does not match the host name |
| 234 | wait 0 |
| 235 | absent @S/r1/log |
| 236 | mkdir @S/r2 |
| 237 | write @S/r2/state caps IMAP4rev1 AUTH=PLAIN SASL-IR\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 7\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-expired.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 238 | bg srv imap @S/r2 |
| 239 | run 0 - -- srv acct @S/c2/accounts @S/r2 home imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 240 | run 6 - -- mh sync --home @S/h2 --account home |
| 241 | err-has sync: TLS: certificate expired or not yet valid |
| 242 | wait 0 |
| 243 | absent @S/r2/log |
| 244 | mkdir @S/r3 |
| 245 | write @S/r3/state caps IMAP4rev1 AUTH=PLAIN SASL-IR\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 7\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-untrusted.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 246 | bg srv imap @S/r3 |
| 247 | run 0 - -- srv acct @S/c2/accounts @S/r3 home imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 248 | run 6 - -- mh sync --home @S/h2 --account home |
| 249 | err-has sync: TLS: certificate not issued by a trusted root |
| 250 | wait 0 |
| 251 | absent @S/r3/log |
| 252 | # |
| 253 | # roots_missing: a trust store that cannot be loaded is refused (exit 6, trust_store_failed) before any |
| 254 | # connection; the server (good certificate, waits for one connection) is then served by a normal sync |
| 255 | mkdir @S/r4 |
| 256 | write @S/r4/state caps IMAP4rev1 AUTH=PLAIN SASL-IR\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 8\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @S/no-such-roots.pem\n |
| 257 | bg srv imap @S/r4 |
| 258 | run 0 - -- srv acct @S/c2/accounts @S/r4 home imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 259 | run 6 - -- mh sync --home @S/h2 --account home |
| 260 | out-has "refused":"trust_store_failed" |
| 261 | append @S/c2/accounts roots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 262 | run 0 - -- mh sync --home @S/h2 --account home |
| 263 | wait 0 |
| 264 | file-has @S/r4/log AUTH OK |
| 265 | # |
| 266 | # timeout: io_timeout 1 against a server that stalls 3 s on SELECT: the sync fails with exit 6 |
| 267 | append @S/h2/config io_timeout 1\n |
| 268 | mkdir @S/t8 |
| 269 | write @S/t8/state caps IMAP4rev1 AUTH=PLAIN SASL-IR MOVE UIDPLUS\nuser alice@example.test\npass s3cret-SYNTH-pw\nbox INBOX 8\nopt stall\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n |
| 270 | bg srv imap @S/t8 |
| 271 | run 0 - -- srv acct @S/c2/accounts @S/t8 home imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 272 | run 6 - -- mh sync --home @S/h2 --account home |
| 273 | out-has "refused":"connection_failed" |
| 274 | err-has sync: TLS: timed out |
| 275 | max-ns 2900000000 |
| 276 | wait 0 |
| 277 | # |
| 278 | # credential_leak_scan: neither the synthetic passwords nor the AUTH PLAIN blob of the first one |
| 279 | # appear in any file mailhand wrote (homes, Maildirs, audit logs, states) or in its last outputs |
| 280 | tree-not @S/h s3cret-SYNTH-pw |
| 281 | tree-not @S/h2 s3cret-SYNTH-pw |
| 282 | tree-not @S/Mail s3cret-SYNTH-pw |
| 283 | tree-not @S/Mail2 s3cret-SYNTH-pw |
| 284 | tree-not @S/Mail pa"ss\word |
| 285 | tree-not @S/Mail pässwörd |
| 286 | tree-not @S/h AGFsaWNlQGV4YW1wbGUudGVzdABzM2NyZXQtU1lOVEgtcHc= |
| 287 | tree-not @S/h2 AGFsaWNlQGV4YW1wbGUudGVzdABzM2NyZXQtU1lOVEgtcHc= |
| 288 | file-not @S/h/audit.log s3cret |
| 289 | file-has @S/h/audit.log sync |