GODT-1804: Add parsing ics attachment test.

This commit is contained in:
Romain LE JEUNE
2022-11-28 09:01:10 +01:00
parent 5ae8d274c0
commit f355cb4d38
2 changed files with 34 additions and 0 deletions

View File

@ -605,6 +605,26 @@ func TestParseMessageReferencesComma(t *testing.T) {
}) })
} }
func TestParseIcsAttachment(t *testing.T) {
f := getFileReader("ics_attachment.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, "body", string(m.RichBody))
assert.Equal(t, "body", string(m.PlainBody))
require.Len(t, m.Attachments, 1)
assert.Equal(t, m.Attachments[0].MIMEType, "text/calendar")
assert.Equal(t, m.Attachments[0].Name, "invite.ics")
assert.Equal(t, m.Attachments[0].ContentID, "")
assert.Equal(t, m.Attachments[0].Disposition, "attachment")
assert.Equal(t, string(m.Attachments[0].Data), "This is an ics calendar invite")
}
func TestParsePanic(t *testing.T) { func TestParsePanic(t *testing.T) {
var err error var err error
require.NotPanics(t, func() { require.NotPanics(t, func() {

14
pkg/message/testdata/ics_attachment.eml vendored Normal file
View File

@ -0,0 +1,14 @@
From: Sender <sender@pm.me>
To: Receiver <receiver@pm.me>
Content-Type: multipart/mixed; boundary=longrandomstring
--longrandomstring
body
--longrandomstring
Content-Type: text/calendar; charset=utf-8; method=REQUEST; name=invite.ics'
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; filename=invite.ics
VGhpcyBpcyBhbiBpY3MgY2FsZW5kYXIgaW52aXRl
--longrandomstring--