mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-18 16:17:03 +00:00
GODT-1804: Add parsing ics attachment test.
This commit is contained in:
@ -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
14
pkg/message/testdata/ics_attachment.eml
vendored
Normal 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--
|
||||||
Reference in New Issue
Block a user