From c5eb660315f7383c031f73fdf2d4725402ab308e Mon Sep 17 00:00:00 2001 From: Jakub Date: Fri, 16 Apr 2021 08:32:51 +0200 Subject: [PATCH] Other: fix live test: API sanitize timestamp --- test/features/bridge/imap/message/fetch.feature | 7 ++++--- test/store_setup_test.go | 11 ++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/test/features/bridge/imap/message/fetch.feature b/test/features/bridge/imap/message/fetch.feature index 29986fa9..c1a34f3c 100644 --- a/test/features/bridge/imap/message/fetch.feature +++ b/test/features/bridge/imap/message/fetch.feature @@ -69,8 +69,9 @@ Feature: IMAP fetch messages 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 "Date: Fri, 13 Aug 1982" - And IMAP response contains "X-Original-Date: Sun, 20 Jul 1969" + 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 "Date: Thu, 01 Jan 1970" + And IMAP response does not contain "\nDate: Thu, 01 Jan 1970" diff --git a/test/store_setup_test.go b/test/store_setup_test.go index f522d5cd..f5363db2 100644 --- a/test/store_setup_test.go +++ b/test/store_setup_test.go @@ -115,7 +115,7 @@ func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bdd if column == "deleted" { hasDeletedFlag = cell.Value == "true" } - err := processMessageTableCell(column, cell.Value, account.Username(), message, header) + err := processMessageTableCell(column, cell.Value, account.Username(), message, &header) if err != nil { return err } @@ -151,7 +151,7 @@ func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bdd return nil } -func processMessageTableCell(column, cellValue, username string, message *pmapi.Message, header textproto.MIMEHeader) error { +func processMessageTableCell(column, cellValue, username string, message *pmapi.Message, header *textproto.MIMEHeader) error { switch column { case "deleted", "id": // it is processed in the main function case "from": @@ -187,8 +187,13 @@ func processMessageTableCell(column, cellValue, username string, message *pmapi. if err != nil { return internalError(err, "parsing time") } - message.Time = date.Unix() header.Set("Date", date.Format(time.RFC1123Z)) + // API will sanitize the date to not have negative timestamp + if date.After(time.Unix(0, 0)) { + message.Time = date.Unix() + } else { + message.Time = 0 + } case "n attachments": numAttachments, err := strconv.Atoi(cellValue) if err != nil {