diff --git a/imap/attributes.go b/imap/attributes.go index d4f66ef7..3872a401 100644 --- a/imap/attributes.go +++ b/imap/attributes.go @@ -5,4 +5,13 @@ const ( AttrNoInferiors = `\Noinferiors` AttrMarked = `\Marked` AttrUnmarked = `\Unmarked` + + // Special Use attributes as defined in RFC-6154. + AttrAll = `\All` + AttrArchive = `\Archive` + AttrDrafts = `\Drafts` + AttrFlagged = `\Flagged` + AttrJunk = `\Junk` + AttrSent = `\Sent` + AttrTrash = `\Trash` ) diff --git a/tests/list_test.go b/tests/list_test.go index 41eb9f88..adf23555 100644 --- a/tests/list_test.go +++ b/tests/list_test.go @@ -234,3 +234,29 @@ func TestListWildcards(t *testing.T) { c.OK(`tag`) }) } + +func TestListSpecialUseAttributes(t *testing.T) { + runOneToOneTestWithAuth(t, defaultServerOptions(t, withDelimiter(".")), func(c *testConnection, s *testSession) { + s.mailboxCreated("user", []string{"INBOX"}) + s.mailboxCreatedWithAttributes("user", []string{"Koncepty"}, imap.NewFlagSet(imap.AttrDrafts)) + s.mailboxCreatedWithAttributes("user", []string{"Odeslane"}, imap.NewFlagSet(imap.AttrSent)) + s.mailboxCreatedWithAttributes("user", []string{"S hvezdickou"}, imap.NewFlagSet(imap.AttrFlagged)) + s.mailboxCreatedWithAttributes("user", []string{"Archiv"}, imap.NewFlagSet(imap.AttrArchive)) + s.mailboxCreatedWithAttributes("user", []string{"Spam"}, imap.NewFlagSet(imap.AttrJunk)) + s.mailboxCreatedWithAttributes("user", []string{"Kos"}, imap.NewFlagSet(imap.AttrTrash)) + s.mailboxCreatedWithAttributes("user", []string{"Vsechny zpravy"}, imap.NewFlagSet(imap.AttrAll)) + + c.C(`a list "" "*"`) + c.S( + `* LIST (\Unmarked) "." "INBOX"`, + `* LIST (\Drafts \Unmarked) "." "Koncepty"`, + `* LIST (\Sent \Unmarked) "." "Odeslane"`, + `* LIST (\Flagged \Unmarked) "." "S hvezdickou"`, + `* LIST (\Archive \Unmarked) "." "Archiv"`, + `* LIST (\Junk \Unmarked) "." "Spam"`, + `* LIST (\Trash \Unmarked) "." "Kos"`, + `* LIST (\All \Unmarked) "." "Vsechny zpravy"`, + ) + c.OK(`a`) + }) +} diff --git a/tests/session_test.go b/tests/session_test.go index 40f21ed5..d298be49 100644 --- a/tests/session_test.go +++ b/tests/session_test.go @@ -115,6 +115,10 @@ func (s *testSession) setLabelPrefix(user, prefix string) { } func (s *testSession) mailboxCreated(user string, name []string, withData ...string) imap.LabelID { + return s.mailboxCreatedWithAttributes(user, name, defaultAttributes, withData...) +} + +func (s *testSession) mailboxCreatedWithAttributes(user string, name []string, attributes imap.FlagSet, withData ...string) imap.LabelID { mboxID := imap.LabelID(utils.NewRandomLabelID()) require.NoError(s.tb, s.conns[s.userIDs[user]].MailboxCreated(imap.Mailbox{ @@ -122,7 +126,7 @@ func (s *testSession) mailboxCreated(user string, name []string, withData ...str Name: name, Flags: defaultFlags, PermanentFlags: defaultPermanentFlags, - Attributes: defaultAttributes, + Attributes: attributes, })) for _, data := range withData {