fix(GODT-2464): Filter attachment name from content-type parameter to not send it twice to the API.

This commit is contained in:
Romain Le Jeune
2023-05-02 07:13:21 +00:00
parent 50709acc5f
commit 543c35041d
7 changed files with 255 additions and 0 deletions

View File

@ -673,6 +673,40 @@ func TestParsePanic(t *testing.T) {
require.Error(t, err)
}
func TestParseTextPlainWithPdfttachmentCyrillic(t *testing.T) {
f := getFileReader("text_plain_pdf_attachment_cyrillic.eml")
m, err := Parse(f)
require.NoError(t, err)
assert.Equal(t, `"Sender" <sender@pm.me>`, m.Sender.String())
assert.Equal(t, `"Receiver" <receiver@pm.me>`, m.ToList[0].String())
assert.Equal(t, "Shake that body", string(m.RichBody))
assert.Equal(t, "Shake that body", string(m.PlainBody))
require.Len(t, m.Attachments, 1)
require.Equal(t, "application/pdf", m.Attachments[0].MIMEType)
assert.Equal(t, "АБВГДЃЕЖЗЅИЈКЛЉМНЊОПРСТЌУФХЧЏЗШ.pdf", m.Attachments[0].Name)
}
func TestParseTextPlainWithDocxAttachmentCyrillic(t *testing.T) {
f := getFileReader("text_plain_docx_attachment_cyrillic.eml")
m, err := Parse(f)
require.NoError(t, err)
assert.Equal(t, `"Sender" <sender@pm.me>`, m.Sender.String())
assert.Equal(t, `"Receiver" <receiver@pm.me>`, m.ToList[0].String())
assert.Equal(t, "Shake that body", string(m.RichBody))
assert.Equal(t, "Shake that body", string(m.PlainBody))
require.Len(t, m.Attachments, 1)
require.Equal(t, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", m.Attachments[0].MIMEType)
assert.Equal(t, "АБВГДЃЕЖЗЅИЈКЛЉМНЊОПРСТЌУФХЧЏЗШ.docx", m.Attachments[0].Name)
}
func getFileReader(filename string) io.Reader {
f, err := os.Open(filepath.Join("testdata", filename))
if err != nil {