-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(GODT-2201): IMAP Empty Value Commands
Implements the following IMAP commands which have no attached values: * Capability * Check * Close * Done * Expunge * Idle * Logout * Noop * StartTLS * Unselect
- Loading branch information
1 parent
9d577e8
commit 0e8821a
Showing
21 changed files
with
466 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
) | ||
|
||
type CapabilityCommand struct{} | ||
|
||
func (l CapabilityCommand) String() string { | ||
return fmt.Sprintf("CAPABILITY") | ||
} | ||
|
||
func (l CapabilityCommand) SanitizedString() string { | ||
return l.String() | ||
} | ||
|
||
type CapabilityCommandParser struct{} | ||
|
||
func (CapabilityCommandParser) FromParser(p *parser.Parser) (Payload, error) { | ||
return &CapabilityCommand{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import ( | ||
"bytes" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestParser_CapabilityCommand(t *testing.T) { | ||
input := toIMAPLine(`tag CAPABILITY`) | ||
s := parser.NewScanner(bytes.NewReader(input)) | ||
p := NewParser(s) | ||
|
||
expected := Command{Tag: "tag", Payload: &CapabilityCommand{}} | ||
|
||
cmd, err := p.Parse() | ||
require.NoError(t, err) | ||
require.Equal(t, expected, cmd) | ||
require.Equal(t, "capability", p.LastParsedCommand()) | ||
require.Equal(t, "tag", p.LastParsedTag()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
) | ||
|
||
type CheckCommand struct{} | ||
|
||
func (l CheckCommand) String() string { | ||
return fmt.Sprintf("CHECK") | ||
} | ||
|
||
func (l CheckCommand) SanitizedString() string { | ||
return l.String() | ||
} | ||
|
||
type CheckCommandParser struct{} | ||
|
||
func (CheckCommandParser) FromParser(p *parser.Parser) (Payload, error) { | ||
return &CheckCommand{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import ( | ||
"bytes" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestParser_CheckCommand(t *testing.T) { | ||
input := toIMAPLine(`tag CHECK`) | ||
s := parser.NewScanner(bytes.NewReader(input)) | ||
p := NewParser(s) | ||
|
||
expected := Command{Tag: "tag", Payload: &CheckCommand{}} | ||
|
||
cmd, err := p.Parse() | ||
require.NoError(t, err) | ||
require.Equal(t, expected, cmd) | ||
require.Equal(t, "check", p.LastParsedCommand()) | ||
require.Equal(t, "tag", p.LastParsedTag()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
) | ||
|
||
type CloseCommand struct{} | ||
|
||
func (l CloseCommand) String() string { | ||
return fmt.Sprintf("CLOSE") | ||
} | ||
|
||
func (l CloseCommand) SanitizedString() string { | ||
return l.String() | ||
} | ||
|
||
type CloseCommandParser struct{} | ||
|
||
func (CloseCommandParser) FromParser(p *parser.Parser) (Payload, error) { | ||
return &CloseCommand{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import ( | ||
"bytes" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestParser_CloseCommand(t *testing.T) { | ||
input := toIMAPLine(`tag CLOSE`) | ||
s := parser.NewScanner(bytes.NewReader(input)) | ||
p := NewParser(s) | ||
|
||
expected := Command{Tag: "tag", Payload: &CloseCommand{}} | ||
|
||
cmd, err := p.Parse() | ||
require.NoError(t, err) | ||
require.Equal(t, expected, cmd) | ||
require.Equal(t, "close", p.LastParsedCommand()) | ||
require.Equal(t, "tag", p.LastParsedTag()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
type DoneCommand struct{} | ||
|
||
func (l DoneCommand) String() string { | ||
return fmt.Sprintf("DONE") | ||
} | ||
|
||
func (l DoneCommand) SanitizedString() string { | ||
return l.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package command | ||
|
||
import ( | ||
"bytes" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestParser_DoneCommand(t *testing.T) { | ||
input := toIMAPLine(`DONE`) | ||
s := parser.NewScanner(bytes.NewReader(input)) | ||
p := NewParser(s) | ||
|
||
expected := Command{Tag: "", Payload: &DoneCommand{}} | ||
|
||
cmd, err := p.Parse() | ||
require.NoError(t, err) | ||
require.Equal(t, expected, cmd) | ||
require.Equal(t, "done", p.LastParsedCommand()) | ||
require.Empty(t, p.LastParsedTag()) | ||
} | ||
|
||
func TestParser_DoneCommandAfterTagIsError(t *testing.T) { | ||
input := toIMAPLine(`tag DONE`) | ||
s := parser.NewScanner(bytes.NewReader(input)) | ||
p := NewParser(s) | ||
_, err := p.Parse() | ||
require.Error(t, err) | ||
require.Equal(t, "tag", p.LastParsedTag()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
) | ||
|
||
type ExpungeCommand struct{} | ||
|
||
func (l ExpungeCommand) String() string { | ||
return fmt.Sprintf("EXPUNGE") | ||
} | ||
|
||
func (l ExpungeCommand) SanitizedString() string { | ||
return l.String() | ||
} | ||
|
||
type ExpungeCommandParser struct{} | ||
|
||
func (ExpungeCommandParser) FromParser(p *parser.Parser) (Payload, error) { | ||
return &ExpungeCommand{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import ( | ||
"bytes" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestParser_ExpungeCommand(t *testing.T) { | ||
input := toIMAPLine(`tag EXPUNGE`) | ||
s := parser.NewScanner(bytes.NewReader(input)) | ||
p := NewParser(s) | ||
|
||
expected := Command{Tag: "tag", Payload: &ExpungeCommand{}} | ||
|
||
cmd, err := p.Parse() | ||
require.NoError(t, err) | ||
require.Equal(t, expected, cmd) | ||
require.Equal(t, "expunge", p.LastParsedCommand()) | ||
require.Equal(t, "tag", p.LastParsedTag()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
) | ||
|
||
type IdleCommand struct{} | ||
|
||
func (l IdleCommand) String() string { | ||
return fmt.Sprintf("IDLE") | ||
} | ||
|
||
func (l IdleCommand) SanitizedString() string { | ||
return l.String() | ||
} | ||
|
||
type IdleCommandParser struct{} | ||
|
||
func (IdleCommandParser) FromParser(p *parser.Parser) (Payload, error) { | ||
return &IdleCommand{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import ( | ||
"bytes" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestParser_IdleCommand(t *testing.T) { | ||
input := toIMAPLine(`tag IDLE`) | ||
s := parser.NewScanner(bytes.NewReader(input)) | ||
p := NewParser(s) | ||
|
||
expected := Command{Tag: "tag", Payload: &IdleCommand{}} | ||
|
||
cmd, err := p.Parse() | ||
require.NoError(t, err) | ||
require.Equal(t, expected, cmd) | ||
require.Equal(t, "idle", p.LastParsedCommand()) | ||
require.Equal(t, "tag", p.LastParsedTag()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
) | ||
|
||
type LogoutCommand struct{} | ||
|
||
func (l LogoutCommand) String() string { | ||
return fmt.Sprintf("LOGOUT") | ||
} | ||
|
||
func (l LogoutCommand) SanitizedString() string { | ||
return l.String() | ||
} | ||
|
||
type LogoutCommandParser struct{} | ||
|
||
func (LogoutCommandParser) FromParser(p *parser.Parser) (Payload, error) { | ||
return &LogoutCommand{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import ( | ||
"bytes" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestParser_LogoutCommand(t *testing.T) { | ||
input := toIMAPLine(`tag LOGOUT`) | ||
s := parser.NewScanner(bytes.NewReader(input)) | ||
p := NewParser(s) | ||
|
||
expected := Command{Tag: "tag", Payload: &LogoutCommand{}} | ||
|
||
cmd, err := p.Parse() | ||
require.NoError(t, err) | ||
require.Equal(t, expected, cmd) | ||
require.Equal(t, "logout", p.LastParsedCommand()) | ||
require.Equal(t, "tag", p.LastParsedTag()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
) | ||
|
||
type NoopCommand struct{} | ||
|
||
func (l NoopCommand) String() string { | ||
return fmt.Sprintf("NOOP") | ||
} | ||
|
||
func (l NoopCommand) SanitizedString() string { | ||
return l.String() | ||
} | ||
|
||
type NoopCommandParser struct{} | ||
|
||
func (NoopCommandParser) FromParser(p *parser.Parser) (Payload, error) { | ||
return &NoopCommand{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import ( | ||
"bytes" | ||
"github.com/ProtonMail/gluon/imap/parser" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestParser_NoopCommand(t *testing.T) { | ||
input := toIMAPLine(`tag NOOP`) | ||
s := parser.NewScanner(bytes.NewReader(input)) | ||
p := NewParser(s) | ||
|
||
expected := Command{Tag: "tag", Payload: &NoopCommand{}} | ||
|
||
cmd, err := p.Parse() | ||
require.NoError(t, err) | ||
require.Equal(t, expected, cmd) | ||
require.Equal(t, "noop", p.LastParsedCommand()) | ||
require.Equal(t, "tag", p.LastParsedTag()) | ||
} |
Oops, something went wrong.