mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-16 07:06:45 +00:00
Integration tests
This commit is contained in:
@ -32,7 +32,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func APIChecksFeatureContext(s *godog.Suite) {
|
func APIChecksFeatureContext(s *godog.Suite) {
|
||||||
s.Step(`^API endpoint "([^"]*)" is called with:$`, apiIsCalledWith)
|
s.Step(`^API endpoint "([^"]*)" is called$`, apiIsCalled)
|
||||||
|
s.Step(`^API endpoint "([^"]*)" is called with$`, apiIsCalledWith)
|
||||||
|
s.Step(`^API endpoint "([^"]*)" is not called$`, apiIsNotCalled)
|
||||||
|
s.Step(`^API endpoint "([^"]*)" is not called with$`, apiIsNotCalledWith)
|
||||||
s.Step(`^message is sent with API call$`, messageIsSentWithAPICall)
|
s.Step(`^message is sent with API call$`, messageIsSentWithAPICall)
|
||||||
s.Step(`^API mailbox "([^"]*)" for "([^"]*)" has (\d+) message(?:s)?$`, apiMailboxForUserHasNumberOfMessages)
|
s.Step(`^API mailbox "([^"]*)" for "([^"]*)" has (\d+) message(?:s)?$`, apiMailboxForUserHasNumberOfMessages)
|
||||||
s.Step(`^API mailbox "([^"]*)" for address "([^"]*)" of "([^"]*)" has (\d+) message(?:s)?$`, apiMailboxForAddressOfUserHasNumberOfMessages)
|
s.Step(`^API mailbox "([^"]*)" for address "([^"]*)" of "([^"]*)" has (\d+) message(?:s)?$`, apiMailboxForAddressOfUserHasNumberOfMessages)
|
||||||
@ -41,15 +44,40 @@ func APIChecksFeatureContext(s *godog.Suite) {
|
|||||||
s.Step(`^API client manager user-agent is "([^"]*)"$`, clientManagerUserAgent)
|
s.Step(`^API client manager user-agent is "([^"]*)"$`, clientManagerUserAgent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func apiIsCalled(endpoint string) error {
|
||||||
|
if !apiIsCalledWithHelper(endpoint, "") {
|
||||||
|
return fmt.Errorf("%s was not called", endpoint)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func apiIsCalledWith(endpoint string, data *gherkin.DocString) error {
|
func apiIsCalledWith(endpoint string, data *gherkin.DocString) error {
|
||||||
|
if !apiIsCalledWithHelper(endpoint, data.Content) {
|
||||||
|
return fmt.Errorf("%s was not called with %s", endpoint, data.Content)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func apiIsNotCalled(endpoint string) error {
|
||||||
|
if apiIsCalledWithHelper(endpoint, "") {
|
||||||
|
return fmt.Errorf("%s was called", endpoint)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func apiIsNotCalledWith(endpoint string, data *gherkin.DocString) error {
|
||||||
|
if apiIsCalledWithHelper(endpoint, data.Content) {
|
||||||
|
return fmt.Errorf("%s was called with %s", endpoint, data.Content)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func apiIsCalledWithHelper(endpoint string, content string) bool {
|
||||||
split := strings.Split(endpoint, " ")
|
split := strings.Split(endpoint, " ")
|
||||||
method := split[0]
|
method := split[0]
|
||||||
path := split[1]
|
path := split[1]
|
||||||
request := []byte(data.Content)
|
request := []byte(content)
|
||||||
if !ctx.GetPMAPIController().WasCalled(method, path, request) {
|
return ctx.GetPMAPIController().WasCalled(method, path, request)
|
||||||
return fmt.Errorf("%s was not called with %s", endpoint, request)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func messageIsSentWithAPICall(data *gherkin.DocString) error {
|
func messageIsSentWithAPICall(data *gherkin.DocString) error {
|
||||||
|
|||||||
@ -70,9 +70,12 @@ func (ctl *Controller) PrintCalls() {
|
|||||||
|
|
||||||
func (ctl *Controller) WasCalled(method, path string, expectedRequest []byte) bool {
|
func (ctl *Controller) WasCalled(method, path string, expectedRequest []byte) bool {
|
||||||
for _, call := range ctl.calls {
|
for _, call := range ctl.calls {
|
||||||
if string(call.method) != method && call.path != path {
|
if string(call.method) != method || call.path != path {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if string(expectedRequest) == "" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
diff, _ := jsondiff.Compare(call.request, expectedRequest, &jsondiff.Options{})
|
diff, _ := jsondiff.Compare(call.request, expectedRequest, &jsondiff.Options{})
|
||||||
isSuperset := diff == jsondiff.FullMatch || diff == jsondiff.SupersetMatch
|
isSuperset := diff == jsondiff.FullMatch || diff == jsondiff.SupersetMatch
|
||||||
if isSuperset {
|
if isSuperset {
|
||||||
|
|||||||
@ -1,40 +1,89 @@
|
|||||||
Feature: IMAP move messages
|
Feature: IMAP move messages
|
||||||
Background:
|
Background:
|
||||||
Given there is connected user "user"
|
Given there is connected user "user"
|
||||||
And there is "user" with mailbox "Folders/mbox"
|
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"
|
And there are messages in mailbox "INBOX" for "user"
|
||||||
| from | to | subject | body |
|
| from | to | subject | body |
|
||||||
| john.doe@mail.com | user@pm.me | foo | hello |
|
| john.doe@mail.com | user@pm.me | foo | hello |
|
||||||
| jane.doe@mail.com | name@pm.me | bar | world |
|
| jane.doe@mail.com | name@pm.me | bar | world |
|
||||||
|
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"
|
And there is IMAP client logged in as "user"
|
||||||
And there is IMAP client selected in "INBOX"
|
|
||||||
|
|
||||||
Scenario: Move message
|
Scenario: Move message from inbox (folder) to folder
|
||||||
When IMAP client moves message seq "1" to "Folders/mbox"
|
Given there is IMAP client selected in "INBOX"
|
||||||
|
When IMAP client moves message seq "1" to "Folders/folder"
|
||||||
Then IMAP response is "OK"
|
Then IMAP response is "OK"
|
||||||
And mailbox "INBOX" for "user" has messages
|
And mailbox "INBOX" for "user" has messages
|
||||||
| from | to | subject |
|
| from | to | subject |
|
||||||
| jane.doe@mail.com | name@pm.me | bar |
|
| jane.doe@mail.com | name@pm.me | bar |
|
||||||
And mailbox "Folders/mbox" for "user" has messages
|
And mailbox "Folders/folder" for "user" has messages
|
||||||
| from | to | subject |
|
| from | to | subject |
|
||||||
| john.doe@mail.com | user@pm.me | foo |
|
| 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
|
Scenario: Move all messages from inbox to folder
|
||||||
When IMAP client moves message seq "1:*" to "Folders/mbox"
|
Given there is IMAP client selected in "INBOX"
|
||||||
|
When IMAP client moves message seq "1:*" to "Folders/folder"
|
||||||
Then IMAP response is "OK"
|
Then IMAP response is "OK"
|
||||||
And mailbox "INBOX" for "user" has 0 messages
|
And mailbox "INBOX" for "user" has 0 messages
|
||||||
And mailbox "Folders/mbox" for "user" has messages
|
And mailbox "Folders/folder" for "user" has messages
|
||||||
| from | to | subject |
|
| from | to | subject |
|
||||||
| john.doe@mail.com | user@pm.me | foo |
|
| john.doe@mail.com | user@pm.me | foo |
|
||||||
| jane.doe@mail.com | name@pm.me | bar |
|
| 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
|
Scenario: Move message from All Mail is not possible
|
||||||
When IMAP client moves message seq "1" to "Folders/mbox"
|
Given there is IMAP client selected in "All Mail"
|
||||||
|
When IMAP client moves message seq "1" to "Folders/folder"
|
||||||
Then IMAP response is "OK"
|
Then IMAP response is "OK"
|
||||||
And mailbox "All Mail" for "user" has messages
|
And mailbox "All Mail" for "user" has messages
|
||||||
| from | to | subject |
|
| from | to | subject |
|
||||||
| john.doe@mail.com | user@pm.me | foo |
|
| john.doe@mail.com | user@pm.me | foo |
|
||||||
| jane.doe@mail.com | name@pm.me | bar |
|
| jane.doe@mail.com | name@pm.me | bar |
|
||||||
And mailbox "Folders/mbox" for "user" has messages
|
And mailbox "Folders/folder" for "user" has messages
|
||||||
| from | to | subject |
|
| from | to | subject |
|
||||||
| john.doe@mail.com | user@pm.me | foo |
|
| 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 not called
|
||||||
|
|||||||
@ -52,9 +52,12 @@ func (ctl *Controller) PrintCalls() {
|
|||||||
|
|
||||||
func (ctl *Controller) WasCalled(method, path string, expectedRequest []byte) bool {
|
func (ctl *Controller) WasCalled(method, path string, expectedRequest []byte) bool {
|
||||||
for _, call := range ctl.calls {
|
for _, call := range ctl.calls {
|
||||||
if call.method != method && call.path != path {
|
if call.method != method || call.path != path {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if string(expectedRequest) == "" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
diff, _ := jsondiff.Compare(call.request, expectedRequest, &jsondiff.Options{})
|
diff, _ := jsondiff.Compare(call.request, expectedRequest, &jsondiff.Options{})
|
||||||
isSuperset := diff == jsondiff.FullMatch || diff == jsondiff.SupersetMatch
|
isSuperset := diff == jsondiff.FullMatch || diff == jsondiff.SupersetMatch
|
||||||
if isSuperset {
|
if isSuperset {
|
||||||
|
|||||||
@ -9,13 +9,6 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
|
|||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
* GODT-885 Do not explicitly unlabel folders during move to match behaviour of other clients.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
* GODT-979 Fix panic when trying to parse a multipart/alternative section that has no child sections.
|
|
||||||
### Changed
|
|
||||||
* GODT-389 Prefer `From` header instead of `MAIL FROM` address.
|
|
||||||
* GODT-898 Only set ContentID for inline attachments.
|
|
||||||
* GODT-773 Replace `INTERNALDATE` older than birthday of RFC822 by birthday of RFC822 to not crash Apple Mail.
|
|
||||||
* GODT-927 Avoid to call API with empty label name.
|
|
||||||
* GODT-732 Fix usage of fontawesome
|
|
||||||
* GODT-885 Do not explicitly unlabel folders during move to match behaviour of other clients.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user