From fcbf63e62c627deae76c1b8cb8c0876c536ed811 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 16 Mar 2020 18:49:26 +0900 Subject: Fresh start --- .../test/net/imap/test_imap_response_parser.rb | 292 +++++++++++++++++++++ 1 file changed, 292 insertions(+) create mode 100644 jni/ruby/test/net/imap/test_imap_response_parser.rb (limited to 'jni/ruby/test/net/imap/test_imap_response_parser.rb') diff --git a/jni/ruby/test/net/imap/test_imap_response_parser.rb b/jni/ruby/test/net/imap/test_imap_response_parser.rb new file mode 100644 index 0000000..1612d78 --- /dev/null +++ b/jni/ruby/test/net/imap/test_imap_response_parser.rb @@ -0,0 +1,292 @@ +require "net/imap" +require "test/unit" + +class IMAPResponseParserTest < Test::Unit::TestCase + def setup + @do_not_reverse_lookup = Socket.do_not_reverse_lookup + Socket.do_not_reverse_lookup = true + if Net::IMAP.respond_to?(:max_flag_count) + @max_flag_count = Net::IMAP.max_flag_count + Net::IMAP.max_flag_count = 3 + end + end + + def teardown + Socket.do_not_reverse_lookup = @do_not_reverse_lookup + if Net::IMAP.respond_to?(:max_flag_count) + Net::IMAP.max_flag_count = @max_flag_count + end + end + + def test_flag_list_safe + parser = Net::IMAP::ResponseParser.new + response = lambda { + $SAFE = 1 + parser.parse(< +Envelope-to: info@xxxxxxxx.si +Delivery-date: Tue, 26 Mar 2013 12:42:58 +0100 +Received: from mail by xxxx.xxxxxxxxxxx.net with spam-scanned (Exim 4.76) + id 1UKSHI-000Cwl-AR + for info@xxxxxxxx.si; Tue, 26 Mar 2013 12:42:58 +0100 +X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on xxxx.xxxxxxxxxxx.net +X-Spam-Level: ** +X-Spam-Status: No, score=2.1 required=7.0 tests=DKIM_ADSP_NXDOMAIN,RDNS_NONE + autolearn=no version=3.3.1 +Received: from [xx.xxx.xxx.xx] (port=56890 helo=xxxxxx.localdomain) + by xxxx.xxxxxxxxxxx.net with esmtp (Exim 4.76) + id 1UKSHI-000Cwi-9j + for info@xxxxxxxx.si; Tue, 26 Mar 2013 12:42:56 +0100 +Received: by xxxxxx.localdomain (Postfix) + id 72725BEA64A; Tue, 26 Mar 2013 12:42:55 +0100 (CET) +Date: Tue, 26 Mar 2013 12:42:55 +0100 (CET) +From: MAILER-DAEMON@xxxxxx.localdomain (Mail Delivery System) +Subject: Undelivered Mail Returned to Sender +To: info@xxxxxxxx.si +Auto-Submitted: auto-replied +MIME-Version: 1.0 +Content-Type: multipart/report; report-type=delivery-status; + boundary="27797BEA649.1364298175/xxxxxx.localdomain" +Message-Id: <20130326114255.72725BEA64A@xxxxxx.localdomain> + + BODYSTRUCTURE (("text" "plain" ("charset" "us-ascii") NIL "Notification" "7bit" 510 14 NIL NIL NIL NIL)("message" "delivery-status" NIL NIL "Delivery report" "7bit" 410 NIL NIL NIL NIL)("text" "rfc822-headers" ("charset" "us-ascii") NIL "Undelivered Message Headers" "7bit" 612 15 NIL NIL NIL NIL) "report" ("report-type" "delivery-status" "boundary" "27797BEA649.1364298175/xxxxxx.localdomain") NIL NIL NIL)) +EOF + delivery_status = response.data.attr["BODYSTRUCTURE"].parts[1] + assert_equal("MESSAGE", delivery_status.media_type) + assert_equal("DELIVERY-STATUS", delivery_status.subtype) + assert_equal(nil, delivery_status.param) + assert_equal(nil, delivery_status.content_id) + assert_equal("Delivery report", delivery_status.description) + assert_equal("7BIT", delivery_status.encoding) + assert_equal(410, delivery_status.size) + end + + # [Bug #8281] + def test_acl + parser = Net::IMAP::ResponseParser.new + response = parser.parse(<\" " \ + "\"\")" \ + " (\"MIXED\" (\"BOUNDARY\" \"000e0cd29212e3e06a0486590ae2\") NIL NIL)" \ + " 37 NIL NIL NIL)" \ + " \"REPORT\" (\"BOUNDARY\" \"16DuG.4XbaNOvCi.9ggvq.8Ipnyp3\" \"REPORT-TYPE\" \"delivery-status\") NIL NIL))\r\n") + empty_part = response.data.attr['BODYSTRUCTURE'].parts[2] + assert_equal(empty_part.lines, 37) + assert_equal(empty_part.body.media_type, 'MULTIPART') + assert_equal(empty_part.body.subtype, 'MIXED') + assert_equal(empty_part.body.param['BOUNDARY'], '000e0cd29212e3e06a0486590ae2') + end + + # [Bug #10112] + def test_search_modseq + parser = Net::IMAP::ResponseParser.new + response = parser.parse("* SEARCH 87216 87221 (MODSEQ 7667567)\r\n") + assert_equal("SEARCH", response.name) + assert_equal([87216, 87221], response.data) + end + + # [Bug #11128] + def test_body_ext_mpart_without_lang + parser = Net::IMAP::ResponseParser.new + response = parser.parse("* 4 FETCH (BODY (((\"text\" \"plain\" (\"charset\" \"utf-8\") NIL NIL \"7bit\" 257 9 NIL NIL NIL NIL)(\"text\" \"html\" (\"charset\" \"utf-8\") NIL NIL \"quoted-printable\" 655 9 NIL NIL NIL NIL) \"alternative\" (\"boundary\" \"001a1137a5047848dd05157ddaa1\") NIL)(\"application\" \"pdf\" (\"name\" \"test.xml\" \"x-apple-part-url\" \"9D00D9A2-98AB-4EFB-85BA-FB255F8BF3D7\") NIL NIL \"base64\" 4383638 NIL (\"attachment\" (\"filename\" \"test.xml\")) NIL NIL) \"mixed\" (\"boundary\" \"001a1137a5047848e405157ddaa3\") NIL))\r\n") + assert_equal("FETCH", response.name) + body = response.data.attr["BODY"] + assert_equal(nil, body.parts[0].disposition) + assert_equal(nil, body.parts[0].language) + assert_equal("ATTACHMENT", body.parts[1].disposition.dsp_type) + assert_equal("test.xml", body.parts[1].disposition.param["FILENAME"]) + assert_equal(nil, body.parts[1].language) + end +end -- cgit v1.2.3