GODT-2170: Improving test server behaviour.

This commit is contained in:
Jakub
2022-12-01 15:52:42 +01:00
committed by James Houlahan
parent 828fe0e86e
commit 8408a5fdc0
9 changed files with 36 additions and 16 deletions

View File

@ -27,6 +27,7 @@ Feature: IMAP create messages
And IMAP client "1" eventually sees the following messages in "Drafts":
| from | to | subject | body |
| user@pm.me | john.doe@email.com | foo | bar |
# This fails now
And IMAP client "1" eventually sees the following messages in "All Mail":
| from | to | subject | body |
| user@pm.me | john.doe@email.com | foo | bar |

View File

@ -11,6 +11,10 @@ Feature: IMAP Draft messages
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
When IMAP client "1" marks message 1 as deleted

View File

@ -33,6 +33,7 @@ import (
"github.com/emersion/go-imap"
id "github.com/emersion/go-imap-id"
"github.com/emersion/go-imap/client"
"github.com/sirupsen/logrus"
"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 {
return eventually(func() error {
return s.imapClientSeesTheFollowingMessagesInMailbox(clientID, mailbox, table)
err := s.imapClientSeesTheFollowingMessagesInMailbox(clientID, mailbox, table)
logrus.WithError(err).Trace("Matching eventually")
return err
})
}

View File

@ -144,7 +144,7 @@ func matchMessages(have, want []Message) error {
})
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

View File

@ -238,7 +238,7 @@ func (s *scenario) addressDraftChanged(draftIndex int, address, username string,
draftID := s.t.getDraftID(username, draftIndex)
encBody := []byte{}
encBody := ""
if wantMessages[0].Body != "" {
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 {
return s.t.withAddrKR(ctx, c, username, s.t.getUserAddrID(s.t.getUserID(username), address),
func(ctx context.Context, addrKR *crypto.KeyRing) error {
var err error
encBody, err = proton.EncryptRFC822(addrKR, wantMessages[0].Build())
msg, err := addrKR.Encrypt(crypto.NewPlainMessage([]byte(wantMessages[0].Body)), addrKR)
if err != nil {
return err
}
encBody, err = msg.GetArmored()
return err
})
}); err != nil {
@ -258,7 +262,7 @@ func (s *scenario) addressDraftChanged(draftIndex int, address, username string,
changes := proton.DraftTemplate{
Subject: wantMessages[0].Subject,
Body: string(encBody),
Body: encBody,
}
if wantMessages[0].To != "" {
changes.ToList = []*mail.Address{{Address: wantMessages[0].To}}