mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-18 08:06:59 +00:00
test - move like outlook - GODT-536
This commit is contained in:
31
test/features/imap/message/move_outlook.feature
Normal file
31
test/features/imap/message/move_outlook.feature
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
Feature: IMAP move messages like Outlook
|
||||||
|
Background:
|
||||||
|
Given there is connected user "user"
|
||||||
|
And there is "user" with mailbox "Folders/mbox"
|
||||||
|
And there are messages in mailbox "INBOX" for "user"
|
||||||
|
| from | to | subject | body |
|
||||||
|
| john.doe@mail.com | user@pm.me | foo | hello |
|
||||||
|
| jane.doe@mail.com | name@pm.me | bar | world |
|
||||||
|
And there is IMAP client logged in as "user"
|
||||||
|
And there is IMAP client selected in "INBOX"
|
||||||
|
|
||||||
|
Scenario: Move message from INBOX to mailbox like outlook
|
||||||
|
When IMAP client moves messages "2" to "<mailbox>" like Outlook for "user"
|
||||||
|
Then IMAP response is "OK"
|
||||||
|
And mailbox "INBOX" for "user" has messages
|
||||||
|
| from | to | subject |
|
||||||
|
| jane.doe@mail.com | name@pm.me | bar |
|
||||||
|
And mailbox "<mailbox>" for "user" has messages
|
||||||
|
| from | to | subject |
|
||||||
|
| john.doe@mail.com | user@pm.me | foo |
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| mailbox |
|
||||||
|
| Archive |
|
||||||
|
| Folders/mbox |
|
||||||
|
| Spam |
|
||||||
|
| Trash |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#Scenario: Move message from Trash/Spam to INBOX like outlook
|
||||||
@ -19,6 +19,7 @@ package tests
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/cucumber/godog"
|
"github.com/cucumber/godog"
|
||||||
"github.com/cucumber/godog/gherkin"
|
"github.com/cucumber/godog/gherkin"
|
||||||
@ -32,6 +33,7 @@ func IMAPActionsMessagesFeatureContext(s *godog.Suite) {
|
|||||||
s.Step(`^IMAP client searches for "([^"]*)"$`, imapClientSearchesFor)
|
s.Step(`^IMAP client searches for "([^"]*)"$`, imapClientSearchesFor)
|
||||||
s.Step(`^IMAP client copies messages "([^"]*)" to "([^"]*)"$`, imapClientCopiesMessagesTo)
|
s.Step(`^IMAP client copies messages "([^"]*)" to "([^"]*)"$`, imapClientCopiesMessagesTo)
|
||||||
s.Step(`^IMAP client moves messages "([^"]*)" to "([^"]*)"$`, imapClientMovesMessagesTo)
|
s.Step(`^IMAP client moves messages "([^"]*)" to "([^"]*)"$`, imapClientMovesMessagesTo)
|
||||||
|
s.Step(`^IMAP client moves messages "([^"]*)" to "([^"]*)" like outlook$`, imapClientMovesMessagesToLikeOutlook)
|
||||||
s.Step(`^IMAP client imports message to "([^"]*)"$`, imapClientCreatesMessage)
|
s.Step(`^IMAP client imports message to "([^"]*)"$`, imapClientCreatesMessage)
|
||||||
s.Step(`^IMAP client imports message to "([^"]*)" with encoding "([^"]*)"$`, imapClientCreatesMessageWithEncoding)
|
s.Step(`^IMAP client imports message to "([^"]*)" with encoding "([^"]*)"$`, imapClientCreatesMessageWithEncoding)
|
||||||
s.Step(`^IMAP client creates message "([^"]*)" from "([^"]*)" to "([^"]*)" with body "([^"]*)" in "([^"]*)"$`, imapClientCreatesMessageFromToWithBody)
|
s.Step(`^IMAP client creates message "([^"]*)" from "([^"]*)" to "([^"]*)" with body "([^"]*)" in "([^"]*)"$`, imapClientCreatesMessageFromToWithBody)
|
||||||
@ -93,6 +95,47 @@ func imapClientMovesMessagesTo(messageRange, newMailboxName string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func imapClientMovesMessagesToLikeOutlook(messageRange, newMailboxName, user string) error {
|
||||||
|
sourceClient := "imap"
|
||||||
|
fetchResp := ctx.GetIMAPClient(sourceClient).Fetch(messageRange, "body.peek[]")
|
||||||
|
fetchResp.AssertOK()
|
||||||
|
if err := ctx.GetTestingError(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
targetClient := "target"
|
||||||
|
if err := thereIsIMAPClientNamedLoggedInAs(targetClient, user); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := thereIsIMAPClientNamedSelectedIn(targetClient, newMailboxName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
movingLikeOutlook := sync.WaitGroup{}
|
||||||
|
movingLikeOutlook.Add(2)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer movingLikeOutlook.Done()
|
||||||
|
for _, msg := range fetchResp.Sections() {
|
||||||
|
res := ctx.GetIMAPClient(targetClient).Append(newMailboxName, msg)
|
||||||
|
res.AssertOK()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer movingLikeOutlook.Done()
|
||||||
|
imapClientNamedMarksMessageAsDeleted(sourceClient, messageRange)
|
||||||
|
ctx.GetIMAPLastResponse(sourceClient).AssertOK()
|
||||||
|
}()
|
||||||
|
|
||||||
|
movingLikeOutlook.Wait()
|
||||||
|
|
||||||
|
imapClientExpunge()
|
||||||
|
ctx.GetIMAPLastResponse(sourceClient).AssertOK()
|
||||||
|
|
||||||
|
return ctx.GetTestingError()
|
||||||
|
}
|
||||||
|
|
||||||
func imapClientCreatesMessage(mailboxName string, message *gherkin.DocString) error {
|
func imapClientCreatesMessage(mailboxName string, message *gherkin.DocString) error {
|
||||||
return imapClientCreatesMessageWithEncoding(mailboxName, "utf8", message)
|
return imapClientCreatesMessageWithEncoding(mailboxName, "utf8", message)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,13 +18,13 @@
|
|||||||
package mocks
|
package mocks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/emersion/go-imap"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
a "github.com/stretchr/testify/assert"
|
a "github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@ -37,7 +37,9 @@ type IMAPResponse struct {
|
|||||||
done bool
|
done bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ir *IMAPResponse) sendCommand(reqTag string, reqIndex int, command string, debug *debug, conn io.Writer, response imap.StringReader) {
|
func (ir *IMAPResponse) Sections() []string { return ir.sections }
|
||||||
|
|
||||||
|
func (ir *IMAPResponse) sendCommand(reqTag string, reqIndex int, command string, debug *debug, conn io.Writer, response *bufio.Reader) {
|
||||||
defer func() { ir.done = true }()
|
defer func() { ir.done = true }()
|
||||||
|
|
||||||
tstart := time.Now()
|
tstart := time.Now()
|
||||||
|
|||||||
Reference in New Issue
Block a user