mox/imapserver/subscribe_test.go
Mechiel Lukkien 507ca73b96
imapserver: implement UIDONLY extension, RFC 9586
Once clients enable this extension, commands can no longer refer to "message
sequence numbers" (MSNs), but can only refer to messages with UIDs. This means
both sides no longer have to carefully keep their sequence numbers in sync
(error-prone), and don't have to keep track of a mapping of sequence numbers to
UIDs (saves resources).

With UIDONLY enabled, all FETCH responses are replaced with UIDFETCH response.
2025-04-11 11:45:49 +02:00

33 lines
996 B
Go

package imapserver
import (
"testing"
"github.com/mjl-/mox/imapclient"
)
func TestSubscribe(t *testing.T) {
tc := start(t, false)
defer tc.close()
tc2 := startNoSwitchboard(t, false)
defer tc2.closeNoWait()
tc.login("mjl@mox.example", password0)
tc2.login("mjl@mox.example", password0)
tc.transactf("bad", "subscribe") // Missing param.
tc.transactf("bad", "subscribe ") // Missing param.
tc.transactf("bad", "subscribe fine ") // Leftover data.
tc.transactf("ok", "subscribe a/b")
tc2.transactf("ok", "noop")
tc2.xuntagged(imapclient.UntaggedList{Flags: []string{`\Subscribed`, `\NonExistent`}, Separator: '/', Mailbox: "a/b"})
tc.transactf("ok", "subscribe a/b") // Already subscribed, which is fine.
tc2.transactf("ok", "noop")
tc2.xuntagged() // But no new changes.
tc.transactf("ok", `list (subscribed) "" "a*" return (subscribed)`)
tc.xuntagged(imapclient.UntaggedList{Flags: []string{`\Subscribed`, `\NonExistent`}, Separator: '/', Mailbox: "a/b"})
}