forked from Silverfish/proton-bridge
GODT-1817: Restore move related feature tests
Gluon updated to latest dev commit, required for feature. Checks from move_local_folder.feature are implemented in Gluon.
This commit is contained in:
@ -1,98 +0,0 @@
|
||||
Feature: IMAP move messages
|
||||
Background:
|
||||
Given there is connected user "user"
|
||||
And there is "user" with mailbox "Folders/folder"
|
||||
And there is "user" with mailbox "Labels/label"
|
||||
And there is "user" with mailbox "Labels/label2"
|
||||
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 are messages in mailbox "Sent" for "user"
|
||||
| from | to | subject | body |
|
||||
| john.doe@mail.com | user@pm.me | response | hello |
|
||||
And there are messages in mailbox "Labels/label2" for "user"
|
||||
| from | to | subject | body |
|
||||
| john.doe@mail.com | user@pm.me | baz | hello |
|
||||
And there is IMAP client logged in as "user"
|
||||
|
||||
Scenario: Move message from inbox (folder) to folder
|
||||
Given there is IMAP client selected in "INBOX"
|
||||
When IMAP client moves message seq "1" to "Folders/folder"
|
||||
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 "Folders/folder" for "user" has messages
|
||||
| from | to | subject |
|
||||
| john.doe@mail.com | user@pm.me | foo |
|
||||
And API endpoint "PUT /mail/v4/messages/label" is called
|
||||
And API endpoint "PUT /mail/v4/messages/unlabel" is not called
|
||||
|
||||
Scenario: Move all messages from inbox to folder
|
||||
Given there is IMAP client selected in "INBOX"
|
||||
When IMAP client moves message seq "1:*" to "Folders/folder"
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "INBOX" for "user" has 0 messages
|
||||
And mailbox "Folders/folder" for "user" has messages
|
||||
| from | to | subject |
|
||||
| john.doe@mail.com | user@pm.me | foo |
|
||||
| jane.doe@mail.com | name@pm.me | bar |
|
||||
And API endpoint "PUT /mail/v4/messages/label" is called
|
||||
And API endpoint "PUT /mail/v4/messages/unlabel" is not called
|
||||
|
||||
Scenario: Move message from folder to label (keeps in folder)
|
||||
Given there is IMAP client selected in "INBOX"
|
||||
When IMAP client moves message seq "1" to "Labels/label"
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "INBOX" for "user" has messages
|
||||
| from | to | subject |
|
||||
| john.doe@mail.com | user@pm.me | foo |
|
||||
| jane.doe@mail.com | name@pm.me | bar |
|
||||
And mailbox "Labels/label" for "user" has messages
|
||||
| from | to | subject |
|
||||
| john.doe@mail.com | user@pm.me | foo |
|
||||
And API endpoint "PUT /mail/v4/messages/label" is called
|
||||
And API endpoint "PUT /mail/v4/messages/unlabel" is not called
|
||||
|
||||
Scenario: Move message from label to folder
|
||||
Given there is IMAP client selected in "Labels/label2"
|
||||
When IMAP client moves message seq "1" to "Folders/folder"
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "Labels/label2" for "user" has 0 messages
|
||||
And mailbox "Folders/folder" for "user" has messages
|
||||
| from | to | subject |
|
||||
| john.doe@mail.com | user@pm.me | baz |
|
||||
And API endpoint "PUT /mail/v4/messages/label" is called
|
||||
And API endpoint "PUT /mail/v4/messages/unlabel" is called
|
||||
|
||||
Scenario: Move message from label to label
|
||||
Given there is IMAP client selected in "Labels/label2"
|
||||
When IMAP client moves message seq "1" to "Labels/label"
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "Labels/label2" for "user" has 0 messages
|
||||
And mailbox "Labels/label" for "user" has messages
|
||||
| from | to | subject |
|
||||
| john.doe@mail.com | user@pm.me | baz |
|
||||
And API endpoint "PUT /mail/v4/messages/label" is called
|
||||
And API endpoint "PUT /mail/v4/messages/unlabel" is called
|
||||
|
||||
Scenario: Move message from All Mail is not possible
|
||||
Given there is IMAP client selected in "All Mail"
|
||||
When IMAP client moves message seq "1" to "Folders/folder"
|
||||
Then IMAP response is "NO move from All Mail is not allowed"
|
||||
And mailbox "All Mail" for "user" has messages
|
||||
| from | to | subject |
|
||||
| john.doe@mail.com | user@pm.me | foo |
|
||||
| jane.doe@mail.com | name@pm.me | bar |
|
||||
And mailbox "Folders/folder" for "user" has 0 messages
|
||||
|
||||
Scenario: Move message from Inbox to Sent is not possible
|
||||
Given there is IMAP client selected in "INBOX"
|
||||
When IMAP client moves message seq "1" to "Sent"
|
||||
Then IMAP response is "move from Inbox to Sent is not allowed"
|
||||
|
||||
Scenario: Move message from Sent to Inbox is not possible
|
||||
Given there is IMAP client selected in "Sent"
|
||||
When IMAP client moves message seq "1" to "INBOX"
|
||||
Then IMAP response is "move from Sent to Inbox is not allowed"
|
||||
@ -1,80 +0,0 @@
|
||||
# IMAP clients can move message to local folder (setting \Deleted flag)
|
||||
# and then move it back (IMAP client does not remember the message,
|
||||
# so instead removing the flag it imports duplicate message).
|
||||
# Regular IMAP server would keep the message twice and later EXPUNGE would
|
||||
# not delete the message (EXPUNGE would delete the original message and
|
||||
# the new duplicate one would stay). Both Bridge and API detects duplicates;
|
||||
# therefore we need to remove \Deleted flag if IMAP client re-imports.
|
||||
Feature: IMAP move message out to and back from local folder
|
||||
Background:
|
||||
Given there is connected user "user"
|
||||
Given there is IMAP client logged in as "user"
|
||||
And there is IMAP client selected in "INBOX"
|
||||
|
||||
Scenario: Mark message as deleted and re-append again
|
||||
When IMAP client imports message to "INBOX"
|
||||
"""
|
||||
From: <john.doe@mail.com>
|
||||
To: <user@pm.me>
|
||||
Subject: foo
|
||||
Date: Mon, 02 Jan 2006 15:04:05 +0000
|
||||
Message-Id: <msgID>
|
||||
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||
|
||||
hello
|
||||
"""
|
||||
Then IMAP response is "OK"
|
||||
When IMAP client marks message seq "1" as deleted
|
||||
Then IMAP response is "OK"
|
||||
When IMAP client imports message to "INBOX"
|
||||
"""
|
||||
From: <john.doe@mail.com>
|
||||
To: <user@pm.me>
|
||||
Subject: foo
|
||||
Date: Mon, 02 Jan 2006 15:04:05 +0000
|
||||
Message-Id: <msgID>
|
||||
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||
|
||||
hello
|
||||
"""
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "INBOX" for "user" has 1 message
|
||||
And mailbox "INBOX" for "user" has messages
|
||||
| from | to | subject | deleted |
|
||||
| john.doe@mail.com | user@pm.me | foo | false |
|
||||
|
||||
# We cannot control ID generation on API.
|
||||
@ignore-live
|
||||
Scenario: Mark internal message as deleted and re-append again
|
||||
# Each message has different subject so if the ID generations on fake API
|
||||
# changes, test will fail because not even external ID mechanism will work.
|
||||
When IMAP client imports message to "INBOX"
|
||||
"""
|
||||
From: <john.doe@mail.com>
|
||||
To: <user@pm.me>
|
||||
Subject: foo
|
||||
Date: Mon, 02 Jan 2006 15:04:05 +0000
|
||||
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||
|
||||
hello
|
||||
"""
|
||||
Then IMAP response is "OK"
|
||||
When IMAP client marks message seq "1" as deleted
|
||||
Then IMAP response is "OK"
|
||||
# Fake API generates for the first message simple ID 1.
|
||||
When IMAP client imports message to "INBOX"
|
||||
"""
|
||||
From: <john.doe@mail.com>
|
||||
To: <user@pm.me>
|
||||
Subject: bar
|
||||
Date: Mon, 02 Jan 2006 15:04:05 +0000
|
||||
X-Pm-Internal-Id: 1
|
||||
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||
|
||||
hello
|
||||
"""
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "INBOX" for "user" has 1 message
|
||||
And mailbox "INBOX" for "user" has messages
|
||||
| from | to | subject | deleted |
|
||||
| john.doe@mail.com | user@pm.me | foo | false |
|
||||
@ -1,77 +0,0 @@
|
||||
Feature: IMAP move messages by append and delete (without MOVE support, e.g., Outlook)
|
||||
Background:
|
||||
Given there is connected user "user"
|
||||
And there is "user" with mailbox "Folders/mbox"
|
||||
And there is IMAP client "source" logged in as "user"
|
||||
And there is IMAP client "target" logged in as "user"
|
||||
|
||||
Scenario Outline: Move message from <srcMailbox> to <dstMailbox> by <order>
|
||||
Given there are messages in mailbox "<srcMailbox>" for "user"
|
||||
| id | from | to | subject | body |
|
||||
| 1 | sndr1@pm.me | rcvr1@pm.me | subj1 | body1 |
|
||||
| 2 | sndr2@pm.me | rcvr2@pm.me | subj2 | body2 |
|
||||
And there is IMAP client "source" selected in "<srcMailbox>"
|
||||
And there is IMAP client "target" selected in "<dstMailbox>"
|
||||
When IMAP clients "source" and "target" move message seq "2" of "user" to "<dstMailbox>" by <order>
|
||||
Then IMAP response to "source" is "OK"
|
||||
Then IMAP response to "target" is "OK"
|
||||
And mailbox "<dstMailbox>" for "user" has 1 messages
|
||||
And mailbox "<dstMailbox>" for "user" has messages
|
||||
| from | to | subject |
|
||||
| sndr2@pm.me | rcvr2@pm.me | subj2 |
|
||||
And mailbox "<srcMailbox>" for "user" has 1 messages
|
||||
And mailbox "<srcMailbox>" for "user" has messages
|
||||
| from | to | subject |
|
||||
| sndr1@pm.me | rcvr1@pm.me | subj1 |
|
||||
Examples:
|
||||
| srcMailbox | dstMailbox | order |
|
||||
| Trash | INBOX | APPEND DELETE EXPUNGE |
|
||||
| Spam | INBOX | APPEND DELETE EXPUNGE |
|
||||
| INBOX | Archive | APPEND DELETE EXPUNGE |
|
||||
| INBOX | Folders/mbox | APPEND DELETE EXPUNGE |
|
||||
| INBOX | Spam | APPEND DELETE EXPUNGE |
|
||||
| INBOX | Trash | APPEND DELETE EXPUNGE |
|
||||
| Trash | INBOX | DELETE APPEND EXPUNGE |
|
||||
| Spam | INBOX | DELETE APPEND EXPUNGE |
|
||||
| INBOX | Archive | DELETE APPEND EXPUNGE |
|
||||
| INBOX | Folders/mbox | DELETE APPEND EXPUNGE |
|
||||
| INBOX | Spam | DELETE APPEND EXPUNGE |
|
||||
| INBOX | Trash | DELETE APPEND EXPUNGE |
|
||||
| Trash | INBOX | DELETE EXPUNGE APPEND |
|
||||
| Spam | INBOX | DELETE EXPUNGE APPEND |
|
||||
| INBOX | Archive | DELETE EXPUNGE APPEND |
|
||||
| INBOX | Folders/mbox | DELETE EXPUNGE APPEND |
|
||||
| INBOX | Spam | DELETE EXPUNGE APPEND |
|
||||
| INBOX | Trash | DELETE EXPUNGE APPEND |
|
||||
|
||||
Scenario Outline: Move message from <mailbox> to All Mail by <order>
|
||||
Given there are messages in mailbox "<mailbox>" for "user"
|
||||
| id | from | to | subject | body |
|
||||
| 1 | john.doe@mail.com | user@pm.me | subj1 | body1 |
|
||||
| 2 | john.doe@mail.com | name@pm.me | subj2 | body2 |
|
||||
And there is IMAP client "source" selected in "<mailbox>"
|
||||
And there is IMAP client "target" selected in "All Mail"
|
||||
When IMAP clients "source" and "target" move message seq "2" of "user" to "All Mail" by <order>
|
||||
Then IMAP response to "source" is "OK"
|
||||
Then IMAP response to "target" is "OK"
|
||||
And mailbox "<mailbox>" for "user" has messages
|
||||
| from | to | subject |
|
||||
| john.doe@mail.com | user@pm.me | subj1 |
|
||||
And mailbox "All Mail" for "user" has messages
|
||||
| from | to | subject |
|
||||
| john.doe@mail.com | user@pm.me | subj1 |
|
||||
| john.doe@mail.com | name@pm.me | subj2 |
|
||||
Examples:
|
||||
| mailbox | order |
|
||||
| INBOX | APPEND DELETE EXPUNGE |
|
||||
| Archive | APPEND DELETE EXPUNGE |
|
||||
| Trash | APPEND DELETE EXPUNGE |
|
||||
| Spam | APPEND DELETE EXPUNGE |
|
||||
| INBOX | DELETE APPEND EXPUNGE |
|
||||
| Archive | DELETE APPEND EXPUNGE |
|
||||
| Trash | DELETE APPEND EXPUNGE |
|
||||
| Spam | DELETE APPEND EXPUNGE |
|
||||
| INBOX | DELETE EXPUNGE APPEND |
|
||||
| Archive | DELETE EXPUNGE APPEND |
|
||||
| Trash | DELETE EXPUNGE APPEND |
|
||||
| Spam | DELETE EXPUNGE APPEND |
|
||||
@ -188,6 +188,8 @@ func TestFeatures(testingT *testing.T) {
|
||||
ctx.Step(`^IMAP client "([^"]*)" selects "([^"]*)"$`, s.imapClientSelectsMailbox)
|
||||
ctx.Step(`^IMAP client "([^"]*)" copies the message with subject "([^"]*)" from "([^"]*)" to "([^"]*)"$`, s.imapClientCopiesTheMessageWithSubjectFromTo)
|
||||
ctx.Step(`^IMAP client "([^"]*)" copies all messages from "([^"]*)" to "([^"]*)"$`, s.imapClientCopiesAllMessagesFromTo)
|
||||
ctx.Step(`^IMAP client "([^"]*)" moves the message with subject "([^"]*)" from "([^"]*)" to "([^"]*)"$`, s.imapClientMovesTheMessageWithSubjectFromTo)
|
||||
ctx.Step(`^IMAP client "([^"]*)" moves all messages from "([^"]*)" to "([^"]*)"$`, s.imapClientMovesAllMessagesFromTo)
|
||||
ctx.Step(`^IMAP client "([^"]*)" sees the following messages in "([^"]*)":$`, s.imapClientSeesTheFollowingMessagesInMailbox)
|
||||
ctx.Step(`^IMAP client "([^"]*)" eventually sees the following messages in "([^"]*)":$`, s.imapClientEventuallySeesTheFollowingMessagesInMailbox)
|
||||
ctx.Step(`^IMAP client "([^"]*)" sees (\d+) messages in "([^"]*)"$`, s.imapClientSeesMessagesInMailbox)
|
||||
@ -201,7 +203,7 @@ func TestFeatures(testingT *testing.T) {
|
||||
ctx.Step(`^IMAP client "([^"]*)" appends the following message to "([^"]*)":$`, s.imapClientAppendsTheFollowingMessageToMailbox)
|
||||
ctx.Step(`^IMAP client "([^"]*)" appends the following messages to "([^"]*)":$`, s.imapClientAppendsTheFollowingMessagesToMailbox)
|
||||
ctx.Step(`^IMAP client "([^"]*)" appends "([^"]*)" to "([^"]*)"$`, s.imapClientAppendsToMailbox)
|
||||
ctx.Step(`^IMAP clients "([^"]*)" and "([^"]*)" move message seq "([^"]*)" of "([^"]*)" to "([^"]*)" by ([^"]*) ([^"]*) ([^"]*)`, s.imapClientsMoveMessageSeqOfUserFromToByOrderedOperations)
|
||||
ctx.Step(`^IMAP clients "([^"]*)" and "([^"]*)" move message with subject "([^"]*)" of "([^"]*)" to "([^"]*)" by ([^"]*) ([^"]*) ([^"]*)`, s.imapClientsMoveMessageWithSubjectUserFromToByOrderedOperations)
|
||||
ctx.Step(`^IMAP client "([^"]*)" sees header "([^"]*)" in message with subject "([^"]*)" in "([^"]*)"$`, s.imapClientSeesHeaderInMessageWithSubject)
|
||||
|
||||
// ==== SMTP ====
|
||||
|
||||
85
tests/features/imap/message/move.feature
Normal file
85
tests/features/imap/message/move.feature
Normal file
@ -0,0 +1,85 @@
|
||||
Feature: IMAP move messages
|
||||
Background:
|
||||
Given there exists an account with username "[user:user]" and password "password"
|
||||
And the account "[user:user]" has the following custom mailboxes:
|
||||
| name | type |
|
||||
| mbox | folder |
|
||||
| label | label |
|
||||
| label2 | label |
|
||||
And the address "[user:user]@[domain]" of account "[user:user]" has the following messages in "Inbox":
|
||||
| from | to | subject | unread |
|
||||
| john.doe@mail.com | [user:user]@[domain] | foo | false |
|
||||
| jane.doe@mail.com | name@[domain] | bar | true |
|
||||
And the address "[user:user]@[domain]" of account "[user:user]" has the following messages in "Labels/label2":
|
||||
| from | to | subject | unread |
|
||||
| john.doe@mail.com | [user:user]@[domain] | baz | false |
|
||||
And the address "[user:user]@[domain]" of account "[user:user]" has the following messages in "Sent":
|
||||
| from | to | subject | unread |
|
||||
| john.doe@mail.com | [user:user]@[domain] | bax | false |
|
||||
And bridge starts
|
||||
And the user logs in with username "[user:user]" and password "password"
|
||||
And user "[user:user]" finishes syncing
|
||||
And user "[user:user]" connects and authenticates IMAP client "1"
|
||||
|
||||
Scenario: Move message from folder to label (keeps in folder)
|
||||
When IMAP client "1" moves the message with subject "foo" from "INBOX" to "Labels/label"
|
||||
And it succeeds
|
||||
And IMAP client "1" sees the following messages in "INBOX":
|
||||
| from | to | subject | unread |
|
||||
| john.doe@mail.com | [user:user]@[domain] | foo | false |
|
||||
| jane.doe@mail.com | name@[domain] | bar | true |
|
||||
And IMAP client "1" sees the following messages in "Labels/label":
|
||||
| from | to | subject | unread |
|
||||
| john.doe@mail.com | [user:user]@[domain] | foo | false |
|
||||
|
||||
# This test covers a limitation of Gluon where we are not able to ensure the messages moved to a label via append
|
||||
# expunge are preserved in the original folder.
|
||||
Scenario: Move message from folder to label with append expunge does not keep message in origin folder
|
||||
When user "[user:user]" connects and authenticates IMAP client "source"
|
||||
And user "[user:user]" connects and authenticates IMAP client "target"
|
||||
And IMAP client "source" selects "INBOX"
|
||||
And IMAP client "target" selects "Labels/label"
|
||||
And IMAP clients "source" and "target" move message with subject "foo" of "[user:user]" to "Labels/label" by APPEND DELETE EXPUNGE
|
||||
And it succeeds
|
||||
Then IMAP client "source" sees the following messages in "INBOX":
|
||||
| from | to | subject | unread |
|
||||
| jane.doe@mail.com | name@[domain] | bar | true |
|
||||
And IMAP client "target" sees the following messages in "Labels/label":
|
||||
| from | to | subject | unread |
|
||||
| john.doe@mail.com | [user:user]@[domain] | foo | false |
|
||||
|
||||
Scenario: Move message from label to folder
|
||||
When IMAP client "1" moves the message with subject "baz" from "Labels/label2" to "Folders/mbox"
|
||||
And it succeeds
|
||||
And IMAP client "1" sees the following messages in "Folders/mbox":
|
||||
| from | to | subject | unread |
|
||||
| john.doe@mail.com | [user:user]@[domain] | baz | false |
|
||||
And IMAP client "1" sees 0 messages in "Labels/label2"
|
||||
|
||||
Scenario: Move message from label to label
|
||||
When IMAP client "1" moves the message with subject "baz" from "Labels/label2" to "Labels/label"
|
||||
And it succeeds
|
||||
And IMAP client "1" sees the following messages in "Labels/label":
|
||||
| from | to | subject | unread |
|
||||
| john.doe@mail.com | [user:user]@[domain] | baz | false |
|
||||
And IMAP client "1" sees 0 messages in "Labels/label2"
|
||||
|
||||
Scenario: Move message from All Mail is not possible
|
||||
When IMAP client "1" moves the message with subject "baz" from "All Mail" to "Folders/folder"
|
||||
Then it fails
|
||||
And IMAP client "1" sees the following messages in "All Mail":
|
||||
| from | to | subject | unread |
|
||||
| john.doe@mail.com | [user:user]@[domain] | foo | false |
|
||||
| jane.doe@mail.com | name@[domain] | bar | true |
|
||||
| john.doe@mail.com | [user:user]@[domain] | baz | false |
|
||||
| john.doe@mail.com | [user:user]@[domain] | bax | false |
|
||||
|
||||
Scenario: Move message from Inbox to Sent is not possible
|
||||
Given test skips reporter checks
|
||||
When IMAP client "1" moves the message with subject "bar" from "Inbox" to "Sent"
|
||||
Then it fails
|
||||
|
||||
Scenario: Move message from Sent to Inbox is not possible
|
||||
Given test skips reporter checks
|
||||
When IMAP client "1" moves the message with subject "bax" from "Sent" to "Inbox"
|
||||
Then it fails
|
||||
@ -33,13 +33,13 @@ Feature: IMAP move messages by append and delete (without MOVE support, e.g., Ou
|
||||
Then it succeeds
|
||||
And IMAP client "source" selects "<srcMailbox>"
|
||||
And IMAP client "target" selects "<dstMailbox>"
|
||||
When IMAP clients "source" and "target" move message seq "2" of "[user:user]" to "<dstMailbox>" by <order>
|
||||
When IMAP clients "source" and "target" move message with subject "subj2" of "[user:user]" to "<dstMailbox>" by <order>
|
||||
And IMAP client "source" sees 1 messages in "<srcMailbox>"
|
||||
And IMAP client "source" sees the following messages in "<srcMailbox>":
|
||||
| from | to | subject |
|
||||
| sndr1@[domain] | rcvr1@[domain] | subj1 |
|
||||
And IMAP client "target" sees 1 messages in "<dstMailbox>"
|
||||
And IMAP client "target" sees the following messages in "<dstMailbox>":
|
||||
And IMAP client "target" eventually sees 1 messages in "<dstMailbox>"
|
||||
And IMAP client "target" eventually sees the following messages in "<dstMailbox>":
|
||||
| from | to | subject |
|
||||
| sndr2@[domain] | rcvr2@[domain] | subj2 |
|
||||
Examples:
|
||||
|
||||
@ -23,7 +23,6 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -288,6 +287,31 @@ func (s *scenario) imapClientSeesTheFollowingMessagesInMailbox(clientID, mailbox
|
||||
return matchMessages(haveMessages, wantMessages)
|
||||
}
|
||||
|
||||
func (s *scenario) imapClientMovesTheMessageWithSubjectFromTo(clientID, subject, from, to string) error {
|
||||
_, client := s.t.getIMAPClient(clientID)
|
||||
|
||||
uid, err := clientGetUIDBySubject(client, from, subject)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := clientMove(client, from, to, uid); err != nil {
|
||||
s.t.pushError(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *scenario) imapClientMovesAllMessagesFromTo(clientID, from, to string) error {
|
||||
_, client := s.t.getIMAPClient(clientID)
|
||||
|
||||
if err := clientMove(client, from, to); err != nil {
|
||||
s.t.pushError(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *scenario) imapClientEventuallySeesTheFollowingMessagesInMailbox(clientID, mailbox string, table *godog.Table) error {
|
||||
return eventually(func() error {
|
||||
err := s.imapClientSeesTheFollowingMessagesInMailbox(clientID, mailbox, table)
|
||||
@ -433,16 +457,11 @@ func (s *scenario) imapClientAppendsToMailbox(clientID string, file, mailbox str
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *scenario) imapClientsMoveMessageSeqOfUserFromToByOrderedOperations(sourceIMAPClient, targetIMAPClient, messageSeq, bddUserID, targetMailboxName, op1, op2, op3 string) error {
|
||||
func (s *scenario) imapClientsMoveMessageWithSubjectUserFromToByOrderedOperations(sourceIMAPClient, targetIMAPClient, messageSubject, bddUserID, targetMailboxName, op1, op2, op3 string) error {
|
||||
// call NOOP to prevent unilateral updates in following FETCH
|
||||
_, sourceClient := s.t.getIMAPClient(sourceIMAPClient)
|
||||
_, targetClient := s.t.getIMAPClient(targetIMAPClient)
|
||||
|
||||
sequenceID, err := strconv.Atoi(messageSeq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := sourceClient.Noop(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -451,8 +470,13 @@ func (s *scenario) imapClientsMoveMessageSeqOfUserFromToByOrderedOperations(sour
|
||||
return err
|
||||
}
|
||||
|
||||
uid, err := clientGetUIDBySubject(sourceClient, sourceClient.Mailbox().Name, messageSubject)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// get the original message
|
||||
messages, err := clientFetchSequence(sourceClient, messageSeq)
|
||||
messages, err := clientFetchSequence(sourceClient, fmt.Sprintf("%v", uid), true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -486,7 +510,7 @@ func (s *scenario) imapClientsMoveMessageSeqOfUserFromToByOrderedOperations(sour
|
||||
|
||||
targetErr = targetClient.Append(targetMailboxName, flags, time.Now(), bytes.NewReader(literal))
|
||||
case "DELETE":
|
||||
if _, err := clientStore(sourceClient, sequenceID, sequenceID, false, imap.FormatFlagsOp(imap.AddFlags, true), imap.DeletedFlag); err != nil {
|
||||
if _, err := clientStore(sourceClient, int(uid), int(uid), true, imap.FormatFlagsOp(imap.AddFlags, true), imap.DeletedFlag); err != nil {
|
||||
storeErr = err
|
||||
}
|
||||
case "EXPUNGE":
|
||||
@ -606,7 +630,7 @@ func clientFetch(client *client.Client, mailbox string) ([]*imap.Message, error)
|
||||
return iterator.Collect(iterator.Chan(resCh)), nil
|
||||
}
|
||||
|
||||
func clientFetchSequence(client *client.Client, sequenceSet string) ([]*imap.Message, error) {
|
||||
func clientFetchSequence(client *client.Client, sequenceSet string, isUID bool) ([]*imap.Message, error) {
|
||||
seqSet, err := imap.ParseSeqSet(sequenceSet)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -615,12 +639,22 @@ func clientFetchSequence(client *client.Client, sequenceSet string) ([]*imap.Mes
|
||||
resCh := make(chan *imap.Message)
|
||||
|
||||
go func() {
|
||||
if err := client.Fetch(
|
||||
seqSet,
|
||||
[]imap.FetchItem{imap.FetchFlags, imap.FetchEnvelope, imap.FetchUid, "BODY.PEEK[]"},
|
||||
resCh,
|
||||
); err != nil {
|
||||
panic(err)
|
||||
if isUID {
|
||||
if err := client.UidFetch(
|
||||
seqSet,
|
||||
[]imap.FetchItem{imap.FetchFlags, imap.FetchEnvelope, imap.FetchUid, "BODY.PEEK[]"},
|
||||
resCh,
|
||||
); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
if err := client.Fetch(
|
||||
seqSet,
|
||||
[]imap.FetchItem{imap.FetchFlags, imap.FetchEnvelope, imap.FetchUid, "BODY.PEEK[]"},
|
||||
resCh,
|
||||
); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
@ -652,6 +686,31 @@ func clientCopy(client *client.Client, from, to string, uid ...uint32) error {
|
||||
return client.UidCopy(seqset, to)
|
||||
}
|
||||
|
||||
func clientMove(client *client.Client, from, to string, uid ...uint32) error {
|
||||
status, err := client.Select(from, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if status.Messages == 0 {
|
||||
return fmt.Errorf("expected %v to have messages, but it doesn't", from)
|
||||
}
|
||||
|
||||
var seqset *imap.SeqSet
|
||||
|
||||
if len(uid) == 0 {
|
||||
seqset = &imap.SeqSet{Set: []imap.Seq{{Start: 1, Stop: status.Messages}}}
|
||||
} else {
|
||||
seqset = &imap.SeqSet{}
|
||||
|
||||
for _, uid := range uid {
|
||||
seqset.AddNum(uid)
|
||||
}
|
||||
}
|
||||
|
||||
return client.UidMove(seqset, to)
|
||||
}
|
||||
|
||||
func clientStore(client *client.Client, from, to int, isUID bool, item imap.StoreItem, flags ...string) ([]*imap.Message, error) { //nolint:unparam
|
||||
resCh := make(chan *imap.Message)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user