mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
GODT-2170: Improving test server behaviour.
This commit is contained in:
4
go.mod
4
go.mod
@ -5,9 +5,9 @@ go 1.18
|
|||||||
require (
|
require (
|
||||||
github.com/0xAX/notificator v0.0.0-20220220101646-ee9b8921e557
|
github.com/0xAX/notificator v0.0.0-20220220101646-ee9b8921e557
|
||||||
github.com/Masterminds/semver/v3 v3.1.1
|
github.com/Masterminds/semver/v3 v3.1.1
|
||||||
github.com/ProtonMail/gluon v0.14.2-0.20221129150032-c663738a6cee
|
github.com/ProtonMail/gluon v0.14.2-0.20221201132248-f620ad183873
|
||||||
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a
|
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a
|
||||||
github.com/ProtonMail/go-proton-api v0.1.4
|
github.com/ProtonMail/go-proton-api v0.1.4-0.20221201145430-b0a0286c470e
|
||||||
github.com/ProtonMail/go-rfc5322 v0.11.0
|
github.com/ProtonMail/go-rfc5322 v0.11.0
|
||||||
github.com/ProtonMail/gopenpgp/v2 v2.4.10
|
github.com/ProtonMail/gopenpgp/v2 v2.4.10
|
||||||
github.com/PuerkitoBio/goquery v1.8.0
|
github.com/PuerkitoBio/goquery v1.8.0
|
||||||
|
|||||||
6
go.sum
6
go.sum
@ -30,6 +30,10 @@ github.com/ProtonMail/docker-credential-helpers v1.1.0 h1:+kvUIpwWcbtP3WFv5sSvkF
|
|||||||
github.com/ProtonMail/docker-credential-helpers v1.1.0/go.mod h1:mK0aBveCxhnQ756AmaTfXMZDeULvheYVhF/MWMErN5g=
|
github.com/ProtonMail/docker-credential-helpers v1.1.0/go.mod h1:mK0aBveCxhnQ756AmaTfXMZDeULvheYVhF/MWMErN5g=
|
||||||
github.com/ProtonMail/gluon v0.14.2-0.20221129150032-c663738a6cee h1:rDGqVa4CepqpJF8TDjqnBITqD8OzrLzeg66ibVDCPSc=
|
github.com/ProtonMail/gluon v0.14.2-0.20221129150032-c663738a6cee h1:rDGqVa4CepqpJF8TDjqnBITqD8OzrLzeg66ibVDCPSc=
|
||||||
github.com/ProtonMail/gluon v0.14.2-0.20221129150032-c663738a6cee/go.mod h1:z2AxLIiBCT1K+0OBHyaDI7AEaO5qI6/BEC2TE42vs4Q=
|
github.com/ProtonMail/gluon v0.14.2-0.20221129150032-c663738a6cee/go.mod h1:z2AxLIiBCT1K+0OBHyaDI7AEaO5qI6/BEC2TE42vs4Q=
|
||||||
|
github.com/ProtonMail/gluon v0.14.2-0.20221201094406-fc09f2d35933 h1:kj6JBn/ASSDKdLvZPU7fFPKC5vN+UgboBvfJzAaZkrY=
|
||||||
|
github.com/ProtonMail/gluon v0.14.2-0.20221201094406-fc09f2d35933/go.mod h1:z2AxLIiBCT1K+0OBHyaDI7AEaO5qI6/BEC2TE42vs4Q=
|
||||||
|
github.com/ProtonMail/gluon v0.14.2-0.20221201132248-f620ad183873 h1:9LKxCftz374K4cse/AdIaUgGLwQlrCPIMIA7llcOck4=
|
||||||
|
github.com/ProtonMail/gluon v0.14.2-0.20221201132248-f620ad183873/go.mod h1:z2AxLIiBCT1K+0OBHyaDI7AEaO5qI6/BEC2TE42vs4Q=
|
||||||
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a h1:D+aZah+k14Gn6kmL7eKxoo/4Dr/lK3ChBcwce2+SQP4=
|
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a h1:D+aZah+k14Gn6kmL7eKxoo/4Dr/lK3ChBcwce2+SQP4=
|
||||||
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a/go.mod h1:oTGdE7/DlWIr23G0IKW3OXK9wZ5Hw1GGiaJFccTvZi4=
|
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a/go.mod h1:oTGdE7/DlWIr23G0IKW3OXK9wZ5Hw1GGiaJFccTvZi4=
|
||||||
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
|
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
|
||||||
@ -45,6 +49,8 @@ github.com/ProtonMail/go-mime v0.0.0-20220429130430-2192574d760f h1:4IWzKjHzZxdr
|
|||||||
github.com/ProtonMail/go-mime v0.0.0-20220429130430-2192574d760f/go.mod h1:qRZgbeASl2a9OwmsV85aWwRqic0NHPh+9ewGAzb4cgM=
|
github.com/ProtonMail/go-mime v0.0.0-20220429130430-2192574d760f/go.mod h1:qRZgbeASl2a9OwmsV85aWwRqic0NHPh+9ewGAzb4cgM=
|
||||||
github.com/ProtonMail/go-proton-api v0.1.3 h1:Y0kdBTbyxEBo4eVK1BD7V9GSTPKUiy/soYR7bg2i2TU=
|
github.com/ProtonMail/go-proton-api v0.1.3 h1:Y0kdBTbyxEBo4eVK1BD7V9GSTPKUiy/soYR7bg2i2TU=
|
||||||
github.com/ProtonMail/go-proton-api v0.1.3/go.mod h1:jqvJ2HqLHqiPJoEb+BTIB1IF7wvr6p+8ZfA6PO2NRNk=
|
github.com/ProtonMail/go-proton-api v0.1.3/go.mod h1:jqvJ2HqLHqiPJoEb+BTIB1IF7wvr6p+8ZfA6PO2NRNk=
|
||||||
|
github.com/ProtonMail/go-proton-api v0.1.4-0.20221201145430-b0a0286c470e h1:PQIbcD4ZpHsZaLT2RcVuoWi7yl2f2x51KthTrerOpqI=
|
||||||
|
github.com/ProtonMail/go-proton-api v0.1.4-0.20221201145430-b0a0286c470e/go.mod h1:jqvJ2HqLHqiPJoEb+BTIB1IF7wvr6p+8ZfA6PO2NRNk=
|
||||||
github.com/ProtonMail/go-proton-api v0.1.4 h1:tGZlYuXlvT7AxFUPry42AsukLYm0HazlRg1iZLvlAZE=
|
github.com/ProtonMail/go-proton-api v0.1.4 h1:tGZlYuXlvT7AxFUPry42AsukLYm0HazlRg1iZLvlAZE=
|
||||||
github.com/ProtonMail/go-proton-api v0.1.4/go.mod h1:jqvJ2HqLHqiPJoEb+BTIB1IF7wvr6p+8ZfA6PO2NRNk=
|
github.com/ProtonMail/go-proton-api v0.1.4/go.mod h1:jqvJ2HqLHqiPJoEb+BTIB1IF7wvr6p+8ZfA6PO2NRNk=
|
||||||
github.com/ProtonMail/go-rfc5322 v0.11.0 h1:o5Obrm4DpmQEffvgsVqG6S4BKwC1Wat+hYwjIp2YcCY=
|
github.com/ProtonMail/go-rfc5322 v0.11.0 h1:o5Obrm4DpmQEffvgsVqG6S4BKwC1Wat+hYwjIp2YcCY=
|
||||||
|
|||||||
@ -487,10 +487,6 @@ func (user *User) handleUpdateDraftEvent(ctx context.Context, event proton.Messa
|
|||||||
"subject": logging.Sensitive(event.Message.Subject),
|
"subject": logging.Sensitive(event.Message.Subject),
|
||||||
}).Info("Handling draft updated event")
|
}).Info("Handling draft updated event")
|
||||||
|
|
||||||
for _, updateCh := range user.updateCh {
|
|
||||||
updateCh.Enqueue(imap.NewMessagesDeleted(imap.MessageID(event.ID)))
|
|
||||||
}
|
|
||||||
|
|
||||||
full, err := user.client.GetFullMessage(ctx, event.Message.ID)
|
full, err := user.client.GetFullMessage(ctx, event.Message.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get full draft: %w", err)
|
return fmt.Errorf("failed to get full draft: %w", err)
|
||||||
@ -502,7 +498,12 @@ func (user *User) handleUpdateDraftEvent(ctx context.Context, event proton.Messa
|
|||||||
return fmt.Errorf("failed to build RFC822 draft: %w", err)
|
return fmt.Errorf("failed to build RFC822 draft: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
user.updateCh[full.AddressID].Enqueue(imap.NewMessagesCreated(buildRes.update))
|
user.updateCh[full.AddressID].Enqueue(imap.NewMessageUpdated(
|
||||||
|
buildRes.update.Message,
|
||||||
|
buildRes.update.Literal,
|
||||||
|
buildRes.update.MailboxIDs,
|
||||||
|
buildRes.update.ParsedMessage,
|
||||||
|
))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/mail"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -442,7 +443,7 @@ func (conn *imapConnector) importMessage(
|
|||||||
messageID := ""
|
messageID := ""
|
||||||
|
|
||||||
if slices.Contains(labelIDs, proton.DraftsLabel) {
|
if slices.Contains(labelIDs, proton.DraftsLabel) {
|
||||||
msg, err := conn.createDraft(ctx, literal, addrKR)
|
msg, err := conn.createDraft(ctx, literal, addrKR, conn.apiAddrs[conn.addrID])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create draft: %w", err)
|
return fmt.Errorf("failed to create draft: %w", err)
|
||||||
}
|
}
|
||||||
@ -516,7 +517,7 @@ func toIMAPMessage(message proton.MessageMetadata) imap.Message {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *imapConnector) createDraft(ctx context.Context, literal []byte, addrKR *crypto.KeyRing) (proton.Message, error) { //nolint:funlen
|
func (conn *imapConnector) createDraft(ctx context.Context, literal []byte, addrKR *crypto.KeyRing, sender proton.Address) (proton.Message, error) { //nolint:funlen
|
||||||
// Create a new message parser from the reader.
|
// Create a new message parser from the reader.
|
||||||
parser, err := parser.New(bytes.NewReader(literal))
|
parser, err := parser.New(bytes.NewReader(literal))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -549,7 +550,7 @@ func (conn *imapConnector) createDraft(ctx context.Context, literal []byte, addr
|
|||||||
Body: armBody,
|
Body: armBody,
|
||||||
MIMEType: message.MIMEType,
|
MIMEType: message.MIMEType,
|
||||||
|
|
||||||
Sender: message.Sender,
|
Sender: &mail.Address{Name: sender.DisplayName, Address: sender.Email},
|
||||||
ToList: message.ToList,
|
ToList: message.ToList,
|
||||||
CCList: message.CCList,
|
CCList: message.CCList,
|
||||||
BCCList: message.BCCList,
|
BCCList: message.BCCList,
|
||||||
|
|||||||
@ -27,6 +27,7 @@ Feature: IMAP create messages
|
|||||||
And IMAP client "1" eventually sees the following messages in "Drafts":
|
And IMAP client "1" eventually sees the following messages in "Drafts":
|
||||||
| from | to | subject | body |
|
| from | to | subject | body |
|
||||||
| user@pm.me | john.doe@email.com | foo | bar |
|
| user@pm.me | john.doe@email.com | foo | bar |
|
||||||
|
# This fails now
|
||||||
And IMAP client "1" eventually sees the following messages in "All Mail":
|
And IMAP client "1" eventually sees the following messages in "All Mail":
|
||||||
| from | to | subject | body |
|
| from | to | subject | body |
|
||||||
| user@pm.me | john.doe@email.com | foo | bar |
|
| user@pm.me | john.doe@email.com | foo | bar |
|
||||||
|
|||||||
@ -11,6 +11,10 @@ Feature: IMAP Draft messages
|
|||||||
|
|
||||||
This is a dra
|
This is a dra
|
||||||
"""
|
"""
|
||||||
|
Then IMAP client "1" eventually sees the following messages in "Drafts":
|
||||||
|
| body |
|
||||||
|
| This is a dra |
|
||||||
|
And IMAP client "1" sees 1 messages in "Drafts"
|
||||||
|
|
||||||
Scenario: Draft edited locally
|
Scenario: Draft edited locally
|
||||||
When IMAP client "1" marks message 1 as deleted
|
When IMAP client "1" marks message 1 as deleted
|
||||||
|
|||||||
@ -33,6 +33,7 @@ import (
|
|||||||
"github.com/emersion/go-imap"
|
"github.com/emersion/go-imap"
|
||||||
id "github.com/emersion/go-imap-id"
|
id "github.com/emersion/go-imap-id"
|
||||||
"github.com/emersion/go-imap/client"
|
"github.com/emersion/go-imap/client"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -280,7 +281,9 @@ func (s *scenario) imapClientSeesTheFollowingMessagesInMailbox(clientID, mailbox
|
|||||||
|
|
||||||
func (s *scenario) imapClientEventuallySeesTheFollowingMessagesInMailbox(clientID, mailbox string, table *godog.Table) error {
|
func (s *scenario) imapClientEventuallySeesTheFollowingMessagesInMailbox(clientID, mailbox string, table *godog.Table) error {
|
||||||
return eventually(func() error {
|
return eventually(func() error {
|
||||||
return s.imapClientSeesTheFollowingMessagesInMailbox(clientID, mailbox, table)
|
err := s.imapClientSeesTheFollowingMessagesInMailbox(clientID, mailbox, table)
|
||||||
|
logrus.WithError(err).Trace("Matching eventually")
|
||||||
|
return err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -144,7 +144,7 @@ func matchMessages(have, want []Message) error {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if !IsSub(ToAny(have), ToAny(want)) {
|
if !IsSub(ToAny(have), ToAny(want)) {
|
||||||
return fmt.Errorf("missing messages: have %+v, want %+v", have, want)
|
return fmt.Errorf("missing messages: have %#v, want %#v", have, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -238,7 +238,7 @@ func (s *scenario) addressDraftChanged(draftIndex int, address, username string,
|
|||||||
|
|
||||||
draftID := s.t.getDraftID(username, draftIndex)
|
draftID := s.t.getDraftID(username, draftIndex)
|
||||||
|
|
||||||
encBody := []byte{}
|
encBody := ""
|
||||||
|
|
||||||
if wantMessages[0].Body != "" {
|
if wantMessages[0].Body != "" {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
@ -247,8 +247,12 @@ func (s *scenario) addressDraftChanged(draftIndex int, address, username string,
|
|||||||
if err := s.t.withClient(ctx, username, func(ctx context.Context, c *proton.Client) error {
|
if err := s.t.withClient(ctx, username, func(ctx context.Context, c *proton.Client) error {
|
||||||
return s.t.withAddrKR(ctx, c, username, s.t.getUserAddrID(s.t.getUserID(username), address),
|
return s.t.withAddrKR(ctx, c, username, s.t.getUserAddrID(s.t.getUserID(username), address),
|
||||||
func(ctx context.Context, addrKR *crypto.KeyRing) error {
|
func(ctx context.Context, addrKR *crypto.KeyRing) error {
|
||||||
var err error
|
msg, err := addrKR.Encrypt(crypto.NewPlainMessage([]byte(wantMessages[0].Body)), addrKR)
|
||||||
encBody, err = proton.EncryptRFC822(addrKR, wantMessages[0].Build())
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
encBody, err = msg.GetArmored()
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@ -258,7 +262,7 @@ func (s *scenario) addressDraftChanged(draftIndex int, address, username string,
|
|||||||
|
|
||||||
changes := proton.DraftTemplate{
|
changes := proton.DraftTemplate{
|
||||||
Subject: wantMessages[0].Subject,
|
Subject: wantMessages[0].Subject,
|
||||||
Body: string(encBody),
|
Body: encBody,
|
||||||
}
|
}
|
||||||
if wantMessages[0].To != "" {
|
if wantMessages[0].To != "" {
|
||||||
changes.ToList = []*mail.Address{{Address: wantMessages[0].To}}
|
changes.ToList = []*mail.Address{{Address: wantMessages[0].To}}
|
||||||
|
|||||||
Reference in New Issue
Block a user