Import/Export backend

This commit is contained in:
Michal Horejsek
2020-06-17 15:29:41 +02:00
parent 49316a935c
commit 1c10cc5065
107 changed files with 2869 additions and 743 deletions

View File

@ -1,45 +0,0 @@
Feature: IMAP copy messages
Background:
Given there is connected user "user"
And there is "user" with mailbox "Folders/mbox"
And there is "user" with mailbox "Labels/label"
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: Copy message to label
When IMAP client copies messages "2" to "Labels/label"
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has 2 messages
And mailbox "Labels/label" for "user" has messages
| from | to | subject |
| john.doe@mail.com | user@pm.me | foo |
Scenario: Copy all messages to label
When IMAP client copies messages "1:*" to "Labels/label"
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has 2 messages
And mailbox "Labels/label" for "user" has messages
| from | to | subject |
| john.doe@mail.com | user@pm.me | foo |
| jane.doe@mail.com | name@pm.me | bar |
Scenario: Copy message to folder does move
When IMAP client copies messages "2" to "Folders/mbox"
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has 1 message
And mailbox "Folders/mbox" for "user" has messages
| from | to | subject |
| john.doe@mail.com | user@pm.me | foo |
Scenario: Copy all messages to folder does move
When IMAP client copies messages "1:*" to "Folders/mbox"
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has 0 messages
And mailbox "Folders/mbox" for "user" has messages
| from | to | subject |
| john.doe@mail.com | user@pm.me | foo |
| jane.doe@mail.com | name@pm.me | bar |

View File

@ -1,70 +0,0 @@
Feature: IMAP create messages
Background:
Given there is connected user "userMoreAddresses"
And there is IMAP client logged in as "userMoreAddresses"
Scenario: Creates message to user's primary address
Given there is IMAP client selected in "INBOX"
When IMAP client creates message "foo" from "john.doe@email.com" to address "primary" of "userMoreAddresses" with body "hello world" in "INBOX"
Then IMAP response is "OK"
And mailbox "INBOX" for "userMoreAddresses" has messages
| from | to | subject | read |
| john.doe@email.com | [primary] | foo | true |
Scenario: Creates draft
When IMAP client creates message "foo" from address "primary" of "userMoreAddresses" to "john.doe@email.com" with body "hello world" in "Drafts"
Then IMAP response is "OK"
And mailbox "Drafts" for "userMoreAddresses" has messages
| from | to | subject | read |
| [primary] | john.doe@email.com | foo | true |
Scenario: Creates message sent from user's primary address
Given there is IMAP client selected in "Sent"
When IMAP client creates message "foo" from address "primary" of "userMoreAddresses" to "john.doe@email.com" with body "hello world" in "Sent"
Then IMAP response is "OK"
When the event loop of "userMoreAddresses" loops once
Then mailbox "Sent" for "userMoreAddresses" has messages
| from | to | subject | read |
| [primary] | john.doe@email.com | foo | true |
And mailbox "INBOX" for "userMoreAddresses" has no messages
Scenario: Creates message sent from user's secondary address
Given there is IMAP client selected in "Sent"
When IMAP client creates message "foo" from address "secondary" of "userMoreAddresses" to "john.doe@email.com" with body "hello world" in "Sent"
Then IMAP response is "OK"
When the event loop of "userMoreAddresses" loops once
Then mailbox "Sent" for "userMoreAddresses" has messages
| from | to | subject | read |
| [secondary] | john.doe@email.com | foo | true |
And mailbox "INBOX" for "userMoreAddresses" has no messages
Scenario: Imports an unrelated message to inbox
Given there is IMAP client selected in "INBOX"
When IMAP client creates message "foo" from "john.doe@email.com" to "john.doe2@email.com" with body "hello world" in "INBOX"
Then IMAP response is "OK"
And mailbox "INBOX" for "userMoreAddresses" has messages
| from | to | subject | read |
| john.doe@email.com | john.doe2@email.com | foo | true |
Scenario: Imports an unrelated message to sent
Given there is IMAP client selected in "Sent"
When IMAP client creates message "foo" from "notuser@gmail.com" to "alsonotuser@gmail.com" with body "hello world" in "Sent"
Then IMAP response is "OK"
When the event loop of "userMoreAddresses" loops once
Then mailbox "Sent" for "userMoreAddresses" has messages
| from | to | subject | read |
| notuser@gmail.com | alsonotuser@gmail.com | foo | true |
And mailbox "INBOX" for "userMoreAddresses" has no messages
# Importing duplicate messages when messageID cannot be found in Sent already.
#
# Previously, we discarded messages for which sender matches account address to
# avoid duplicates, but this led to discarding messages imported through mail client.
Scenario: Imports a similar (duplicate) message to sent
Given there are messages in mailbox "Sent" for "userMoreAddresses"
| from | to | subject | body |
| [primary] | chosen@one.com | Meet the Twins | Hello, Mr. Anderson |
And there is IMAP client selected in "Sent"
When IMAP client creates message "Meet the Twins" from address "primary" of "userMoreAddresses" to "chosen@one.com" with body "Hello, Mr. Anderson" in "Sent"
Then IMAP response is "OK"
And mailbox "Sent" for "userMoreAddresses" has 2 messages

View File

@ -1,45 +0,0 @@
Feature: IMAP delete messages
Background:
Given there is connected user "user"
And there is "user" with mailbox "Folders/mbox"
And there is "user" with mailbox "Labels/label"
Scenario Outline: Delete message
Given there are 10 messages in mailbox "<mailbox>" for "user"
And there is IMAP client logged in as "user"
And there is IMAP client selected in "<mailbox>"
When IMAP client deletes messages "1"
Then IMAP response is "OK"
And mailbox "<mailbox>" for "user" has 9 messages
Examples:
| mailbox |
| INBOX |
| Folders/mbox |
| Labels/label |
| Trash |
Scenario Outline: Delete all messages
Given there are 10 messages in mailbox "<mailbox>" for "user"
And there is IMAP client logged in as "user"
And there is IMAP client selected in "<mailbox>"
When IMAP client deletes messages "1:*"
Then IMAP response is "OK"
And mailbox "<mailbox>" for "user" has 0 messages
Examples:
| mailbox |
| INBOX |
| Folders/mbox |
| Labels/label |
| Trash |
Scenario: Delete message by setting flags
Given there are 1 messages in mailbox "INBOX" for "user"
And there is IMAP client logged in as "user"
And there is IMAP client selected in "INBOX"
When IMAP client marks message "1" with "\Deleted"
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has 0 messages
# Unread because we set flags without \Seen.
And message "1" in "Trash" for "user" is marked as unread

View File

@ -1,51 +0,0 @@
Feature: IMAP fetch messages
Background:
Given there is connected user "user"
And there is "user" with mailbox "Folders/mbox"
Scenario: Fetch of inbox
Given there are 10 messages in mailbox "INBOX" for "user"
And there is IMAP client logged in as "user"
And there is IMAP client selected in "INBOX"
When IMAP client fetches "1:*"
Then IMAP response is "OK"
And IMAP response has 10 messages
Scenario: Fetch first few message of inbox
Given there are 10 messages in mailbox "INBOX" for "user"
And there is IMAP client logged in as "user"
And there is IMAP client selected in "INBOX"
When IMAP client fetches "1:5"
Then IMAP response is "OK"
And IMAP response has 5 messages
Scenario: Fetch of custom mailbox
Given there are 10 messages in mailbox "Folders/mbox" for "user"
And there is IMAP client logged in as "user"
And there is IMAP client selected in "Folders/mbox"
When IMAP client fetches "1:*"
Then IMAP response is "OK"
And IMAP response has 10 messages
Scenario: Fetch of emtpy mailbox
Given there is IMAP client logged in as "user"
And there is IMAP client selected in "Folders/mbox"
When IMAP client fetches "1:*"
Then IMAP response is "OK"
And IMAP response has 0 messages
Scenario: Fetch of big mailbox
Given there are 100 messages in mailbox "Folders/mbox" for "user"
And there is IMAP client logged in as "user"
And there is IMAP client selected in "Folders/mbox"
When IMAP client fetches "1:*"
Then IMAP response is "OK"
And IMAP response has 100 messages
Scenario: Fetch returns alsways latest messages
Given there are 10 messages in mailbox "Folders/mbox" for "user"
And there is IMAP client logged in as "user"
And there is IMAP client selected in "Folders/mbox"
When IMAP client fetches by UID "11:*"
Then IMAP response is "OK"
And IMAP response has 1 message

View File

@ -1,87 +0,0 @@
Feature: IMAP import messages
Background:
Given there is connected user "user"
And there is IMAP client logged in as "user"
And there is IMAP client selected in "INBOX"
@ignore
Scenario: Import message with double charset in content type
When IMAP client imports message to "INBOX"
"""
From: Bridge Test <bridgetest@pm.test>
To: Internal Bridge <bridgetest@protonmail.com>
Subject: Message with double charset in content type
Content-Type: text/plain; charset=utf-8; charset=utf-8
Content-Disposition: inline
Hello
"""
Then IMAP response is "OK"
@ignore
Scenario: Import message with attachment name encoded by RFC 2047 without quoting
When IMAP client imports message to "INBOX"
"""
From: Bridge Test <bridgetest@pm.test>
To: Internal Bridge <bridgetest@protonmail.com>
Subject: Message with attachment name encoded by RFC 2047 without quoting
Content-type: multipart/mixed; boundary="boundary"
--boundary
Content-Type: text/plain
Hello
--boundary
Content-Type: application/pdf; name==?US-ASCII?Q?filename?=
Content-Disposition: attachment; filename==?US-ASCII?Q?filename?=
somebytes
--boundary--
"""
Then IMAP response is "OK"
Scenario: Import message as latin1 without content type
When IMAP client imports message to "INBOX" with encoding "latin1"
"""
From: Bridge Test <bridgetest@pm.test>
To: Internal Bridge <bridgetest@protonmail.com>
Subject: Message in latin1 without content type
Content-Disposition: inline
Hello íááá
"""
Then IMAP response is "OK"
Scenario: Import message as latin1 with content type
When IMAP client imports message to "INBOX" with encoding "latin1"
"""
From: Bridge Test <bridgetest@pm.test>
To: Internal Bridge <bridgetest@protonmail.com>
Subject: Message in latin1 with content type
Content-Disposition: inline
Content-Type: text/plain; charset=latin1
Hello íááá
"""
Then IMAP response is "OK"
Scenario: Import message as latin1 with wrong content type
When IMAP client imports message to "INBOX" with encoding "latin1"
"""
From: Bridge Test <bridgetest@pm.test>
To: Internal Bridge <bridgetest@protonmail.com>
Subject: Message in latin1 with wrong content type
Content-Disposition: inline
Content-Type: text/plain; charset=KOI8R
Hello íááá
"""
Then IMAP response is "OK"

View File

@ -1,42 +0,0 @@
Feature: IMAP move messages
Background:
Given there is connected user "user"
And there is "user" with mailbox "Folders/mbox"
# Messages are inserted in opposite way to keep increasing ID.
# Sequence numbers are then opposite than listed above.
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
When IMAP client moves messages "2" to "Folders/mbox"
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/mbox" for "user" has messages
| from | to | subject |
| john.doe@mail.com | user@pm.me | foo |
Scenario: Move all messages
When IMAP client moves messages "1:*" to "Folders/mbox"
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has 0 messages
And mailbox "Folders/mbox" for "user" has messages
| from | to | subject |
| john.doe@mail.com | user@pm.me | foo |
| jane.doe@mail.com | name@pm.me | bar |
Scenario: Move message from All Mail is not possible
When IMAP client moves messages "2" to "Folders/mbox"
Then IMAP response is "OK"
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/mbox" for "user" has messages
| from | to | subject |
| john.doe@mail.com | user@pm.me | foo |

View File

@ -1,82 +0,0 @@
Feature: IMAP search messages
Background:
Given there is connected user "user"
# Messages are inserted in opposite way to keep increasing ID.
# Sequence numbers are then opposite than listed above.
Given there are messages in mailbox "INBOX" for "user"
| from | to | cc | subject | read | starred | body |
| john.doe@email.com | user@pm.me | | foo | false | false | hello |
| jane.doe@email.com | user@pm.me | name@pm.me | bar | true | true | world |
| jane.doe@email.com | name@pm.me | | baz | true | false | bye |
And there is IMAP client logged in as "user"
And there is IMAP client selected in "INBOX"
Scenario: Search by Sequence numbers
When IMAP client searches for "1"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 1[^0-9]*$"
Scenario: Search by UID
When IMAP client searches for "UID 2"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 2[^0-9]*$"
Scenario: Search by Sequence numbers and UID
When IMAP client searches for "1 UID 1"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 1[^0-9]*$"
Scenario: Search by Sequence numbers and UID without match
When IMAP client searches for "1 UID 2"
Then IMAP response is "OK"
And IMAP response contains "SEARCH[^0-9]*$"
Scenario: Search by Subject
When IMAP client searches for "SUBJECT foo"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 3[^0-9]*$"
Scenario: Search by From
When IMAP client searches for "FROM jane.doe@email.com"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 1 2[^0-9]*$"
Scenario: Search by To
When IMAP client searches for "TO user@pm.me"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 2 3[^0-9]*$"
Scenario: Search by CC
When IMAP client searches for "CC name@pm.me"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 2[^0-9]*$"
Scenario: Search flagged messages
When IMAP client searches for "FLAGGED"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 2[^0-9]*$"
Scenario: Search not flagged messages
When IMAP client searches for "UNFLAGGED"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 1 3[^0-9]*$"
Scenario: Search seen messages
When IMAP client searches for "SEEN"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 1 2[^0-9]*$"
Scenario: Search unseen messages
When IMAP client searches for "UNSEEN"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 3[^0-9]*$"
Scenario: Search recent messages
When IMAP client searches for "RECENT"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 1 2 3[^0-9]*$"
Scenario: Search by more criterias
When IMAP client searches for "SUBJECT baz TO name@pm.me SEEN UNFLAGGED"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 1[^0-9]*$"

View File

@ -1,57 +0,0 @@
Feature: IMAP update messages
Background:
Given there is connected user "user"
# Messages are inserted in opposite way to keep increasing ID.
# Sequence numbers are then opposite than listed above.
And there are messages in mailbox "INBOX" for "user"
| from | to | subject | body | read | starred |
| john.doe@mail.com | user@pm.me | foo | hello | false | false |
| jane.doe@mail.com | name@pm.me | bar | world | true | true |
And there is IMAP client logged in as "user"
And there is IMAP client selected in "INBOX"
Scenario: Mark message as read
When IMAP client marks message "2" as read
Then IMAP response is "OK"
And message "1" in "INBOX" for "user" is marked as read
And message "1" in "INBOX" for "user" is marked as unstarred
Scenario: Mark message as unread
When IMAP client marks message "1" as unread
Then IMAP response is "OK"
And message "2" in "INBOX" for "user" is marked as unread
And message "2" in "INBOX" for "user" is marked as starred
Scenario: Mark message as starred
Then message "1" in "INBOX" for "user" is marked as unread
And message "1" in "INBOX" for "user" is marked as unstarred
When IMAP client marks message "2" as starred
Then IMAP response is "OK"
And message "1" in "INBOX" for "user" is marked as unread
And message "1" in "INBOX" for "user" is marked as starred
Scenario: Mark message as unstarred
When IMAP client marks message "1" as unstarred
Then IMAP response is "OK"
And message "2" in "INBOX" for "user" is marked as read
And message "2" in "INBOX" for "user" is marked as unstarred
Scenario: Mark message as read and starred
When IMAP client marks message "2" with "\Seen \Flagged"
Then IMAP response is "OK"
And message "1" in "INBOX" for "user" is marked as read
And message "1" in "INBOX" for "user" is marked as starred
Scenario: Mark message as read only
When IMAP client marks message "1" with "\Seen"
Then IMAP response is "OK"
And message "2" in "INBOX" for "user" is marked as read
# Unstarred because we set flags without \Starred.
And message "2" in "INBOX" for "user" is marked as unstarred
Scenario: Mark message as spam only
When IMAP client marks message "1" with "Junk"
Then IMAP response is "OK"
# Unread and unstarred because we set flags without \Seen and \Starred.
And message "1" in "Spam" for "user" is marked as unread
And message "1" in "Spam" for "user" is marked as unstarred