GODT-1779: Remove go-imap

This commit is contained in:
James Houlahan
2022-08-26 17:00:21 +02:00
parent 3b0bc1ca15
commit 39433fe707
593 changed files with 12725 additions and 91626 deletions

View File

@ -0,0 +1,92 @@
Feature: IMAP auth
Scenario: Authenticates successfully
Given there is connected user "user"
When IMAP client authenticates "user"
Then IMAP response is "OK"
Scenario: Authenticates with bad password
Given there is connected user "user"
When IMAP client authenticates "user" with bad password
Then IMAP response is "IMAP error: NO backend/credentials: incorrect password"
@ignore-live-auth
Scenario: Authenticates with disconnected user
Given there is disconnected user "user"
When IMAP client authenticates "user"
Then IMAP response is "IMAP error: NO account is logged out, use the app to login again"
@ignore-live-auth
Scenario: Authenticates with connected user that was loaded without internet
Given there is user "user" which just logged in
And there is no internet connection
When bridge starts
And the internet connection is restored
And the event loop of "user" loops once
And IMAP client authenticates "user"
# Problems during IMAP auth could lead to the user being disconnected.
# This could take a few milliseconds because it happens async in separate goroutines.
# We wait enough time for that to happen, then check that it didn't happen (user should remain connected).
And 2 seconds pass
Then "user" is connected
@ignore-live-auth
Scenario: Authenticates with freshly logged-out user
Given there is user "user" which just logged in
When "user" logs out
And IMAP client authenticates "user"
Then IMAP response is "IMAP error: NO account is logged out, use the app to login again"
@ignore-live-auth
Scenario: Authenticates user which was re-logged in
Given there is user "user" which just logged in
When "user" logs out
And IMAP client authenticates "user"
Then IMAP response is "IMAP error: NO account is logged out, use the app to login again"
When "user" logs in
And IMAP client authenticates "user"
Then IMAP response is "OK"
When IMAP client selects "INBOX"
Then IMAP response is "OK"
Scenario: Authenticates with no user
When IMAP client authenticates with username "user@pm.me" and password "bridgepassword"
Then IMAP response is "IMAP error: NO user user@pm.me not found"
Scenario: Authenticates with capital letter
Given there is connected user "userAddressWithCapitalLetter"
When IMAP client authenticates "userAddressWithCapitalLetter"
Then IMAP response is "OK"
Scenario: Authenticates with more addresses - primary one
Given there is connected user "userMoreAddresses"
When IMAP client authenticates "userMoreAddresses" with address "primary"
Then IMAP response is "OK"
Scenario: Authenticates with more addresses - secondary one
Given there is connected user "userMoreAddresses"
When IMAP client authenticates "userMoreAddresses" with address "secondary"
Then IMAP response is "OK"
Scenario: Authenticates with more addresses - disabled address
Given there is connected user "userMoreAddresses"
When IMAP client authenticates "userMoreAddresses" with address "disabled"
Then IMAP response is "IMAP error: NO user .* not found"
@ignore-live
Scenario: Authenticates with secondary address of account with disabled primary address
Given there is connected user "userDisabledPrimaryAddress"
When IMAP client authenticates "userDisabledPrimaryAddress" with address "secondary"
Then IMAP response is "OK"
Scenario: Authenticates two users
Given there is connected user "user"
And there is connected user "userMoreAddresses"
When IMAP client "imap1" authenticates "user"
Then IMAP response to "imap1" is "OK"
When IMAP client "imap2" authenticates "userMoreAddresses" with address "primary"
Then IMAP response to "imap2" is "OK"
Scenario: Logs out user
Given there is connected user "user"
When IMAP client logs out
Then IMAP response is "OK"

View File

@ -0,0 +1,63 @@
Feature: IMAP IDLE
Background:
Given there is connected user "user"
And there are 10 messages in mailbox "INBOX" for "user"
# Those tests are ignored as currently our IMAP implementation is not responding with updates to all open connections.
@ignore
Scenario Outline: Mark as read
Given there is IMAP client "active" logged in as "user"
And there is IMAP client "active" selected in "INBOX"
And there is IMAP client "idling" logged in as "user"
And there is IMAP client "idling" selected in "INBOX"
When IMAP client "idling" starts IDLE-ing
And IMAP client "active" marks message seq "<seq>" as read
Then IMAP client "idling" receives update marking message seq "<seq>" as read within <seconds> seconds
Then message "<seq>" in "INBOX" for "user" is marked as read
Examples:
| seq | seconds |
| 1 | 2 |
| 1:5 | 2 |
| 1:10 | 5 |
@ignore
Scenario Outline: Mark as unread
Given there is IMAP client "active" logged in as "user"
And there is IMAP client "active" selected in "INBOX"
And there is IMAP client "idling" logged in as "user"
And there is IMAP client "idling" selected in "INBOX"
When IMAP client "idling" starts IDLE-ing
And IMAP client "active" marks message seq "<seq>" as unread
Then IMAP client "idling" receives update marking message seq "<seq>" as unread within <seconds> seconds
And message "<seq>" in "INBOX" for "user" is marked as unread
Examples:
| seq | seconds |
| 1 | 2 |
| 1:5 | 2 |
| 1:10 | 5 |
@ignore
Scenario Outline: Three IDLEing
Given there is IMAP client "active" logged in as "user"
And there is IMAP client "active" selected in "INBOX"
And there is IMAP client "idling1" logged in as "user"
And there is IMAP client "idling1" selected in "INBOX"
And there is IMAP client "idling2" logged in as "user"
And there is IMAP client "idling2" selected in "INBOX"
And there is IMAP client "idling3" logged in as "user"
And there is IMAP client "idling3" selected in "INBOX"
When IMAP client "idling1" starts IDLE-ing
And IMAP client "idling2" starts IDLE-ing
And IMAP client "idling3" starts IDLE-ing
And IMAP client "active" marks message seq "<seq>" as read
Then IMAP client "idling1" receives update marking message seq "<seq>" as read within <seconds> seconds
Then IMAP client "idling2" receives update marking message seq "<seq>" as read within <seconds> seconds
Then IMAP client "idling3" receives update marking message seq "<seq>" as read within <seconds> seconds
Examples:
| seq | seconds |
| 1 | 2 |
| 1:5 | 2 |
| 1:10 | 5 |

View File

@ -0,0 +1,27 @@
Feature: IMAP IDLE with two users
Scenario: IDLE statements are not leaked to other account
Given there is connected user "user"
And there are 10 messages in mailbox "INBOX" for "user"
And there is connected user "userMoreAddresses"
And there is IMAP client "active" logged in as "user"
And there is IMAP client "active" selected in "INBOX"
And there is IMAP client "idling" logged in as "userMoreAddresses"
And there is IMAP client "idling" selected in "INBOX"
When IMAP client "idling" starts IDLE-ing
And IMAP client "active" marks message seq "1" as read
Then IMAP client "idling" does not receive update for message seq "1" within 5 seconds
Scenario: IDLE statements are not leaked to other alias
Given there is connected user "userMoreAddresses"
And there is "userMoreAddresses" in "combined" address mode
And there are messages in mailbox "INBOX" for "userMoreAddresses"
| from | to | subject |
| john.doe@mail.com | [primary] | foo |
| jane.doe@mail.com | [secondary] | bar |
And there is IMAP client "active" logged in as "userMoreAddresses" with address "primary"
And there is IMAP client "active" selected in "INBOX"
And there is IMAP client "idling" logged in as "userMoreAddresses" with address "secondary"
And there is IMAP client "idling" selected in "INBOX"
When IMAP client "idling" starts IDLE-ing
And IMAP client "active" marks message seq "1" as read
Then IMAP client "idling" does not receive update for message seq "1" within 5 seconds

View File

@ -0,0 +1,50 @@
Feature: IMAP create mailbox
Background:
Given there is connected user "user"
And there is IMAP client logged in as "user"
And "user" does not have mailbox "Folders/mbox"
And "user" does not have mailbox "Labels/mbox"
Scenario: Create folder
When IMAP client creates mailbox "Folders/mbox"
Then IMAP response is "OK"
And "user" has mailbox "Folders/mbox"
And "user" does not have mailbox "Labels/mbox"
Scenario: Create label
When IMAP client creates mailbox "Labels/mbox"
Then IMAP response is "OK"
And "user" does not have mailbox "Folders/mbox"
And "user" has mailbox "Labels/mbox"
Scenario: Creating label with existing name is not possible
Given there is "user" with mailbox "Folders/mbox"
When IMAP client creates mailbox "Labels/mbox"
Then IMAP response is "IMAP error: NO A label or folder with this name already exists"
And "user" has mailbox "Folders/mbox"
And "user" does not have mailbox "Labels/mbox"
Scenario: Creating folder with existing name is not possible
Given there is "user" with mailbox "Labels/mbox"
When IMAP client creates mailbox "Folders/mbox"
Then IMAP response is "IMAP error: NO A label or folder with this name already exists"
And "user" has mailbox "Labels/mbox"
And "user" does not have mailbox "Folders/mbox"
Scenario: Creating system mailbox is not possible
When IMAP client creates mailbox "INBOX"
Then IMAP response is "IMAP error: NO mailbox INBOX already exists"
When IMAP client creates mailbox "Folders/INBOX"
Then IMAP response is "IMAP error: NO Invalid name"
# API allows you to create custom folder with naem `All Mail`
#When IMAP client creates mailbox "Folders/All mail"
#Then IMAP response is "IMAP error: NO mailbox All Mail already exists"
Scenario: Creating mailbox without prefix is not possible
When IMAP client creates mailbox "mbox"
Then IMAP response is "OK"
And "user" does not have mailbox "mbox"
When All mail mailbox is hidden
And IMAP client creates mailbox "All mail"
Then IMAP response is "OK"
And "user" does not have mailbox "All mail"

View File

@ -0,0 +1,29 @@
Feature: IMAP delete mailbox
Background:
Given there is connected user "user"
Scenario: Delete folder
Given there is "user" with mailbox "Folders/mbox"
And there is IMAP client logged in as "user"
When IMAP client deletes mailbox "Folders/mbox"
Then IMAP response is "OK"
And "user" does not have mailbox "Folders/mbox"
Scenario: Delete label
Given there is "user" with mailbox "Labels/mbox"
And there is IMAP client logged in as "user"
When IMAP client deletes mailbox "Labels/mbox"
Then IMAP response is "OK"
And "user" does not have mailbox "Labels/mbox"
Scenario: Empty Trash by deleting it
Given there are 10 messages in mailbox "Trash" for "user"
And there is IMAP client logged in as "user"
When IMAP client deletes mailbox "Trash"
Then IMAP response is "OK"
And mailbox "Trash" for "user" has 0 messages
Scenario: Deleting system mailbox is not possible
Given there is IMAP client logged in as "user"
When IMAP client deletes mailbox "INBOX"
Then IMAP response is "IMAP error: NO cannot empty mailbox 0"

View File

@ -0,0 +1,15 @@
Feature: IMAP get mailbox info
Background:
Given there is connected user "user"
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"
Scenario: Mailbox info contains mailbox name
When IMAP client gets info of "INBOX"
Then IMAP response contains "2 EXISTS"
And IMAP response contains "UNSEEN 1"
And IMAP response contains "UIDNEXT 3"
And IMAP response contains "UIDVALIDITY"

View File

@ -0,0 +1,143 @@
Feature: IMAP list mailboxes
Background:
Given there is connected user "user"
Scenario: List mailboxes
Given there is "user" with mailbox "Folders/mbox1"
And there is "user" with mailbox "Labels/mbox2"
And there is IMAP client logged in as "user"
When IMAP client lists mailboxes
Then IMAP response contains "INBOX"
Then IMAP response contains "Sent"
Then IMAP response contains "Archive"
Then IMAP response contains "Trash"
Then IMAP response contains "All Mail"
Then IMAP response contains "Folders/mbox1"
Then IMAP response contains "Labels/mbox2"
Scenario: List mailboxes without All Mail
Given there is IMAP client logged in as "user"
When IMAP client lists mailboxes
Then IMAP response contains "INBOX"
Then IMAP response contains "Sent"
Then IMAP response contains "Archive"
Then IMAP response contains "Trash"
Then IMAP response contains "All Mail"
When All mail mailbox is hidden
And IMAP client lists mailboxes
Then IMAP response contains "INBOX"
Then IMAP response contains "Sent"
Then IMAP response contains "Archive"
Then IMAP response contains "Trash"
Then IMAP response doesn't contain "All Mail"
When All mail mailbox is visible
And IMAP client lists mailboxes
Then IMAP response contains "INBOX"
Then IMAP response contains "Sent"
Then IMAP response contains "Archive"
Then IMAP response contains "Trash"
Then IMAP response contains "All Mail"
Scenario: List multiple times in parallel without crash
Given there is "user" with mailboxes
| Folders/mbox1 |
| Folders/mbox2 |
| Folders/mbox3 |
| Folders/mbox4 |
| Folders/mbox5 |
| Folders/mbox6 |
| Folders/mbox7 |
| Folders/mbox8 |
| Folders/mbox9 |
| Folders/mbox10 |
| Folders/mbox11 |
| Folders/mbox12 |
| Folders/mbox13 |
| Folders/mbox14 |
| Folders/mbox15 |
| Folders/mbox16 |
| Folders/mbox17 |
| Folders/mbox18 |
| Folders/mbox19 |
| Folders/mbox20 |
| Labels/lab1 |
| Labels/lab2 |
| Labels/lab3 |
| Labels/lab4 |
| Labels/lab5 |
| Labels/lab6 |
| Labels/lab7 |
| Labels/lab8 |
| Labels/lab9 |
| Labels/lab10 |
| Labels/lab11 |
| Labels/lab12 |
| Labels/lab13 |
| Labels/lab14 |
| Labels/lab15 |
| Labels/lab16 |
| Labels/lab17 |
| Labels/lab18 |
| Labels/lab19 |
| Labels/lab20 |
| Labels/lab1.1 |
| Labels/lab1.2 |
| Labels/lab1.3 |
| Labels/lab1.4 |
| Labels/lab1.5 |
| Labels/lab1.6 |
| Labels/lab1.7 |
| Labels/lab1.8 |
| Labels/lab1.9 |
| Labels/lab1.10 |
| Labels/lab1.11 |
| Labels/lab1.12 |
| Labels/lab1.13 |
| Labels/lab1.14 |
| Labels/lab1.15 |
| Labels/lab1.16 |
| Labels/lab1.17 |
| Labels/lab1.18 |
| Labels/lab1.19 |
| Labels/lab1.20 |
| Labels/lab2.1 |
| Labels/lab2.2 |
| Labels/lab2.3 |
| Labels/lab2.4 |
| Labels/lab2.5 |
| Labels/lab2.6 |
| Labels/lab2.7 |
| Labels/lab2.8 |
| Labels/lab2.9 |
| Labels/lab2.10 |
| Labels/lab2.11 |
| Labels/lab2.12 |
| Labels/lab2.13 |
| Labels/lab2.14 |
| Labels/lab2.15 |
| Labels/lab2.16 |
| Labels/lab2.17 |
| Labels/lab2.18 |
| Labels/lab2.19 |
| Labels/lab2.20 |
And there is IMAP client "A" logged in as "user"
And there is IMAP client "B" logged in as "user"
When IMAP client "A" lists mailboxes
And IMAP client "B" lists mailboxes
Then IMAP response to "A" is "OK"
And IMAP response to "A" contains "mbox1"
And IMAP response to "A" contains "mbox10"
And IMAP response to "A" contains "mbox20"
@ignore-live
Scenario: List mailboxes with subfolders
# Escaped slash in the name contains slash in the name.
# Not-escaped slash in the name means tree structure.
# We keep escaping in an IMAP communication so each mailbox is unique and
# both mailboxes are accessible. The slash is visible in the IMAP client.
Given there is "user" with mailbox "Folders/a\/b"
And there is "user" with mailbox "Folders/a/b"
And there is IMAP client logged in as "user"
When IMAP client lists mailboxes
Then IMAP response contains "Folders/a\/b"
Then IMAP response contains "Folders/a/b"

View File

@ -0,0 +1,30 @@
Feature: IMAP mailbox rename
Background:
Given there is connected user "user"
Scenario: Rename folder
Given there is "user" with mailbox "Folders/mbox"
And there is IMAP client logged in as "user"
When IMAP client renames mailbox "Folders/mbox" to "Folders/mbox2"
Then IMAP response is "OK"
And "user" does not have mailbox "Folders/mbox"
And "user" has mailbox "Folders/mbox2"
Scenario: Rename label
Given there is "user" with mailbox "Labels/mbox"
And there is IMAP client logged in as "user"
When IMAP client renames mailbox "Labels/mbox" to "Labels/mbox2"
Then IMAP response is "OK"
And "user" does not have mailbox "Labels/mbox"
And "user" has mailbox "Labels/mbox2"
Scenario: Renaming folder to label is not possible
Given there is "user" with mailbox "Folders/mbox"
And there is IMAP client logged in as "user"
When IMAP client renames mailbox "Folders/mbox" to "Labels/mbox"
Then IMAP response is "IMAP error: NO cannot rename folder to non-folder"
Scenario: Renaming system folder is not possible
Given there is IMAP client logged in as "user"
When IMAP client renames mailbox "INBOX" to "Folders/mbox"
Then IMAP response is "IMAP error: NO cannot rename system mailboxes"

View File

@ -0,0 +1,17 @@
Feature: IMAP select into mailbox
Background:
Given there is connected user "user"
And there is "user" with mailbox "Folders/mbox"
And there is IMAP client logged in as "user"
Scenario: Select into inbox
When IMAP client selects "INBOX"
Then IMAP response is "OK"
Scenario: Select into custom mailbox
When IMAP client selects "Folders/mbox"
Then IMAP response is "OK"
Scenario: Select into non-existing mailbox
When IMAP client selects "qwerty"
Then IMAP response is "IMAP error: NO mailbox qwerty does not exist"

View File

@ -0,0 +1,20 @@
Feature: IMAP get mailbox status
Background:
Given there is connected user "user"
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: Mailbox status contains mailbox name
When IMAP client gets status of "INBOX"
Then IMAP response contains "INBOX"
Scenario: Mailbox status contains counts and UIDs
When IMAP client gets status of "INBOX"
And IMAP response contains "MESSAGES 2"
And IMAP response contains "UNSEEN 1"
And IMAP response contains "UIDNEXT 3"
And IMAP response contains "UIDVALIDITY"

View File

@ -0,0 +1,89 @@
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 | read | deleted |
| john.doe@mail.com | user@pm.me | foo | hello | true | false |
| jane.doe@mail.com | name@pm.me | bar | world | false | true |
And there are messages in mailbox "Sent" for "user"
| from | to | subject | body |
| john.doe@mail.com | user@pm.me | response | hello |
And there is IMAP client logged in as "user"
Scenario: Copy message to label
Given there is IMAP client selected in "INBOX"
When IMAP client copies message seq "1" to "Labels/label"
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has messages
| from | to | subject | body | read | deleted |
| john.doe@mail.com | user@pm.me | foo | hello | true | false |
| jane.doe@mail.com | name@pm.me | bar | world | false | true |
And mailbox "Labels/label" for "user" has messages
| from | to | subject | body | read | deleted |
| john.doe@mail.com | user@pm.me | foo | hello | true | false |
Scenario: Copy all messages to label
Given there is IMAP client selected in "INBOX"
When IMAP client copies message seq "1:*" to "Labels/label"
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has messages
| from | to | subject | body | read | deleted |
| john.doe@mail.com | user@pm.me | foo | hello | true | false |
| jane.doe@mail.com | name@pm.me | bar | world | false | true |
And mailbox "Labels/label" for "user" has messages
| from | to | subject | body | read | deleted |
| john.doe@mail.com | user@pm.me | foo | hello | true | false |
| jane.doe@mail.com | name@pm.me | bar | world | false | true |
Scenario: Copy message to folder does move
Given there is IMAP client selected in "INBOX"
When IMAP client copies message seq "1" to "Folders/mbox"
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has messages
| from | to | subject | body | read | deleted |
| jane.doe@mail.com | name@pm.me | bar | world | false | true |
And mailbox "Folders/mbox" for "user" has messages
| from | to | subject | body | read | deleted |
| john.doe@mail.com | user@pm.me | foo | hello | true | false |
Scenario: Copy message from All mail moves from the original location
Given there is IMAP client selected in "All Mail"
When IMAP client copies message seq "1" to "Folders/mbox"
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has 2 messages
And mailbox "INBOX" for "user" has messages
| from | to | subject | body | read | deleted |
| jane.doe@mail.com | name@pm.me | bar | world | false | true |
| john.doe@mail.com | user@pm.me | response | hello | true | false |
And mailbox "All Mail" for "user" has 3 messages
And mailbox "All Mail" for "user" has messages
| from | to | subject | body | read | deleted |
| john.doe@mail.com | user@pm.me | foo | hello | true | false |
| jane.doe@mail.com | name@pm.me | bar | world | false | false |
| john.doe@mail.com | user@pm.me | response | hello | true | false |
And mailbox "Folders/mbox" for "user" has 1 messages
And mailbox "Folders/mbox" for "user" has messages
| from | to | subject | body | read | deleted |
| john.doe@mail.com | user@pm.me | foo | hello | true | false |
Scenario: Copy all messages to folder does move
Given there is IMAP client selected in "INBOX"
When IMAP client copies message seq "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 | body | read | deleted |
| john.doe@mail.com | user@pm.me | foo | hello | true | false |
| jane.doe@mail.com | name@pm.me | bar | world | false | true |
Scenario: Copy message from Inbox to Sent is not possible
Given there is IMAP client selected in "INBOX"
When IMAP client copies message seq "1" to "Sent"
Then IMAP response is "move from Inbox to Sent is not allowed"
Scenario: Copy message from Sent to Inbox is not possible
Given there is IMAP client selected in "Sent"
When IMAP client copies message seq "1" to "INBOX"
Then IMAP response is "move from Sent to Inbox is not allowed"

View File

@ -0,0 +1,78 @@
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.
#
# NOTE: We need to introduce cooldown here in order to detect duplicates
# properly. Once mail is imported to API the Sphinx indices for duplicate
# detection are updated every 10s. Therefore it is good to leave at least 15
# second gap after import in order to be able to correctly handle the case
# when we try to detect duplicate imports
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 wait for Sphinx to create duplication indices
And there is IMAP client selected in "Sent"
Then mailbox "Sent" for "userMoreAddresses" has 1 messages
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 \[APPENDUID 4 2\] APPEND completed"
And mailbox "Sent" for "userMoreAddresses" has 2 messages

View File

@ -0,0 +1,127 @@
Feature: IMAP remove messages from mailbox
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: Mark message as deleted and EXPUNGE
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 marks message seq "2" as deleted
Then IMAP response is "OK"
And mailbox "<mailbox>" for "user" has 10 messages
And message "2" in "<mailbox>" for "user" is marked as deleted
And IMAP response contains "\* 2 FETCH[ (]*FLAGS \([^)]*\\Deleted"
When IMAP client sends expunge
Then IMAP response is "OK"
And IMAP response contains "\* 2 EXPUNGE"
And mailbox "<mailbox>" for "user" has 9 messages
Examples:
| mailbox |
| INBOX |
| Folders/mbox |
| Labels/label |
| Spam |
| Trash |
Scenario Outline: Mark all messages as deleted and EXPUNGE
Given there are 5 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 marks message seq "1:*" as deleted
Then IMAP response is "OK"
# Use UID version to not be sensitive about the order from API. Event loop
# could return it in different order and delete first message with seq 1,
# which would produce EXPUNGE sequence as 1 4 3 2 1, for example.
When IMAP client sends expunge by UID "1:5"
Then IMAP response is "OK"
And IMAP response contains "\* 1 EXPUNGE"
And IMAP response contains "\* 2 EXPUNGE"
And IMAP response contains "\* 3 EXPUNGE"
And IMAP response contains "\* 4 EXPUNGE"
And IMAP response contains "\* 5 EXPUNGE"
And mailbox "<mailbox>" for "user" has 0 messages
Examples:
| mailbox |
| INBOX |
| Folders/mbox |
| Labels/label |
| Spam |
| Trash |
Scenario Outline: Mark messages as undeleted and EXPUNGE
Given there are 5 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 marks message seq "1:*" as deleted
Then IMAP response is "OK"
When IMAP client marks message seq "1:3" as undeleted
Then IMAP response is "OK"
When IMAP client sends expunge
Then IMAP response is "OK"
And IMAP response contains "\* 4 EXPUNGE"
And IMAP response contains "\* 5 EXPUNGE"
And mailbox "<mailbox>" for "user" has 3 messages
Examples:
| mailbox |
| INBOX |
| Folders/mbox |
| Labels/label |
| Spam |
| Trash |
Scenario Outline: Mark message as deleted and leave mailbox
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 marks message seq "2" as deleted
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has 10 messages
And message "2" in "INBOX" for "user" is marked as deleted
When IMAP client sends command "<leave>"
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has <n> messages
Examples:
| leave | n |
| CLOSE | 9 |
| SELECT INBOX | 9 |
| SELECT Trash | 9 |
| EXAMINE INBOX | 9 |
| EXAMINE Trash | 9 |
| LOGOUT | 9 |
| UNSELECT | 10 |
Scenario: Not possible to delete from All Mail and expunge does nothing
Given there are messages in mailbox "INBOX" for "user"
| id | from | to | subject | body |
| 1 | john.doe@mail.com | user@pm.me | subj1 | body1 |
And there is IMAP client logged in as "user"
And there is IMAP client selected in "All Mail"
When IMAP client marks message seq "1" as deleted
Then IMAP response is "IMAP error: NO operation not allowed for 'All Mail' folder"
And mailbox "All Mail" for "user" has messages
| from | to | subject |
| john.doe@mail.com | user@pm.me | subj1 |
When IMAP client sends expunge
Then IMAP response is "OK"
And mailbox "All Mail" for "user" has messages
| from | to | subject |
| john.doe@mail.com | user@pm.me | subj1 |
Scenario: Expunge specific message only
Given there are 5 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 seq "1" as deleted
Then IMAP response is "OK"
When IMAP client marks message seq "2" as deleted
Then IMAP response is "OK"
When IMAP client sends command "UID EXPUNGE 1"
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has 4 messages
And message "2" in "INBOX" for "user" is marked as deleted

View File

@ -0,0 +1,51 @@
Feature: IMAP remove messages from Trash
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: Message in Trash/Spam and some other label is not permanently deleted
Given there are messages in mailbox "<mailbox>" for "user"
| id | from | to | subject | body |
| 1 | john.doe@mail.com | user@pm.me | foo | hello |
| 2 | 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 "<mailbox>"
When IMAP client copies message seq "2" to "Labels/label"
Then IMAP response is "OK"
When IMAP client marks message seq "2" as deleted
Then IMAP response is "OK"
And mailbox "<mailbox>" for "user" has 2 messages
And mailbox "All Mail" for "user" has 2 messages
And mailbox "Labels/label" for "user" has 1 messages
When IMAP client sends expunge
Then IMAP response is "OK"
And mailbox "<mailbox>" for "user" has 1 messages
And mailbox "All Mail" for "user" has 2 messages
And mailbox "Labels/label" for "user" has 1 messages
Examples:
| mailbox |
| Spam |
| Trash |
Scenario Outline: Message in Trash/Spam only is permanently deleted
Given there are messages in mailbox "<mailbox>" for "user"
| id | from | to | subject | body |
| 1 | john.doe@mail.com | user@pm.me | foo | hello |
| 2 | 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 "<mailbox>"
When IMAP client marks message seq "2" as deleted
Then IMAP response is "OK"
And mailbox "<mailbox>" for "user" has 2 messages
And mailbox "All Mail" for "user" has 2 messages
When IMAP client sends expunge
Then IMAP response is "OK"
And mailbox "<mailbox>" for "user" has 1 messages
And mailbox "All Mail" for "user" has 1 messages
Examples:
| mailbox |
| Spam |
| Trash |

View File

@ -0,0 +1,47 @@
Feature: IMAP operations with Drafts
Background:
Given there is connected user "user"
And there are messages in mailbox "Drafts" for "user"
| id | from | subject | body |
| msg1 | Lionel Richie <lionel@richie.com> | RE: Hello, is it me you looking for? | Nope |
And there is IMAP client logged in as "user"
And there is IMAP client selected in "Drafts"
Scenario: Draft subject updated locally
Scenario: Draft recipient updated locally
Scenario: Draft body updated locally
@ignore-live
Scenario: Draft subject updated on server side
@ignore-live
Scenario: Draft recipient updated on server side
@ignore-live
Scenario: Draft body and size updated on server side
When IMAP client fetches body of UID "1"
Then IMAP response is "OK"
Then IMAP response contains "Nope"
When IMAP client sends command "UID FETCH 1 RFC822.SIZE"
Then IMAP response is "OK"
Then IMAP response contains "538"
When IMAP client sends command "UID FETCH 1 BODYSTRUCTURE"
Then IMAP response is "OK"
Then IMAP response contains "4 14"
Given the body of draft "msg1" for "user" has changed to "Yes I am"
And the event loop of "user" loops once
And mailbox "Drafts" for "user" has 1 messages
When IMAP client fetches body of UID "2"
Then IMAP response is "OK"
Then IMAP response contains "Yes I am"
Then IMAP response does not contain "Nope"
When IMAP client sends command "UID FETCH 2 RFC822.SIZE"
Then IMAP response is "OK"
Then IMAP response contains "542"
When IMAP client sends command "UID FETCH 2 BODYSTRUCTURE"
Then IMAP response is "OK"
Then IMAP response contains "8 14"

View File

@ -0,0 +1,191 @@
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 of inbox by UID
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 by UID "1:*"
Then IMAP response is "OK"
And IMAP response has 10 messages
Scenario: Fetch first few messages 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 first few messages of inbox by UID
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 by UID "1:5"
Then IMAP response is "OK"
And IMAP response has 5 messages
Scenario: Fetch last few messages of inbox using wildcard
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 "6:*"
Then IMAP response is "OK"
And IMAP response has 5 messages
Scenario: Fetch last few messages of inbox using wildcard by UID
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 by UID "6:*"
Then IMAP response is "OK"
And IMAP response has 5 messages
Scenario: Fetch last message of inbox using wildcard
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 "*"
Then IMAP response is "OK"
And IMAP response has 1 message
Scenario: Fetch last message of inbox using wildcard by UID
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 by UID "*"
Then IMAP response is "OK"
And IMAP response has 1 message
Scenario: Fetch backwards range using wildcard
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 backwards range using wildcard by UID
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 by UID "*:1"
Then IMAP response is "OK"
And IMAP response has 10 messages
Scenario: Fetch overshot range using wildcard returns last message
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 "20:*"
Then IMAP response is "OK"
And IMAP response has 1 message
Scenario: Fetch overshot range using wildcard by UID returns last message
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 by UID "20:*"
Then IMAP response is "OK"
And IMAP response has 1 message
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
# This test is wrong! RFC says it should return "BAD" (GODT-1153).
Scenario Outline: Fetch range of empty mailbox
Given there is IMAP client logged in as "user"
And there is IMAP client selected in "Folders/mbox"
When IMAP client fetches "<range>"
Then IMAP response is "OK"
And IMAP response has 0 messages
When IMAP client fetches by UID "<range>"
Then IMAP response is "OK"
And IMAP response has 0 messages
Examples:
| range |
| 1 |
| 1,5,6 |
| 1:* |
| * |
@ignore-live
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 of big mailbox by UID
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 by UID "1:*"
Then IMAP response is "OK"
And IMAP response has 100 messages
Scenario: Fetch returns also messages that are marked as deleted
Given there are messages in mailbox "Folders/mbox" for "user"
| from | to | subject | body | read | starred | deleted |
| john.doe@mail.com | user@pm.me | foo | hello | false | false | false |
| jane.doe@mail.com | name@pm.me | bar | world | true | true | true |
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 2 message
Scenario: Fetch by UID returns also messages that are marked as deleted
Given there are messages in mailbox "Folders/mbox" for "user"
| from | to | subject | body | read | starred | deleted |
| john.doe@mail.com | user@pm.me | foo | hello | false | false | false |
| jane.doe@mail.com | name@pm.me | bar | world | true | true | true |
And there is IMAP client logged in as "user"
And there is IMAP client selected in "Folders/mbox"
When IMAP client fetches by UID "1:*"
Then IMAP response is "OK"
And IMAP response has 2 message
Scenario: Fetch of very old message sent from the moon succeeds with modified date
Given there are messages in mailbox "Folders/mbox" for "user"
| from | to | subject | time |
| john.doe@mail.com | user@pm.me | Very old email | 1969-07-20T00:00:00 |
And there is IMAP client logged in as "user"
And there is IMAP client selected in "Folders/mbox"
When IMAP client sends command "FETCH 1:* rfc822"
Then IMAP response is "OK"
And IMAP response contains "\nDate: Fri, 13 Aug 1982"
And IMAP response contains "\nX-Pm-Date: Thu, 01 Jan 1970"
And IMAP response contains "\nX-Original-Date: Sun, 20 Jul 1969"
# We had bug to incorectly set empty date, so let's make sure
# there is no reference anywhere in the response.
And IMAP response does not contain "\nDate: Thu, 01 Jan 1970"
Scenario: Fetch of message which was deleted without event processed
Given there are 10 messages in mailbox "INBOX" for "user"
And message "5" was deleted forever without event processed for "user"
And there is IMAP client logged in as "user"
And there is IMAP client selected in "INBOX"
When IMAP client fetches bodies "1:*"
Then IMAP response is "NO"
When IMAP client fetches bodies "1:*"
Then IMAP response is "OK"
And IMAP response has 9 messages

View File

@ -0,0 +1,41 @@
Feature: IMAP fetch header of message
Background: Fetch header deterministic content type and boundary
Given there is connected user "user"
And there are messages in mailbox "INBOX" for "user"
| id | from | to | subject | n attachments | content type | body |
| 1 | f@m.co | t@pm.me | A message with attachment | 2 | html | body |
| 2 | f@m.co | t@pm.me | A simple html message | 0 | html | body |
| 3 | f@m.co | t@pm.me | A simple plain message | 0 | plain | body |
# | 4 | f@m.co | t@pm.me | An externally encrypted message | 0 | mixed | body |
# | 5 | f@m.co | t@pm.me | A simple plain message in latin1 | 0 | plain-latin1 | body |
And there is IMAP client logged in as "user"
And there is IMAP client selected in "INBOX"
@ignore-live
Scenario Outline: Fetch header deterministic content type and boundary
Given header is not cached for message "<id>" in "INBOX" for "user"
# First time need to download and cache
When IMAP client fetches header of "<id>"
Then IMAP response is "OK"
And IMAP response contains "Content-Type: <contentType>"
And IMAP response contains "<parameter>"
And header is cached for message "<id>" in "INBOX" for "user"
# Second time it's taken from imap cache
When IMAP client fetches body "<id>"
Then IMAP response is "OK"
And IMAP response contains "Content-Type: <contentType>"
And IMAP response contains "<parameter>"
# Third time header taken from DB
When IMAP client fetches header of "<id>"
Then IMAP response is "OK"
And IMAP response contains "Content-Type: <contentType>"
And IMAP response contains "<parameter>"
Examples:
| id | contentType | parameter |
| 1 | multipart/mixed | boundary=4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce |
| 2 | text/html | charset=utf-8 |
| 3 | text/plain | charset=utf-8 |

View File

@ -0,0 +1,220 @@
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"
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
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"
# I could not find any RFC why this is not valid. But for now our parser is not able to process it.
@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"
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
--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
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"
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
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"
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
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"
Scenario: Import received message to Sent
When IMAP client imports message to "Sent"
"""
From: Foo <foo@example.com>
To: Bridge Test <bridgetest@pm.test>
Subject: Hello
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 API mailbox "Sent" for "user" has 0 message
And API mailbox "INBOX" for "user" has 1 message
Scenario: Import non-received message to Inbox
When IMAP client imports message to "INBOX"
"""
From: Foo <foo@example.com>
To: Bridge Test <bridgetest@pm.test>
Subject: Hello
Hello
"""
Then IMAP response is "OK"
And API mailbox "INBOX" for "user" has 0 message
And API mailbox "Sent" for "user" has 1 message
Scenario Outline: Import message without sender
When IMAP client imports message to "<mailbox>"
"""
To: Lionel Richie <lionel@richie.com>
Subject: RE: Hello, is it me you looking for?
Nope.
"""
Then IMAP response is "OK"
And API mailbox "<mailbox>" for "user" has 1 message
Examples:
| mailbox |
| Drafts |
| Archive |
| Sent |
Scenario: Import embedded message
When IMAP client imports message to "INBOX"
"""
From: Foo <foo@example.com>
To: Bridge Test <bridgetest@pm.test>
Subject: Embedded message
Content-Type: multipart/mixed; boundary="boundary"
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
This is a multi-part message in MIME format.
--boundary
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
--boundary
Content-Type: message/rfc822; name="embedded.eml"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="embedded.eml"
From: Bar <bar@example.com>
To: Bridge Test <bridgetest@pm.test>
Subject: (No Subject)
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
hello
--boundary--
"""
Then IMAP response is "OK"
# We cannot control internal IDs on live server.
@ignore-live
Scenario: Import existing message
When IMAP client imports message to "INBOX"
"""
From: Foo <foo@example.com>
To: Bridge Test <bridgetest@pm.test>
Subject: Hello
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
X-Pm-Internal-Id: 1
Hello
"""
Then IMAP response is "OK \[APPENDUID \d 1\] APPEND completed"
When IMAP client imports message to "INBOX"
"""
From: Foo <foo@example.com>
To: Bridge Test <bridgetest@pm.test>
Subject: Hello
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
X-Pm-Internal-Id: 1
Hello
"""
Then IMAP response is "OK \[APPENDUID \d 1\] APPEND completed"
Scenario: Import message to All Mail
When IMAP client imports message to "All Mail"
"""
From: Foo <from1@pm.me>
To: Bridge Test <to1@pm.me>
Subject: subj1
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
body1
"""
Then IMAP response is "OK \[APPENDUID \d 1\] APPEND completed"
Then mailbox "Archive" for "user" has messages
| from | to | subject | body
| from1@pm.me | to1@pm.me | subj1 | body1
And API mailbox "Archive" for "user" has 1 message
And mailbox "All Mail" for "user" has messages
| from | to | subject | body
| from1@pm.me | to1@pm.me | subj1 | body1
And API mailbox "All Mail" for "user" has 1 message

View File

@ -0,0 +1,98 @@
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"

View File

@ -0,0 +1,80 @@
# 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 |

View File

@ -0,0 +1,77 @@
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 |

View File

@ -0,0 +1,90 @@
Feature: IMAP search messages
Background:
Given there is connected user "user"
Given there are messages in mailbox "INBOX" for "user"
| from | to | cc | subject | read | starred | deleted | body |
| john.doe@email.com | user@pm.me | | foo | false | false | false | hello |
| jane.doe@email.com | user@pm.me | name@pm.me | bar | true | true | false | world |
| jane.doe@email.com | name@pm.me | | baz | true | false | true | 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 1[^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 2 3[^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 1 2[^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 2 3[^0-9]*$"
Scenario: Search unseen messages
When IMAP client searches for "UNSEEN"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 1[^0-9]*$"
Scenario: Search deleted messages
When IMAP client searches for "DELETED"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 3[^0-9]*$"
Scenario: Search undeleted messages
When IMAP client searches for "UNDELETED"
Then IMAP response is "OK"
And IMAP response contains "SEARCH 1 2[^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 3[^0-9]*$"

View File

@ -0,0 +1,81 @@
Feature: IMAP update messages
Background:
Given there is connected user "user"
And there are messages in mailbox "INBOX" for "user"
| id | from | to | subject | body | read | starred | deleted |
| 1 | john.doe@mail.com | user@pm.me | foo | hello | false | false | false |
| 2 | jane.doe@mail.com | name@pm.me | bar | world | true | true | false |
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 seq "1" 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 seq "2" 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 seq "1" 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 seq "2" 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 seq "1" 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 seq "2" 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 seq "2" 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
Scenario: Mark message as deleted
# Mark message as Starred so we can check that mark as Deleted is not
# tempering with Starred flag
When IMAP client marks message seq "2" as starred
Then IMAP response is "OK"
When IMAP client marks message seq "2" as deleted
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 starred
And message "2" in "INBOX" for "user" is marked as deleted
Scenario: Mark message as undeleted
When IMAP client marks message seq "2" as undeleted
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 starred
And message "2" in "INBOX" for "user" is marked as undeleted
Scenario: Mark message as deleted only
When IMAP client marks message seq "2" with "\Deleted"
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 unstarred
And message "2" in "INBOX" for "user" is marked as deleted

View File

@ -0,0 +1,62 @@
Feature: IMAP update messages in Spam folder
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 "Spam" for "user"
| id | from | to | subject | body | read | starred | deleted |
| 1 | john.doe@mail.com | user@pm.me | foo | hello | false | false | false |
| 2 | jane.doe@mail.com | name@pm.me | bar | world | true | true | false |
And there is IMAP client logged in as "user"
And there is IMAP client selected in "Spam"
Scenario: Mark message as read only
When IMAP client marks message seq "1" with "\Seen"
Then IMAP response is "OK"
And message "1" in "Spam" for "user" is marked as read
And message "1" in "Spam" for "user" is marked as unstarred
And API mailbox "Spam" for "user" has messages
| from | to | subject |
| john.doe@mail.com | user@pm.me | foo |
| jane.doe@mail.com | name@pm.me | bar |
Scenario Outline: Move from Spam to INBOX when client <operation> <flag>
When IMAP client <operation> flags "<flag>" <suffix> message seq "1"
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has 1 messages
And mailbox "INBOX" for "user" has messages
| from | to | subject |
| john.doe@mail.com | user@pm.me | foo |
And mailbox "Spam" for "user" has 1 messages
And mailbox "Spam" for "user" has messages
| from | to | subject |
| jane.doe@mail.com | name@pm.me | bar |
Examples:
| operation | suffix | flag |
| adds | to | nojunk |
| adds | to | NoJunk |
| removes | from | junk |
| removes | from | Junk |
| removes | from | $Junk |
Scenario Outline: Do not move from Archive to INBOX when client <operation> <flag>
Given there are messages in mailbox "Archive" for "user"
| id | from | to | subject | body | read | starred | deleted |
| 1 | john.doe@mail.com | user@pm.me | Archived | hello | false | false | false |
And there is IMAP client selected in "Archive"
When IMAP client <operation> flags "<flag>" <suffix> message seq "1"
Then IMAP response is "OK"
And mailbox "INBOX" for "user" has 0 messages
And mailbox "Archive" for "user" has 1 messages
And mailbox "Archive" for "user" has messages
| from | to | subject |
| john.doe@mail.com | user@pm.me | Archived |
Examples:
| operation | suffix | flag |
| adds | to | nojunk |
| adds | to | NoJunk |
| removes | from | junk |
| removes | from | Junk |
| removes | from | $Junk |

View File

@ -0,0 +1,26 @@
Feature: User agent
Background:
Given there is connected user "user"
Scenario: Get user agent
Given there is IMAP client logged in as "user"
Then API user-agent is "UnknownClient/0.0.1 ([GOOS])"
When IMAP client sends ID with argument:
"""
"name" "Foo" "version" "1.4.0"
"""
Then API user-agent is "Foo/1.4.0 ([GOOS])"
Scenario: Update user agent
Given there is IMAP client logged in as "user"
Then API user-agent is "UnknownClient/0.0.1 ([GOOS])"
When IMAP client sends ID with argument:
"""
"name" "Foo" "version" "1.4.0"
"""
Then API user-agent is "Foo/1.4.0 ([GOOS])"
When IMAP client sends ID with argument:
"""
"name" "Bar" "version" "4.2.0"
"""
Then API user-agent is "Bar/4.2.0 ([GOOS])"