6 "github.com/mjl-/mox/imapclient"
9func TestCreate(t *testing.T) {
13 tc2 := startNoSwitchboard(t)
16 tc.client.Login("mjl@mox.example", "testtest")
17 tc2.client.Login("mjl@mox.example", "testtest")
20 tc.transactf("no", "create Inbox") // Idem.
23 tc.transactf("ok", "create inbox/a/c")
24 tc.xuntagged(imapclient.UntaggedList{Flags: []string{`\Subscribed`}, Separator: '/', Mailbox: "Inbox/a"}, imapclient.UntaggedList{Flags: []string{`\Subscribed`}, Separator: '/', Mailbox: "Inbox/a/c"})
26 tc2.transactf("ok", "noop")
27 tc2.xuntagged(imapclient.UntaggedList{Flags: []string{`\Subscribed`}, Separator: '/', Mailbox: "Inbox/a"}, imapclient.UntaggedList{Flags: []string{`\Subscribed`}, Separator: '/', Mailbox: "Inbox/a/c"})
29 tc.transactf("no", "create inbox/a/c") // Exists.
31 tc.transactf("ok", "create inbox/a/x")
32 tc.xuntagged(imapclient.UntaggedList{Flags: []string{`\Subscribed`}, Separator: '/', Mailbox: "Inbox/a/x"})
34 tc2.transactf("ok", "noop")
35 tc2.xuntagged(imapclient.UntaggedList{Flags: []string{`\Subscribed`}, Separator: '/', Mailbox: "Inbox/a/x"})
38 tc.transactf("ok", "create mailbox/")
39 tc.xuntagged(imapclient.UntaggedList{Flags: []string{`\Subscribed`}, Separator: '/', Mailbox: "mailbox", OldName: "mailbox/"})
41 tc2.transactf("ok", "noop")
42 tc2.xuntagged(imapclient.UntaggedList{Flags: []string{`\Subscribed`}, Separator: '/', Mailbox: "mailbox"})
44 // If we are already subscribed, create should still work, and we still want to see the subscribed flag.
45 tc.transactf("ok", "subscribe newbox")
46 tc2.transactf("ok", "noop")
47 tc2.xuntagged(imapclient.UntaggedList{Flags: []string{`\Subscribed`, `\NonExistent`}, Separator: '/', Mailbox: "newbox"})
49 tc.transactf("ok", "create newbox")
50 tc.xuntagged(imapclient.UntaggedList{Flags: []string{`\Subscribed`}, Separator: '/', Mailbox: "newbox"})
51 tc2.transactf("ok", "noop")
52 tc2.xuntagged(imapclient.UntaggedList{Flags: []string{`\Subscribed`}, Separator: '/', Mailbox: "newbox"})
54 // todo: test create+delete+create of a name results in a higher uidvalidity.
56 tc.transactf("no", "create /bad/root")
57 tc.transactf("no", "create bad//root") // Cannot have internal duplicate slashes.
58 tc.transactf("no", `create ""`) // Refuse empty mailbox name.
59 // We are not allowing special characters.
60 tc.transactf("bad", `create "\n"`)
61 tc.transactf("bad", `create "\x7f"`)
62 tc.transactf("bad", `create "\x9f"`)
63 tc.transactf("bad", `create "\u2028"`)
64 tc.transactf("bad", `create "\u2029"`)
65 tc.transactf("no", `create "%%"`)
66 tc.transactf("no", `create "*"`)
67 tc.transactf("no", `create "#"`)
68 tc.transactf("no", `create "&"`)