From 1d5ee6f4419780409c6d409063794340e5b0e12c Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 23 Jan 2013 14:43:37 +0100 Subject: [PATCH] Improved unit tests. --- test/fixtures/mail14.box | 155 +++++++++++++++++++++++++++++++++ test/unit/email_parser_test.rb | 21 +++++ 2 files changed, 176 insertions(+) create mode 100644 test/fixtures/mail14.box diff --git a/test/fixtures/mail14.box b/test/fixtures/mail14.box new file mode 100644 index 000000000..0317e0cb4 --- /dev/null +++ b/test/fixtures/mail14.box @@ -0,0 +1,155 @@ +Return-Path: +X-Original-To: sales@znuny.com +Delivered-To: znuny-sales@samba.edenhofer.de +Received: from ntserver-1.example.com (ntserver-1.example.com [94.125.78.230]) + by samba.edenhofer.de (Postfix) with ESMTP id 98B43500B14 + for ; Fri, 7 Dec 2012 08:37:49 +0000 (GMT) +Received: from NTEXCHANGE2.example.dom ( [172.17.253.213]) by ntserver-1.example.com + (Reddoxx engine) with SMTP id 9B6345F102; Fri, 7 Dec 2012 09:37:49 +0100 +Received: from NTEXCHANGE3.example.dom ([169.254.2.40]) by NTEXCHANGE2.example.dom + ([169.254.1.165]) with mapi id 14.02.0318.004; Fri, 7 Dec 2012 09:37:48 +0100 +From: =?utf-8?B?TcO8bGxlciwgQmVybmQ=?= +To: 'Martin Edenhofer via Znuny Sales' +Subject: AW: OTRS [Ticket#118192] +Thread-Topic: OTRS [Ticket#118192] +Thread-Index: AQHN0Wlv/YXxN5hYKEuzRN8KaxaKiJgNBfNQ +Date: Fri, 7 Dec 2012 08:37:47 +0000 +Message-ID: +References: + <20121203151518.1594.546768@portal.znuny.com> +In-Reply-To: <20121203151518.1594.546768@portal.znuny.com> +Accept-Language: de-DE, en-US +Content-Language: de-DE +X-MS-Has-Attach: yes +X-MS-TNEF-Correlator: +x-originating-ip: [172.17.253.224] +x-olx-disclaimer: Done +x-tm-as-product-ver: SMEX-10.2.0.2087-7.000.1014-19428.002 +x-tm-as-result: No--27.303800-0.000000-31 +x-tm-as-user-approved-sender: Yes +x-tm-as-user-blocked-sender: No +Content-Type: multipart/mixed; + boundary="_003_EFA59C089DA07740B05CB29190CB4F96474734CANTEXCHANGE3exampled_" +MIME-Version: 1.0 + +--_003_EFA59C089DA07740B05CB29190CB4F96474734CANTEXCHANGE3exampled_ +Content-Type: text/plain; charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +=E4=F6=FC=DF ad asd + +-Martin + +-- +Old programmers never die. They just branch to a new address. + +--_003_EFA59C089DA07740B05CB29190CB4F96474734CANTEXCHANGE3exampled_ +Content-Type: message/rfc822 +Content-Disposition: attachment; + creation-date="Fri, 07 Dec 2012 08:25:56 GMT"; + modification-date="Fri, 07 Dec 2012 08:25:56 GMT" + +Received: from NTEXCHANGE3.example.dom ([172.17.253.64]) by ntexchange.example.dom + with Microsoft SMTPSVC(6.0.3790.4675); Wed, 5 Dec 2012 21:15:07 +0100 +Received: from NTEXCHANGE2.example.dom (172.17.253.213) by NTEXCHANGE3.example.dom + (172.17.253.64) with Microsoft SMTP Server (TLS) id 14.2.318.4; Wed, 5 Dec + 2012 21:15:07 +0100 +Received: from ntserver-1.example.com (172.17.253.224) by NTEXCHANGE2.example.dom + (172.17.253.213) with Microsoft SMTP Server id 14.2.318.4; Wed, 5 Dec 2012 + 21:15:06 +0100 +Received: from ntserver-1.example.com ([192.168.100.117]) by ntserver-1.example.com with + Microsoft SMTPSVC(7.5.7601.17514); Wed, 5 Dec 2012 21:15:05 +0100 +Received: from mailout02.ispamone.de ( [212.211.146.205]) by ntserver-1.example.com + (Reddoxx engine) with SMTP id 56767845A33; Wed, 5 Dec 2012 21:15:05 +0100 +From: "helpdesk@example.com" +To: HelpDesk +Subject: Neue Anfrage erstellt - 33284 +Thread-Topic: Neue Anfrage erstellt - 33284 +Thread-Index: Ac3TJBhe4TPAltHrS6m3GwtF5lDkwA== +Content-Class: urn:content-classes:message +Date: Wed, 5 Dec 2012 20:07:04 +0000 +Message-ID: <174905662.1354738495468.JavaMail.babeldoc@atlas> +Content-Language: de-DE +X-MS-Has-Attach: +X-MS-Exchange-Organization-SCL: 0 +X-MS-TNEF-Correlator: +Content-Type: multipart/alternative; + boundary="_000_1749056621354738495468JavaMailbabeldocatlas_" +MIME-Version: 1.0 + +--_000_1749056621354738495468JavaMailbabeldocatlas_ +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: base64 + +dGhpcyBpcyBhIHRlc3Q= + +--_000_1749056621354738495468JavaMailbabeldocatlas_ +Content-Type: text/html; charset="utf-8" +Content-Transfer-Encoding: base64 + +PGgxPnRoaXMgaXMgYSB0ZXN0PC9oMT4= + +--_000_1749056621354738495468JavaMailbabeldocatlas_-- + +--_003_EFA59C089DA07740B05CB29190CB4F96474734CANTEXCHANGE3exampled_ +Content-Type: message/rfc822 +Content-Disposition: attachment; + creation-date="Fri, 07 Dec 2012 08:26:03 GMT"; + modification-date="Fri, 07 Dec 2012 08:26:03 GMT" + +Received: from NTEXCHANGE3.example.dom ([172.17.253.64]) by ntexchange.example.dom + with Microsoft SMTPSVC(6.0.3790.4675); Wed, 5 Dec 2012 21:06:21 +0100 +Received: from NTEXCHANGE2.example.dom (172.17.253.213) by NTEXCHANGE3.example.dom + (172.17.253.64) with Microsoft SMTP Server (TLS) id 14.2.318.4; Wed, 5 Dec + 2012 21:06:21 +0100 +Received: from ntserver-1.example.com (172.17.253.224) by NTEXCHANGE2.example.dom + (172.17.253.213) with Microsoft SMTP Server id 14.2.318.4; Wed, 5 Dec 2012 + 21:06:21 +0100 +Received: from ntserver-1.example.com ([192.168.100.117]) by ntserver-1.example.com with + Microsoft SMTPSVC(7.5.7601.17514); Wed, 5 Dec 2012 21:06:21 +0100 +Received: from mailout01.ispamone.de ( [212.211.146.204]) by ntserver-1.example.com + (Reddoxx engine) with SMTP id 40D026EFCF5; Wed, 5 Dec 2012 21:06:19 +0100 +From: "bestellung.example@example.com" +To: HelpDesk +Subject: Call: HW-Anforderung; Best-nr.47524152 +Thread-Topic: Call: HW-Anforderung; Best-nr.47524152 +Thread-Index: Ac3TI/8Xh/P5FTJFSYuBz+vjlXSWbg== +Date: Wed, 5 Dec 2012 20:06:21 +0000 +Message-ID: <13553079.1354737948277.JavaMail.jboss@fpep> +Content-Language: de-DE +X-MS-Has-Attach: +X-MS-Exchange-Organization-SCL: 0 +X-MS-TNEF-Correlator: +Content-Type: text/plain; charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +MIME-Version: 1.0 + + + + +Warenempf=E4nger: +Firma: Example GmbH +Name: Rehm +Vorname: Joachim +Stra=DFe K=E4ssstr. 19 +Ort: 00000 Ulm +E-Mail: helpdesk@example.com +Telefon: 0000 166-2399 +Fax: 0000 166-2309 +Abteilung: TN 23 +Geb=E4ude: EG, Zimmer E60 + + +Bestellpositionen: +Pos. Menge Art.-Nr. Bezeichnung Ansprechpartner = + Aufstellort Bemerkungen des Bestellers +10 1.0 588164 Dell UltraSharp U2410 24 Andreas Ring, GE-P= +EW K=E4ssstr. 19, 3. OG, Zi 306 +20 1.0 71705 Crossoverkabel S/FTP, PiMF, Cat... Andreas Ring, GE-P= +EW K=E4ssstr. 19, 3. OG, Zi 306 +30 1.0 777577_638Dell Latitude E6430 mit UMTS / ... Andreas Ring, GE-P= +EW K=E4ssstr. 19, 3. OG, Zi 306 +40 1.0 920-003052Logitech K270 cordless Keyboard... Andreas Ring, GE-P= +EW K=E4ssstr. 19, 3. OG, Zi 306 + +--_003_EFA59C089DA07740B05CB29190CB4F96474734CANTEXCHANGE3exampled_-- diff --git a/test/unit/email_parser_test.rb b/test/unit/email_parser_test.rb index a39dd0771..88a7723c8 100644 --- a/test/unit/email_parser_test.rb +++ b/test/unit/email_parser_test.rb @@ -271,6 +271,27 @@ Hof", :to => 'q1@znuny.com', }, }, + { + :data => IO.read('test/fixtures/mail14.box'), + :body_md5 => '548917e0bff0806f9b27c09bbf23bb38', + :attachments => [ + { + :md5 => 'c7d16825111cddb26253365f7c05859c', + :filename => 'file-1', + }, + { + :md5 => '2f0c4f903ae59cf1b8bacb7bc0094b7a', + :filename => 'file-2', + }, + ], + :params => { + :from => '"Müller, Bernd" ', + :from_email => 'Bernd.Mueller@example.com', + :from_display_name => "Müller, Bernd", + :subject => 'AW: OTRS [Ticket#118192]', + :to => '\'Martin Edenhofer via Znuny Sales\' ', + }, + }, ] files.each { |file|