X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2FT190-multipart.sh;h=91a632c6698ed1362421f8c33452ea8d73696d45;hp=a97dc282f10659c1dfd605a2249eeb1f7bf88287;hb=3805898e3e337768d13b223a40b0ea76da73657e;hpb=0829bd4e5da82a14e003f4036592913adb00e243 diff --git a/test/T190-multipart.sh b/test/T190-multipart.sh index a97dc282..91a632c6 100755 --- a/test/T190-multipart.sh +++ b/test/T190-multipart.sh @@ -1,15 +1,8 @@ #!/usr/bin/env bash test_description="output of multipart message" -. ./test-lib.sh +. ./test-lib.sh || exit 1 -cat < embedded_message -From: Carl Worth -To: cworth@cworth.org -Subject: html message -Date: Fri, 05 Jan 2001 15:42:57 +0000 -User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu) -Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org> -MIME-Version: 1.0 +cat < embedded_message_body Content-Type: multipart/alternative; boundary="==-=-==" --==-=-== @@ -24,15 +17,19 @@ This is an embedded message, with a multipart/alternative part. --==-=-==-- EOF - -cat < ${MAIL_DIR}/multipart +cat < embedded_message From: Carl Worth To: cworth@cworth.org -Subject: Multipart message -Date: Fri, 05 Jan 2001 15:43:57 +0000 +Subject: html message +Date: Fri, 05 Jan 2001 15:42:57 +0000 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu) -Message-ID: <87liy5ap00.fsf@yoom.home.cworth.org> +Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org> MIME-Version: 1.0 +EOF + +cat embedded_message_body >> embedded_message + +cat < multipart_body Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" @@ -44,8 +41,9 @@ Content-Type: message/rfc822 Content-Disposition: inline EOF -cat embedded_message >> ${MAIL_DIR}/multipart -cat <> ${MAIL_DIR}/multipart + +cat embedded_message >> multipart_body +cat <> multipart_body --=-=-= Content-Disposition: attachment; filename=attachment @@ -73,6 +71,18 @@ W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE --==-=-=-- EOF +cat < ${MAIL_DIR}/multipart +From: Carl Worth +To: cworth@cworth.org +Subject: Multipart message +Date: Fri, 05 Jan 2001 15:43:57 +0000 +User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu) +Message-ID: <87liy5ap00.fsf@yoom.home.cworth.org> +MIME-Version: 1.0 +EOF + +cat multipart_body >> ${MAIL_DIR}/multipart + cat < ${MAIL_DIR}/base64-part-with-crlf From: Carl Worth To: cworth@cworth.org @@ -178,7 +188,7 @@ Non-text part: application/pgp-signature body} message} EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=text --part=1, message body" notmuch show --format=text --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -217,7 +227,7 @@ Non-text part: application/pgp-signature part} part} EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=text --part=2, multipart/mixed" notmuch show --format=text --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -251,7 +261,7 @@ And this message is signed. part} part} EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=text --part=3, rfc822 part" notmuch show --format=text --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -275,7 +285,7 @@ This is an embedded message, with a multipart/alternative part. body} part} EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=text --part=4, rfc822's multipart" notmuch show --format=text --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -289,7 +299,7 @@ This is an embedded message, with a multipart/alternative part. part} part} EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=text --part=5, rfc822's html part" notmuch show --format=text --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -298,7 +308,7 @@ cat <EXPECTED Non-text part: text/html part} EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=text --part=6, rfc822's text part" notmuch show --format=text --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -307,7 +317,7 @@ cat <EXPECTED This is an embedded message, with a multipart/alternative part. part} EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=text --part=7, inline attachement" notmuch show --format=text --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -316,7 +326,7 @@ cat <EXPECTED This is a text attachment. attachment} EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=text --part=8, plain text part" notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -327,7 +337,7 @@ And this message is signed. -Carl part} EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=text --part=9, pgp signature (unverified)" notmuch show --format=text --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -336,23 +346,22 @@ cat <EXPECTED Non-text part: application/pgp-signature part} EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT -test_expect_success \ - "--format=text --part=8, no part, expect error" \ - "notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'" +test_begin_subtest "--format=text --part=8, no part, expect error" +test_expect_success "notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'" test_begin_subtest "--format=json --part=0, full message" notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT cat <EXPECTED -{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "excluded": false, "filename": "${MAIL_DIR}/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [ +{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "excluded": false, "filename": ["${MAIL_DIR}/multipart"], "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [ {"id": 1, "content-type": "multipart/signed", "content": [ {"id": 2, "content-type": "multipart/mixed", "content": [ -{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ +{"id": 3, "content-type": "message/rfc822", "content-disposition": "inline", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 5, "content-type": "text/html", "content-length": 71}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, -{"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, +{"id": 7, "content-type": "text/plain", "content-disposition": "attachment", "filename": "attachment", "content": "This is a text attachment.\n"}, {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, {"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}]} EOF @@ -363,11 +372,11 @@ notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OU cat <EXPECTED {"id": 1, "content-type": "multipart/signed", "content": [ {"id": 2, "content-type": "multipart/mixed", "content": [ -{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ +{"id": 3, "content-type": "message/rfc822", "content-disposition": "inline", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 5, "content-type": "text/html", "content-length": 71}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, -{"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, +{"id": 7, "content-type": "text/plain", "content-disposition": "attachment", "filename": "attachment", "content": "This is a text attachment.\n"}, {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, {"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]} EOF @@ -377,11 +386,11 @@ test_begin_subtest "--format=json --part=2, multipart/mixed" notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT cat <EXPECTED {"id": 2, "content-type": "multipart/mixed", "content": [ -{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ +{"id": 3, "content-type": "message/rfc822", "content-disposition": "inline", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 5, "content-type": "text/html", "content-length": 71}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, -{"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, +{"id": 7, "content-type": "text/plain", "content-disposition": "attachment", "filename": "attachment", "content": "This is a text attachment.\n"}, {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]} EOF test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" @@ -389,7 +398,7 @@ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" test_begin_subtest "--format=json --part=3, rfc822 part" notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT cat <EXPECTED -{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ +{"id": 3, "content-type": "message/rfc822", "content-disposition": "inline", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 5, "content-type": "text/html", "content-length": 71}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]} @@ -422,7 +431,11 @@ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" test_begin_subtest "--format=json --part=7, inline attachment" notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT cat <EXPECTED -{"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"} +{"id": 7, + "content-type": "text/plain", + "filename": "attachment", + "content": "This is a text attachment.\n", + "content-disposition": "attachment"} EOF test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" @@ -440,21 +453,20 @@ cat <EXPECTED EOF test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" -test_expect_success \ - "--format=json --part=10, no part, expect error" \ - "notmuch show --format=json --part=10 'id:87liy5ap00.fsf@yoom.home.cworth.org'" +test_begin_subtest "--format=json --part=10, no part, expect error" +test_expect_success "notmuch show --format=json --part=10 'id:87liy5ap00.fsf@yoom.home.cworth.org'" test_begin_subtest "--format=raw" notmuch show --format=raw 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT -test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart +test_expect_equal_file "${MAIL_DIR}"/multipart OUTPUT test_begin_subtest "--format=raw --part=0, full message" notmuch show --format=raw --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT -test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart +test_expect_equal_file "${MAIL_DIR}"/multipart OUTPUT test_begin_subtest "--format=raw --part=1, message body" notmuch show --format=raw --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT -test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart +test_expect_equal_file "${MAIL_DIR}"/multipart OUTPUT test_begin_subtest "--format=raw --part=2, multipart/mixed" notmuch show --format=raw --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -499,11 +511,11 @@ And this message is signed. --=-=-=-- EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=raw --part=3, rfc822 part" notmuch show --format=raw --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT -test_expect_equal_file OUTPUT embedded_message +test_expect_equal_file embedded_message OUTPUT test_begin_subtest "--format=raw --part=4, rfc822's multipart" notmuch show --format=raw --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -529,28 +541,28 @@ This is an embedded message, with a multipart/alternative part. --==-=-==-- EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=raw --part=5, rfc822's html part" notmuch show --format=raw --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT cat <EXPECTED

This is an embedded message, with a multipart/alternative part.

EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=raw --part=6, rfc822's text part" notmuch show --format=raw --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT cat <EXPECTED This is an embedded message, with a multipart/alternative part. EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=raw --part=7, inline attachment" notmuch show --format=raw --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT cat <EXPECTED This is a text attachment. EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=raw --part=8, plain text part" notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -559,7 +571,7 @@ And this message is signed. -Carl EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--format=raw --part=9, pgp signature (unverified)" notmuch show --format=raw --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -574,11 +586,10 @@ W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE =zkga -----END PGP SIGNATURE----- EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT -test_expect_success \ - "--format=raw --part=10, no part, expect error" \ - "notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'" +test_begin_subtest "--format=raw --part=10, no part, expect error" +test_expect_success "notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'" test_begin_subtest "--format=mbox" notmuch show --format=mbox 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -586,11 +597,10 @@ printf "From cworth@cworth.org Fri Jan 5 15:43:57 2001\n" >EXPECTED cat "${MAIL_DIR}"/multipart >>EXPECTED # mbox output is expected to include a blank line echo >>EXPECTED -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT -test_expect_success \ - "--format=mbox --part=1, incompatible, expect error" \ - "! notmuch show --format=mbox --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org'" +test_begin_subtest "--format=mbox --part=1, incompatible, expect error" +test_expect_success "! notmuch show --format=mbox --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org'" test_begin_subtest "'notmuch reply' to a multipart message" notmuch reply 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT @@ -614,7 +624,7 @@ Non-text part: text/html > > -Carl EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "'notmuch reply' to a multipart message with json format" notmuch reply --format=json 'id:87liy5ap00.fsf@yoom.home.cworth.org' | notmuch_json_show_sanitize >OUTPUT @@ -627,7 +637,7 @@ notmuch_json_show_sanitize <EXPECTED "original": {"id": "XXXXX", "match": false, "excluded": false, - "filename": "YYYYY", + "filename": ["YYYYY"], "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], @@ -641,6 +651,7 @@ notmuch_json_show_sanitize <EXPECTED "content-type": "multipart/mixed", "content": [{"id": 3, "content-type": "message/rfc822", + "content-disposition": "inline", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth ", "To": "cworth@cworth.org", @@ -655,6 +666,7 @@ notmuch_json_show_sanitize <EXPECTED "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, {"id": 7, "content-type": "text/plain", + "content-disposition": "attachment", "filename": "attachment", "content": "This is a text attachment.\n"}, {"id": 8, @@ -715,7 +727,7 @@ cat_expected_head () cat <", "Subject": "html message", "To": "B "}, @@ -752,18 +764,67 @@ notmuch show --format=json --include-html id:htmlmessage > OUTPUT test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.withhtml)" test_begin_subtest "indexes mime-type #1" -test_subtest_known_broken output=$(notmuch search mimetype:application/unique_identifier | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)" test_begin_subtest "indexes mime-type #2" -test_subtest_known_broken output=$(notmuch search mimetype:text/some_other_identifier | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)" test_begin_subtest "indexes mime-type #3" -test_subtest_known_broken output=$(notmuch search from:todd and mimetype:multipart/alternative | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)" +test_begin_subtest "case of Content-Disposition doesn't matter for indexing" +cat < ${MAIL_DIR}/content-disposition +Return-path: +Envelope-to: david@tethera.net +Delivery-date: Sun, 04 Oct 2015 09:16:03 -0300 +Received: from gitolite.debian.net ([87.98.215.224]) + by yantan.tethera.net with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) + (Exim 4.80) + (envelope-from ) + id 1ZiiCx-0007iz-RK + for david@tethera.net; Sun, 04 Oct 2015 09:16:03 -0300 +Received: from remotemail by gitolite.debian.net with local (Exim 4.80) + (envelope-from ) + id 1ZiiC8-0002Rz-Uf; Sun, 04 Oct 2015 12:15:12 +0000 +Received: (nullmailer pid 28621 invoked by uid 1000); Sun, 04 Oct 2015 + 12:14:53 -0000 +From: David Bremner +To: David Bremner +Subject: test attachment +User-Agent: Notmuch/0.20.2+93~g33c8777 (http://notmuchmail.org) Emacs/24.5.1 + (x86_64-pc-linux-gnu) +Date: Sun, 04 Oct 2015 09:14:53 -0300 +Message-ID: <87io6m96f6.fsf@zancas.localnet> +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="=-=-=" + +--=-=-= +Content-Type: text/plain +Content-Disposition: ATTACHMENT; filename=hello.txt +Content-Description: this is a very exciting file + +hello + +--=-=-= +Content-Type: text/plain + + +world + +--=-=-=-- + +EOF +NOTMUCH_NEW + +cat < EXPECTED +attachment +inbox +unread +EOF + +notmuch search --output=tags id:87io6m96f6.fsf@zancas.localnet > OUTPUT +test_expect_equal_file EXPECTED OUTPUT test_done