mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2026-02-10 11:08:33 +00:00
GODT-213: Complex external encrypted tests (multipart/alternative, message/rfc822 attachment)
This commit is contained in:
@ -326,6 +326,132 @@ func TestBuildSignedHTMLEncryptedMessageWithPubKey(t *testing.T) {
|
||||
expectContentDispositionParam(`filename`, is(`OpenPGP_signature`))
|
||||
}
|
||||
|
||||
func TestBuildSignedMultipartAlternativeEncryptedMessageWithPubKey(t *testing.T) {
|
||||
m := gomock.NewController(t)
|
||||
defer m.Finish()
|
||||
|
||||
b := NewBuilder(1, 1, 1)
|
||||
defer b.Done()
|
||||
|
||||
body := readerToString(getFileReader("pgp-mime-body-signed-multipart-alternative-with-pubkey.eml"))
|
||||
|
||||
kr := tests.MakeKeyRing(t)
|
||||
msg := newTestMessage(t, kr, "messageID", "addressID", "multipart/mixed", body, time.Date(2020, time.January, 1, 0, 0, 0, 0, time.UTC))
|
||||
|
||||
res, err := b.NewJob(context.Background(), newTestFetcher(m, kr, msg), msg.ID).GetResult()
|
||||
require.NoError(t, err)
|
||||
|
||||
section(t, res).
|
||||
expectContentType(is(`multipart/mixed`)).
|
||||
expectDate(is(`Wed, 01 Jan 2020 00:00:00 +0000`))
|
||||
|
||||
section(t, res, 1).
|
||||
expectContentType(is(`multipart/signed`)).
|
||||
expectContentTypeParam(`micalg`, is(`pgp-sha256`)).
|
||||
expectContentTypeParam(`protocol`, is(`application/pgp-signature`))
|
||||
|
||||
section(t, res, 1, 1).
|
||||
expectContentType(is(`multipart/mixed`)).
|
||||
expectContentTypeParam(`protected-headers`, is(`v1`)).
|
||||
expectHeader(`Subject`, is(`Alternative`)).
|
||||
expectHeader(`From`, is(`"pm.bridge.qa" <pm.bridge.qa@gmail.com>`)).
|
||||
expectHeader(`To`, is(`schizofrenic@pm.me`)).
|
||||
expectSection(verifiesAgainst(section(t, res, 1, 1, 1, 3).pubKey(), section(t, res, 1, 2).signature()))
|
||||
|
||||
section(t, res, 1, 1, 1).
|
||||
expectContentType(is(`multipart/mixed`))
|
||||
|
||||
section(t, res, 1, 1, 1, 1).
|
||||
expectContentType(is(`multipart/alternative`))
|
||||
|
||||
section(t, res, 1, 1, 1, 1, 1).
|
||||
expectContentType(is(`text/plain`)).
|
||||
expectBody(contains(`This Rich formated text`)).
|
||||
expectBody(contains(`What kind of shoes do ninjas wear`)).
|
||||
expectBody(contains(`How does a penguin build its house`))
|
||||
|
||||
section(t, res, 1, 1, 1, 1, 2).
|
||||
expectContentType(is(`text/html`)).
|
||||
expectBody(contains(`This <font color="#ee24cc">Rich</font> formated text`)).
|
||||
expectBody(contains(`What kind of shoes do ninjas wear`)).
|
||||
expectBody(contains(`How does a penguin build its house`))
|
||||
|
||||
section(t, res, 1, 1, 1, 2).
|
||||
expectContentType(is(`application/pdf`)).
|
||||
expectTransferEncoding(is(`base64`)).
|
||||
expectContentTypeParam(`name`, is(`minimal.pdf`)).
|
||||
expectContentDispositionParam(`filename`, is(`minimal.pdf`))
|
||||
|
||||
section(t, res, 1, 1, 1, 3).
|
||||
expectContentType(is(`application/pgp-keys`)).
|
||||
expectContentTypeParam(`name`, is(`OpenPGP_0x161C0875822359F7.asc`)).
|
||||
expectContentDisposition(is(`attachment`)).
|
||||
expectContentDispositionParam(`filename`, is(`OpenPGP_0x161C0875822359F7.asc`))
|
||||
|
||||
section(t, res, 1, 2).
|
||||
expectContentType(is(`application/pgp-signature`)).
|
||||
expectContentTypeParam(`name`, is(`OpenPGP_signature.asc`)).
|
||||
expectContentDisposition(is(`attachment`)).
|
||||
expectContentDispositionParam(`filename`, is(`OpenPGP_signature`))
|
||||
}
|
||||
|
||||
func TestBuildSignedEmbeddedMessageRFC822EncryptedMessageWithPubKey(t *testing.T) {
|
||||
m := gomock.NewController(t)
|
||||
defer m.Finish()
|
||||
|
||||
b := NewBuilder(1, 1, 1)
|
||||
defer b.Done()
|
||||
|
||||
body := readerToString(getFileReader("pgp-mime-body-signed-embedded-message-rfc822-with-pubkey.eml"))
|
||||
|
||||
kr := tests.MakeKeyRing(t)
|
||||
msg := newTestMessage(t, kr, "messageID", "addressID", "multipart/mixed", body, time.Date(2020, time.January, 1, 0, 0, 0, 0, time.UTC))
|
||||
|
||||
res, err := b.NewJob(context.Background(), newTestFetcher(m, kr, msg), msg.ID).GetResult()
|
||||
require.NoError(t, err)
|
||||
|
||||
section(t, res).
|
||||
expectContentType(is(`multipart/mixed`)).
|
||||
expectDate(is(`Wed, 01 Jan 2020 00:00:00 +0000`))
|
||||
|
||||
section(t, res, 1).
|
||||
expectContentType(is(`multipart/signed`)).
|
||||
expectContentTypeParam(`micalg`, is(`pgp-sha256`)).
|
||||
expectContentTypeParam(`protocol`, is(`application/pgp-signature`))
|
||||
|
||||
section(t, res, 1, 1).
|
||||
expectContentType(is(`multipart/mixed`)).
|
||||
expectContentTypeParam(`protected-headers`, is(`v1`)).
|
||||
expectHeader(`Subject`, is(`Fwd: HTML with attachment external PGP`)).
|
||||
expectHeader(`From`, is(`"pm.bridge.qa" <pm.bridge.qa@gmail.com>`)).
|
||||
expectHeader(`To`, is(`schizofrenic@pm.me`)).
|
||||
expectSection(verifiesAgainst(section(t, res, 1, 1, 1, 2).pubKey(), section(t, res, 1, 2).signature()))
|
||||
|
||||
section(t, res, 1, 1, 1).
|
||||
expectContentType(is(`multipart/mixed`))
|
||||
|
||||
section(t, res, 1, 1, 1, 1).
|
||||
expectContentType(is(`text/plain`))
|
||||
|
||||
section(t, res, 1, 1, 1, 2).
|
||||
expectContentType(is(`application/pgp-keys`)).
|
||||
expectContentTypeParam(`name`, is(`OpenPGP_0x161C0875822359F7.asc`)).
|
||||
expectContentDisposition(is(`attachment`)).
|
||||
expectContentDispositionParam(`filename`, is(`OpenPGP_0x161C0875822359F7.asc`))
|
||||
|
||||
section(t, res, 1, 1, 1, 3).
|
||||
expectContentType(is(`message/rfc822`)).
|
||||
expectContentTypeParam(`name`, is(`HTML with attachment external PGP.eml`)).
|
||||
expectContentDisposition(is(`attachment`)).
|
||||
expectContentDispositionParam(`filename`, is(`HTML with attachment external PGP.eml`))
|
||||
|
||||
section(t, res, 1, 2).
|
||||
expectContentType(is(`application/pgp-signature`)).
|
||||
expectContentTypeParam(`name`, is(`OpenPGP_signature.asc`)).
|
||||
expectContentDisposition(is(`attachment`)).
|
||||
expectContentDispositionParam(`filename`, is(`OpenPGP_signature`))
|
||||
}
|
||||
|
||||
func TestBuildHTMLMessageWithAttachment(t *testing.T) {
|
||||
m := gomock.NewController(t)
|
||||
defer m.Finish()
|
||||
|
||||
Reference in New Issue
Block a user