mirror of
https://github.com/hanzoai/mail.git
synced 2026-09-23 23:53:02 +00:00
Fork of github.com/mjl-/mox at 5656ca6d1b
(upstream v0.0.15 plus 55 commits).
Rename the module path in go.mod and the import paths in 268 Go files. Also
update the five scripts that "go install" the module (genwebsite.sh,
docker-release.sh, apidiff.sh, test-upgrade.sh, Dockerfile.release), which
would otherwise build upstream rather than this fork.
Add NOTICE recording the upstream project, author, license, and fork point,
and stating which license covers which files: MIT for the mox source and our
changes, MPL-2.0 for publicsuffix/public_suffix_list.txt alone, and the
vendored dependencies' own licenses under licenses/. Embed NOTICE so
"mail licenses" prints the lineage from the running binary. LICENSE.MIT,
LICENSE.MPLv2.0 and the licenses/ tree are preserved verbatim; no code is
relicensed.
The mox command name, config keys, data directory layout and website content
are unchanged. LLM.md records the fork point, the rename, what was left alone,
and the steps to stand the server up.
Co-authored-by: Hanzo Dev <[email protected]>
86 lines
2.9 KiB
Go
86 lines
2.9 KiB
Go
package imapserver
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/hanzoai/mail/imapclient"
|
|
)
|
|
|
|
func TestSelect(t *testing.T) {
|
|
testSelectExamine(t, false, false)
|
|
}
|
|
|
|
func TestExamine(t *testing.T) {
|
|
testSelectExamine(t, true, false)
|
|
}
|
|
|
|
func TestSelectUIDOnly(t *testing.T) {
|
|
testSelectExamine(t, false, true)
|
|
}
|
|
|
|
func TestExamineUIDOnly(t *testing.T) {
|
|
testSelectExamine(t, true, true)
|
|
}
|
|
|
|
// select and examine are pretty much the same. but examine opens readonly instead of readwrite.
|
|
func testSelectExamine(t *testing.T, examine, uidonly bool) {
|
|
defer mockUIDValidity()()
|
|
tc := start(t, uidonly)
|
|
defer tc.close()
|
|
|
|
tc.login("[email protected]", password0)
|
|
|
|
cmd := "select"
|
|
okcode := "READ-WRITE"
|
|
if examine {
|
|
cmd = "examine"
|
|
okcode = "READ-ONLY"
|
|
}
|
|
|
|
uclosed := imapclient.UntaggedResult{Status: imapclient.OK, Code: imapclient.CodeWord("CLOSED"), Text: "x"}
|
|
flags := strings.Split(`\Seen \Answered \Flagged \Deleted \Draft $Forwarded $Junk $NotJunk $Phishing $MDNSent`, " ")
|
|
permflags := strings.Split(`\Seen \Answered \Flagged \Deleted \Draft $Forwarded $Junk $NotJunk $Phishing $MDNSent \*`, " ")
|
|
uflags := imapclient.UntaggedFlags(flags)
|
|
upermflags := imapclient.UntaggedResult{Status: imapclient.OK, Code: imapclient.CodePermanentFlags(permflags), Text: "x"}
|
|
urecent := imapclient.UntaggedRecent(0)
|
|
uexists0 := imapclient.UntaggedExists(0)
|
|
uexists1 := imapclient.UntaggedExists(1)
|
|
uuidval1 := imapclient.UntaggedResult{Status: imapclient.OK, Code: imapclient.CodeUIDValidity(1), Text: "x"}
|
|
uuidnext1 := imapclient.UntaggedResult{Status: imapclient.OK, Code: imapclient.CodeUIDNext(1), Text: "x"}
|
|
ulist := imapclient.UntaggedList{Separator: '/', Mailbox: "Inbox"}
|
|
uunseen := imapclient.UntaggedResult{Status: imapclient.OK, Code: imapclient.CodeUnseen(1), Text: "x"}
|
|
uuidnext2 := imapclient.UntaggedResult{Status: imapclient.OK, Code: imapclient.CodeUIDNext(2), Text: "x"}
|
|
|
|
// Parameter required.
|
|
tc.transactf("bad", "%s", cmd)
|
|
|
|
// Mailbox does not exist.
|
|
tc.transactf("no", "%s bogus", cmd)
|
|
tc.transactf("no", "%s expungebox", cmd)
|
|
|
|
tc.transactf("ok", "%s inbox", cmd)
|
|
tc.xuntagged(uflags, upermflags, urecent, uexists0, uuidval1, uuidnext1, ulist)
|
|
tc.xcodeWord(okcode)
|
|
|
|
tc.transactf("ok", `%s "inbox"`, cmd)
|
|
tc.xuntagged(uclosed, uflags, upermflags, urecent, uexists0, uuidval1, uuidnext1, ulist)
|
|
tc.xcodeWord(okcode)
|
|
|
|
// Append a message. It will be reported as UNSEEN.
|
|
tc.client.Append("inbox", makeAppend(exampleMsg))
|
|
tc.transactf("ok", "%s inbox", cmd)
|
|
if uidonly {
|
|
tc.xuntagged(uclosed, uflags, upermflags, urecent, uexists1, uuidval1, uuidnext2, ulist)
|
|
} else {
|
|
tc.xuntagged(uclosed, uflags, upermflags, urecent, uunseen, uexists1, uuidval1, uuidnext2, ulist)
|
|
}
|
|
tc.xcodeWord(okcode)
|
|
|
|
// With imap4rev2, we no longer get untagged RECENT or untagged UNSEEN.
|
|
tc.client.Enable(imapclient.CapIMAP4rev2)
|
|
tc.transactf("ok", "%s inbox", cmd)
|
|
tc.xuntagged(uclosed, uflags, upermflags, uexists1, uuidval1, uuidnext2, ulist)
|
|
tc.xcodeWord(okcode)
|
|
}
|