interplane.Get Omega
Read in your language

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

branch main Branches Tags History

mailhand / tests / scenarios / 55-creds.txt

73 lines · 3545 bytes Raw Blame History
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.
6mkdir @S/Mail
7mkdir @S/p
8write @S/p/port 19999\n
9#
10# missing: no accounts file -> exit 9
11run 0 - -- mh setup --home @S/h1 --maildir @S/Mail --me alice@example.test --name Alice
12run 9 - -- mh sync --home @S/h1 --account work
13out-has "op":"sync","ok":false,"refused":"no_credentials"
14err-has credentials file
15#
16# mode_0644 and mode_0640: group or other bits -> exit 5, the mode is named, the secret is not
17run 0 - -- srv acct @S/h1/accounts @S/p work imaps mail.test alice@example.test s3cret-SYNTH-pw 644
18run 5 - -- mh sync --home @S/h1 --account work
19out-has "refused":"credentials_mode","mode":"0644"
20err-has /h1/accounts refused: credentials_mode mode 0644 (group or others have access; chmod 600 it)
21out-not s3cret
22err-not s3cret
23out-not /h1/accounts
24run 0 - -- srv acct @S/h1/accounts @S/p work imaps mail.test alice@example.test s3cret-SYNTH-pw 640
25run 5 - -- mh sync --home @S/h1 --account work
26out-has "mode":"0640"
27#
28# mcp: the same refusal through the MCP tool "sync": no path and no secret in the reply
29run 0 tests/fixtures/imap/mcp-sync.in -- mh mcp --home @S/h1
30out-has credentials_mode
31out-not /h1/accounts
32out-not s3cret
33#
34# symlink: the accounts path is a symlink (to a good file) -> exit 5
35run 0 - -- mh setup --home @S/h2 --maildir @S/Mail --me alice@example.test --name Alice
36run 0 - -- srv acct @S/real-accounts @S/p work imaps mail.test alice@example.test s3cret-SYNTH-pw 600
37symlink @S/real-accounts @S/h2/accounts
38run 5 - -- mh sync --home @S/h2 --account work
39out-has "refused":"credentials_symlink"
40#
41# not_regular: the accounts path is a directory -> exit 5
42run 0 - -- mh setup --home @S/h3 --maildir @S/Mail --me alice@example.test --name Alice
43mkdir @S/h3/accounts
44run 5 - -- mh sync --home @S/h3 --account work
45out-has "refused":"credentials_not_regular"
46#
47# owner: config "accounts /etc/hostname" (a regular file owned by root) -> exit 5, owner first
48run 0 - -- mh setup --home @S/h4 --maildir @S/Mail --me alice@example.test --name Alice
49append @S/h4/config accounts /etc/hostname\n
50run 5 - -- mh sync --home @S/h4 --account work
51out-has "refused":"credentials_owner"
52err-has /etc/hostname refused: credentials_owner
53#
54# too_large: one byte over the credentials buffer -> exit 5
55run 0 - -- mh setup --home @S/h5 --maildir @S/Mail --me alice@example.test --name Alice
56run 0 - -- srv big @S/h5/accounts 262145
57run 5 - -- mh sync --home @S/h5 --account work
58out-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)
61run 0 - -- mh setup --home @S/h6 --maildir @S/Mail --me alice@example.test --name Alice
62run 0 - -- srv acct @S/h6/accounts @S/p work submission mail.test alice@example.test s3cret-SYNTH-pw 600
63run 2 - -- mh sync --home @S/h6 --account other
64out-has "refused":"account_not_found"
65run 9 - -- mh sync --home @S/h6 --account work
66out-has "refused":"account_has_no_imap"
67out-not s3cret
68err-not s3cret
69#
70# the audit log records the refused syncs without any credential
71file-has @S/h1/audit.log sync
72file-not @S/h1/audit.log s3cret
73tree-not @S/Mail s3cret