Other: fix live test: API sanitize timestamp

This commit is contained in:
Jakub
2021-04-16 08:32:51 +02:00
parent 5ad23715ec
commit c5eb660315
2 changed files with 12 additions and 6 deletions

View File

@ -69,8 +69,9 @@ Feature: IMAP fetch messages
And there is IMAP client selected in "Folders/mbox" And there is IMAP client selected in "Folders/mbox"
When IMAP client sends command "FETCH 1:* rfc822" When IMAP client sends command "FETCH 1:* rfc822"
Then IMAP response is "OK" Then IMAP response is "OK"
And IMAP response contains "Date: Fri, 13 Aug 1982" And IMAP response contains "\nDate: Fri, 13 Aug 1982"
And IMAP response contains "X-Original-Date: Sun, 20 Jul 1969" 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 # We had bug to incorectly set empty date, so let's make sure
# there is no reference anywhere in the response. # 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"

View File

@ -115,7 +115,7 @@ func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bdd
if column == "deleted" { if column == "deleted" {
hasDeletedFlag = cell.Value == "true" 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 { if err != nil {
return err return err
} }
@ -151,7 +151,7 @@ func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bdd
return nil 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 { switch column {
case "deleted", "id": // it is processed in the main function case "deleted", "id": // it is processed in the main function
case "from": case "from":
@ -187,8 +187,13 @@ func processMessageTableCell(column, cellValue, username string, message *pmapi.
if err != nil { if err != nil {
return internalError(err, "parsing time") return internalError(err, "parsing time")
} }
message.Time = date.Unix()
header.Set("Date", date.Format(time.RFC1123Z)) 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": case "n attachments":
numAttachments, err := strconv.Atoi(cellValue) numAttachments, err := strconv.Atoi(cellValue)
if err != nil { if err != nil {