From 3e8cc8bcee8b6ac29c365822cc19bad2d2f927ea Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Thu, 13 Apr 2023 14:47:58 +0200 Subject: [PATCH] fix(GODT-2550): Announce IMAP ID Capability Feature was built in but never announced to the clients. --- imap/capabilities.go | 3 ++- internal/session/handle_capability.go | 2 +- internal/session/session.go | 2 +- tests/capability_test.go | 6 +++--- tests/login_test.go | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/imap/capabilities.go b/imap/capabilities.go index 443ef808..6d609c39 100644 --- a/imap/capabilities.go +++ b/imap/capabilities.go @@ -9,11 +9,12 @@ const ( UNSELECT Capability = `UNSELECT` UIDPLUS Capability = `UIDPLUS` MOVE Capability = `MOVE` + ID Capability = `ID` ) func IsCapabilityAvailableBeforeAuth(c Capability) bool { switch c { - case IMAP4rev1, StartTLS, IDLE: + case IMAP4rev1, StartTLS, IDLE, ID: return true case UNSELECT, UIDPLUS, MOVE: return false diff --git a/internal/session/handle_capability.go b/internal/session/handle_capability.go index e852ca5d..8c576941 100644 --- a/internal/session/handle_capability.go +++ b/internal/session/handle_capability.go @@ -16,7 +16,7 @@ func (s *Session) getCaps() []imap.Capability { return s.caps } - caps := []imap.Capability{} + var caps []imap.Capability for _, c := range s.caps { if imap.IsCapabilityAvailableBeforeAuth(c) { caps = append(caps, c) diff --git a/internal/session/session.go b/internal/session/session.go index d29297b1..4a4f746a 100644 --- a/internal/session/session.go +++ b/internal/session/session.go @@ -110,7 +110,7 @@ func New( inputCollector: inputCollector, scanner: scanner, backend: backend, - caps: []imap.Capability{imap.IMAP4rev1, imap.IDLE, imap.UNSELECT, imap.UIDPLUS, imap.MOVE}, + caps: []imap.Capability{imap.IMAP4rev1, imap.IDLE, imap.UNSELECT, imap.UIDPLUS, imap.MOVE, imap.ID}, sessionID: sessionID, eventCh: eventCh, idleBulkTime: idleBulkTime, diff --git a/tests/capability_test.go b/tests/capability_test.go index 1db09992..87e64b98 100644 --- a/tests/capability_test.go +++ b/tests/capability_test.go @@ -7,14 +7,14 @@ import ( func TestCapability(t *testing.T) { runOneToOneTest(t, defaultServerOptions(t), func(c *testConnection, _ *testSession) { c.C("A001 Capability") - c.S(`* CAPABILITY IDLE IMAP4rev1 STARTTLS`) + c.S(`* CAPABILITY ID IDLE IMAP4rev1 STARTTLS`) c.S("A001 OK CAPABILITY") c.C(`A002 login "user" "pass"`) - c.S(`A002 OK [CAPABILITY IDLE IMAP4rev1 MOVE STARTTLS UIDPLUS UNSELECT] Logged in`) + c.S(`A002 OK [CAPABILITY ID IDLE IMAP4rev1 MOVE STARTTLS UIDPLUS UNSELECT] Logged in`) c.C("A003 Capability") - c.S(`* CAPABILITY IDLE IMAP4rev1 MOVE STARTTLS UIDPLUS UNSELECT`) + c.S(`* CAPABILITY ID IDLE IMAP4rev1 MOVE STARTTLS UIDPLUS UNSELECT`) c.S("A003 OK CAPABILITY") }) } diff --git a/tests/login_test.go b/tests/login_test.go index a1a2b7c6..df324513 100644 --- a/tests/login_test.go +++ b/tests/login_test.go @@ -90,7 +90,7 @@ func TestLoginLiteralFailure(t *testing.T) { func TestLoginCapabilities(t *testing.T) { runOneToOneTest(t, defaultServerOptions(t), func(c *testConnection, _ *testSession) { c.C("A001 login user pass") - c.S(`A001 OK [CAPABILITY IDLE IMAP4rev1 MOVE STARTTLS UIDPLUS UNSELECT] Logged in`) + c.S(`A001 OK [CAPABILITY ID IDLE IMAP4rev1 MOVE STARTTLS UIDPLUS UNSELECT] Logged in`) }) }