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 / 55-creds.txt
| 1 | # Credentials (Credentials, src/cr.om): HOME/accounts (or config "accounts PATH") must be a regular |
| 2 | # file, not a symlink, owned by the user running mailhand, with mode & 077 == 0, and fit the one |
| 3 | # credentials buffer (262144 bytes). Each refusal names the file and the mode on stderr, never the |
| 4 | # content; the JSON record (also what MCP returns) carries neither the path nor the content. |
| 5 | # No server is needed: "srv acct" only waits for the port file written here. |
| 6 | mkdir @S/Mail |
| 7 | mkdir @S/p |
| 8 | write @S/p/port 19999\n |
| 9 | # |
| 10 | # missing: no accounts file -> exit 9 |
| 11 | run 0 - -- mh setup --home @S/h1 --maildir @S/Mail --me alice@example.test --name Alice |
| 12 | run 9 - -- mh sync --home @S/h1 --account work |
| 13 | out-has "op":"sync","ok":false,"refused":"no_credentials" |
| 14 | err-has credentials file |
| 15 | # |
| 16 | # mode_0644 and mode_0640: group or other bits -> exit 5, the mode is named, the secret is not |
| 17 | run 0 - -- srv acct @S/h1/accounts @S/p work imaps mail.test alice@example.test s3cret-SYNTH-pw 644 |
| 18 | run 5 - -- mh sync --home @S/h1 --account work |
| 19 | out-has "refused":"credentials_mode","mode":"0644" |
| 20 | err-has /h1/accounts refused: credentials_mode mode 0644 (group or others have access; chmod 600 it) |
| 21 | out-not s3cret |
| 22 | err-not s3cret |
| 23 | out-not /h1/accounts |
| 24 | run 0 - -- srv acct @S/h1/accounts @S/p work imaps mail.test alice@example.test s3cret-SYNTH-pw 640 |
| 25 | run 5 - -- mh sync --home @S/h1 --account work |
| 26 | out-has "mode":"0640" |
| 27 | # |
| 28 | # mcp: the same refusal through the MCP tool "sync": no path and no secret in the reply |
| 29 | run 0 tests/fixtures/imap/mcp-sync.in -- mh mcp --home @S/h1 |
| 30 | out-has credentials_mode |
| 31 | out-not /h1/accounts |
| 32 | out-not s3cret |
| 33 | # |
| 34 | # symlink: the accounts path is a symlink (to a good file) -> exit 5 |
| 35 | run 0 - -- mh setup --home @S/h2 --maildir @S/Mail --me alice@example.test --name Alice |
| 36 | run 0 - -- srv acct @S/real-accounts @S/p work imaps mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 37 | symlink @S/real-accounts @S/h2/accounts |
| 38 | run 5 - -- mh sync --home @S/h2 --account work |
| 39 | out-has "refused":"credentials_symlink" |
| 40 | # |
| 41 | # not_regular: the accounts path is a directory -> exit 5 |
| 42 | run 0 - -- mh setup --home @S/h3 --maildir @S/Mail --me alice@example.test --name Alice |
| 43 | mkdir @S/h3/accounts |
| 44 | run 5 - -- mh sync --home @S/h3 --account work |
| 45 | out-has "refused":"credentials_not_regular" |
| 46 | # |
| 47 | # owner: config "accounts /etc/hostname" (a regular file owned by root) -> exit 5, owner first |
| 48 | run 0 - -- mh setup --home @S/h4 --maildir @S/Mail --me alice@example.test --name Alice |
| 49 | append @S/h4/config accounts /etc/hostname\n |
| 50 | run 5 - -- mh sync --home @S/h4 --account work |
| 51 | out-has "refused":"credentials_owner" |
| 52 | err-has /etc/hostname refused: credentials_owner |
| 53 | # |
| 54 | # too_large: one byte over the credentials buffer -> exit 5 |
| 55 | run 0 - -- mh setup --home @S/h5 --maildir @S/Mail --me alice@example.test --name Alice |
| 56 | run 0 - -- srv big @S/h5/accounts 262145 |
| 57 | run 5 - -- mh sync --home @S/h5 --account work |
| 58 | out-has "refused":"credentials_too_large" |
| 59 | # |
| 60 | # not_found and no_imap: a good file without that account (exit 2), an account without imap (exit 9) |
| 61 | run 0 - -- mh setup --home @S/h6 --maildir @S/Mail --me alice@example.test --name Alice |
| 62 | run 0 - -- srv acct @S/h6/accounts @S/p work submission mail.test alice@example.test s3cret-SYNTH-pw 600 |
| 63 | run 2 - -- mh sync --home @S/h6 --account other |
| 64 | out-has "refused":"account_not_found" |
| 65 | run 9 - -- mh sync --home @S/h6 --account work |
| 66 | out-has "refused":"account_has_no_imap" |
| 67 | out-not s3cret |
| 68 | err-not s3cret |
| 69 | # |
| 70 | # the audit log records the refused syncs without any credential |
| 71 | file-has @S/h1/audit.log sync |
| 72 | file-not @S/h1/audit.log s3cret |
| 73 | tree-not @S/Mail s3cret |