From 64f8a514cb9be3b72cc82a0323dd9fbc2ac5509e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lecour?= Date: Fri, 1 Jan 2021 19:12:50 +0100 Subject: [PATCH] Ajout de tests sur les mails + normalisation des .eml --- app/services/email_importer.rb | 14 +- test/fixtures/files/clients_multiple.eml | 16 + test/fixtures/files/clients_single.eml | 15 + test/fixtures/files/cron_headers.eml | 27 +- test/fixtures/files/cron_not.eml | 25 +- test/fixtures/files/cron_subject.eml | 25 +- test/fixtures/files/delivered_to_missing.eml | 13 + test/fixtures/files/delivered_to_multiple.eml | 46 ++- test/fixtures/files/delivered_to_single.eml | 306 +----------------- test/fixtures/files/html_only.eml | 41 +-- test/fixtures/files/html_only_base64.eml | 92 +----- test/fixtures/files/html_only_multipart.eml | 35 +- test/fixtures/files/tickets_multiple.eml | 16 + test/fixtures/files/tickets_single.eml | 15 + test/services/email_importer_test.rb | 55 +++- 15 files changed, 221 insertions(+), 520 deletions(-) create mode 100644 test/fixtures/files/clients_multiple.eml create mode 100644 test/fixtures/files/clients_single.eml create mode 100644 test/fixtures/files/delivered_to_missing.eml create mode 100644 test/fixtures/files/tickets_multiple.eml create mode 100644 test/fixtures/files/tickets_single.eml diff --git a/app/services/email_importer.rb b/app/services/email_importer.rb index 3253d58..b95f2f2 100644 --- a/app/services/email_importer.rb +++ b/app/services/email_importer.rb @@ -70,7 +70,12 @@ class EmailImporter end def clients(mail) - values_for_header(mail.header["X-Client-ID"]) + header = mail.header["X-Client-Id"] + if header.respond_to?(:map) + header.map(&:value) + elsif header.respond_to?(:value) + header.value + end end def servers(mail) @@ -84,7 +89,12 @@ class EmailImporter end def tickets(mail) - values_for_header(mail.header["X-Ticket-ID"]) + header = mail.header["X-Ticket-Id"] + if header.respond_to?(:map) + header.map(&:value) + elsif header.respond_to?(:value) + header.value + end end def address_match_evolix_net?(address) diff --git a/test/fixtures/files/clients_multiple.eml b/test/fixtures/files/clients_multiple.eml new file mode 100644 index 0000000..790d0a0 --- /dev/null +++ b/test/fixtures/files/clients_multiple.eml @@ -0,0 +1,16 @@ +Return-Path: +Delivered-To: delivered-to-1@example.com +Received: by mx.example.com (Postfix, from userid 1000) + id 8B3187F5D3; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) +From: from-foo@example.com +To: Foo +Subject: Dummy subject +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST) +Message-Id: +X-Client-Id: 42QUUX4567 +X-Client-Id: 75FOOB0123 + +dummy body diff --git a/test/fixtures/files/clients_single.eml b/test/fixtures/files/clients_single.eml new file mode 100644 index 0000000..234bbbe --- /dev/null +++ b/test/fixtures/files/clients_single.eml @@ -0,0 +1,15 @@ +Return-Path: +Delivered-To: delivered-to-1@example.com +Received: by mx.example.com (Postfix, from userid 1000) + id 8B3187F5D3; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) +From: from-foo@example.com +To: Foo +Subject: Dummy subject +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST) +Message-Id: +X-Client-Id: 42QUUX4567 + +dummy body diff --git a/test/fixtures/files/cron_headers.eml b/test/fixtures/files/cron_headers.eml index 04078c3..4cac286 100644 --- a/test/fixtures/files/cron_headers.eml +++ b/test/fixtures/files/cron_headers.eml @@ -1,29 +1,18 @@ -Return-Path: -X-Original-To: equipe@evolix.net -Delivered-To: equipe@evolix.net -Received: by pele.evolix.net (Postfix, from userid 1000) +Return-Path: +Delivered-To: delivered-to-1@example.com +Received: by mx.example.com (Postfix, from userid 1000) id 8B3187F5D3; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) -X-Original-To: alert3@evolix.fr -Delivered-To: alert3@evolix.fr -Received: from tyredating-yepgarage-singapore-adm01.evolix.net (ec2-54-251-151-125.ap-southeast-1.compute.amazonaws.com [54.251.151.125]) - by pele.evolix.net (Postfix) with ESMTP id 657387F46C - for ; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) -Received: by tyredating-yepgarage-singapore-adm01.evolix.net (Postfix) - id A57B163657; Sat, 12 Sep 2020 06:43:02 +0200 (CEST) -Delivered-To: root@tyredating-yepgarage-singapore-adm01.evolix.net -Received: by tyredating-yepgarage-singapore-adm01.evolix.net (Postfix, from userid 0) - id 9E4AC63644; Sat, 12 Sep 2020 06:43:02 +0200 (CEST) -From: root@tyredating-yepgarage-singapore-adm01.evolix.net (Cron Daemon) -To: root@tyredating-yepgarage-singapore-adm01.evolix.net -Subject: dummy subject +From: from-foo@example.com +To: Foo +Subject: Dummy subject MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit +Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST) +Message-Id: X-Cron-Env: X-Cron-Env: X-Cron-Env: X-Cron-Env: -Message-Id: <20200912044302.9E4AC63644@tyredating-yepgarage-singapore-adm01.evolix.net> -Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST) run-parts: /etc/cron.daily/zzz_evobackup exited because of uncaught signal 9 diff --git a/test/fixtures/files/cron_not.eml b/test/fixtures/files/cron_not.eml index 1e2fbdf..cef3727 100644 --- a/test/fixtures/files/cron_not.eml +++ b/test/fixtures/files/cron_not.eml @@ -1,25 +1,14 @@ -Return-Path: -X-Original-To: equipe@evolix.net -Delivered-To: equipe@evolix.net -Received: by pele.evolix.net (Postfix, from userid 1000) +Return-Path: +Delivered-To: delivered-to-1@example.com +Received: by mx.example.com (Postfix, from userid 1000) id 8B3187F5D3; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) -X-Original-To: alert3@evolix.fr -Delivered-To: alert3@evolix.fr -Received: from tyredating-yepgarage-singapore-adm01.evolix.net (ec2-54-251-151-125.ap-southeast-1.compute.amazonaws.com [54.251.151.125]) - by pele.evolix.net (Postfix) with ESMTP id 657387F46C - for ; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) -Received: by tyredating-yepgarage-singapore-adm01.evolix.net (Postfix) - id A57B163657; Sat, 12 Sep 2020 06:43:02 +0200 (CEST) -Delivered-To: root@tyredating-yepgarage-singapore-adm01.evolix.net -Received: by tyredating-yepgarage-singapore-adm01.evolix.net (Postfix, from userid 0) - id 9E4AC63644; Sat, 12 Sep 2020 06:43:02 +0200 (CEST) -From: root@tyredating-yepgarage-singapore-adm01.evolix.net (Cron Daemon) -To: root@tyredating-yepgarage-singapore-adm01.evolix.net -Subject: dummy subject +From: from-foo@example.com +To: Foo +Subject: Dummy subject MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -Message-Id: <20200912044302.9E4AC63644@tyredating-yepgarage-singapore-adm01.evolix.net> Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST) +Message-Id: dummy body diff --git a/test/fixtures/files/cron_subject.eml b/test/fixtures/files/cron_subject.eml index f03583b..9bc7e54 100644 --- a/test/fixtures/files/cron_subject.eml +++ b/test/fixtures/files/cron_subject.eml @@ -1,25 +1,14 @@ -Return-Path: -X-Original-To: equipe@evolix.net -Delivered-To: equipe@evolix.net -Received: by pele.evolix.net (Postfix, from userid 1000) +Return-Path: +Delivered-To: delivered-to-1@example.com +Received: by mx.example.com (Postfix, from userid 1000) id 8B3187F5D3; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) -X-Original-To: alert3@evolix.fr -Delivered-To: alert3@evolix.fr -Received: from tyredating-yepgarage-singapore-adm01.evolix.net (ec2-54-251-151-125.ap-southeast-1.compute.amazonaws.com [54.251.151.125]) - by pele.evolix.net (Postfix) with ESMTP id 657387F46C - for ; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) -Received: by tyredating-yepgarage-singapore-adm01.evolix.net (Postfix) - id A57B163657; Sat, 12 Sep 2020 06:43:02 +0200 (CEST) -Delivered-To: root@tyredating-yepgarage-singapore-adm01.evolix.net -Received: by tyredating-yepgarage-singapore-adm01.evolix.net (Postfix, from userid 0) - id 9E4AC63644; Sat, 12 Sep 2020 06:43:02 +0200 (CEST) -From: root@tyredating-yepgarage-singapore-adm01.evolix.net (Cron Daemon) -To: root@tyredating-yepgarage-singapore-adm01.evolix.net -Subject: Cron test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) (failed) +From: from-foo@example.com +To: Foo +Subject: Cron Dummy subject MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -Message-Id: <20200912044302.9E4AC63644@tyredating-yepgarage-singapore-adm01.evolix.net> Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST) +Message-Id: run-parts: /etc/cron.daily/zzz_evobackup exited because of uncaught signal 9 diff --git a/test/fixtures/files/delivered_to_missing.eml b/test/fixtures/files/delivered_to_missing.eml new file mode 100644 index 0000000..5230f76 --- /dev/null +++ b/test/fixtures/files/delivered_to_missing.eml @@ -0,0 +1,13 @@ +Return-Path: +Received: by mx.example.com (Postfix, from userid 1000) + id 8B3187F5D3; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) +From: from-foo@example.com +To: Foo +Subject: dummy subject +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST) +Message-Id: + +dummy body diff --git a/test/fixtures/files/delivered_to_multiple.eml b/test/fixtures/files/delivered_to_multiple.eml index 8feaf0a..bc6f245 100644 --- a/test/fixtures/files/delivered_to_multiple.eml +++ b/test/fixtures/files/delivered_to_multiple.eml @@ -1,30 +1,20 @@ -Return-Path: -X-Original-To: equipe@evolix.net -Delivered-To: equipe@evolix.net -Received: by pele.evolix.net (Postfix, from userid 1000) - id 1A25A7F5D8; Sat, 5 Sep 2020 04:29:46 +0200 (CEST) -X-Original-To: alert3@evolix.fr -Delivered-To: alert3@evolix.fr -Received: from stratis-www01.evolix.net (failover01.stratis-www01.evolix.eu [94.23.123.135]) - by pele.evolix.net (Postfix) with ESMTP id 0C4857F5B7 - for ; Sat, 5 Sep 2020 04:29:46 +0200 (CEST) -Received: by stratis-www01.evolix.net (Postfix) - id E53EC1FE8A; Sat, 5 Sep 2020 04:29:45 +0200 (CEST) -Delivered-To: root@stratis-www01.evolix.net -Received: by stratis-www01.evolix.net (Postfix, from userid 0) - id DC0BC1FE89; Sat, 5 Sep 2020 04:29:45 +0200 (CEST) -From: root@stratis-www01.evolix.net (Cron Daemon) -To: root@stratis-www01.evolix.net -Subject: Cron test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) +Return-Path: +X-Original-To: original-to@example.com +Delivered-To: delivered-to-1@example.com +Received: by mx1.example.com (Postfix, from userid 1000) + id 8B3187F5D3; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) +Delivered-To: delivered-to-2@example.com +Received: by mx2.example.com (Postfix, from userid 1000) + id 7F5D38B318; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) +Delivered-To: delivered-to-3@example.com +From: Hotmail Sender Support + +To: Foo +Subject: dummy subject +MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 -X-Cron-Env: -X-Cron-Env: -X-Cron-Env: -X-Cron-Env: -Message-Id: <20200905022945.DC0BC1FE89@stratis-www01.evolix.net> -Date: Sat, 5 Sep 2020 04:29:45 +0200 (CEST) +Content-Transfer-Encoding: 8bit +Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST) +Message-Id: -/etc/cron.daily/logrotate: -gzip: stdin: file size changed while zipping -/etc/cron.daily/zzz_evobackup: --- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly. +dummy body diff --git a/test/fixtures/files/delivered_to_single.eml b/test/fixtures/files/delivered_to_single.eml index 3cad533..9471f05 100644 --- a/test/fixtures/files/delivered_to_single.eml +++ b/test/fixtures/files/delivered_to_single.eml @@ -1,296 +1,14 @@ -Return-Path: -X-Original-To: equipe+lpoujol@evolix.fr -Delivered-To: equipe+lpoujol@evolix.fr -Received: from smtpi.msn.com (co1gmehub03.msn.com [65.55.52.231]) - by pele.evolix.net (Postfix) with ESMTPS id E26007F8FC; - Tue, 12 May 2020 11:55:00 +0200 (CEST) -X-Mailer: Microsoft Avondale Mailer -X-SRX: 1500300887 -Thread-Topic: =?iso-8859-1?Q?SRX1500300887ID_-_=5BEXTERNE=5D_Re:_Probl=E8me_de_remise_d?= - =?iso-8859-1?Q?es_messages_signal=E9_dans_Outlook.com_SRX1500300887ID$?= -thread-index: AdYoQ2Kuuy6GyqvPQtuNIVCto8rMwQ== -From: Hotmail Sender Support - -To: ludovic poujol -CC: -Subject: =?iso-8859-1?Q?RE:_SRX1500300887ID_-_=5BEXTERNE=5D_Re:_Probl=E8me_de_remi?= - =?iso-8859-1?Q?se_des_messages_signal=E9_dans_Outlook.com_SRX1500300887ID$?= -Date: Tue, 12 May 2020 03:54:53 -0600 -Message-ID: <97BD692073A84E54B04BC74EA66C9B1B@partners.extranet.microsoft.com> +Return-Path: +Delivered-To: delivered-to-1@example.com +Received: by mx.example.com (Postfix, from userid 1000) + id 8B3187F5D3; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) +From: from-foo@example.com +To: Foo +Subject: dummy subject MIME-Version: 1.0 -Content-Type: multipart/alternative; - boundary="----=_NextPart_000_E9B38D_01D62811.181431A0" -Content-Class: urn:content-classes:message -Importance: normal -Priority: normal -X-MimeOLE: Produced By Microsoft MimeOLE V6.3.9600.19678 -X-OriginalArrivalTime: 12 May 2020 09:54:53.0944 (UTC) FILETIME=[62CB9F80:01D62843] +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST) +Message-Id: -------=_NextPart_000_E9B38D_01D62811.181431A0 -Content-Type: text/plain; charset="iso-8859-1" -Content-Transfer-Encoding: quoted-printable - - =20 - -Hello, - -My name is Somashekhar and I work with the Outlook.com Deliverability -Support Team. - -=20 - -We have implemented mitigation for your IP (31.170.8.119) and this -process may take 24 - 48 hours to replicate completely throughout our -system. - -Sincerely, - -=20 - -Somashekhar - -Outlook.com Deliverability Support. - - - _____ =20 - - - ---- Original Message --- -From : "Ludovic Poujol"=20 -Sent : Tuesday, May 12, 2020 8:48:16 AM UTC -To : -"WINLV.EDFS.WW.00.FR.MSF.RMD.TS.T01.SPT.00.EM@css.one.microsoft.com"=20 -Cc : "equipe@evolix.fr"=20 -Subject : [EXTERNE] Re: Probl=E8me de remise des messages signal=E9 dans -Outlook.com SRX1500300887ID$ - -Bonjour, - -On 2020-05-05 15:48, -WINLV.EDFS.WW.00.FR.MSF.RMD.TS.T01.SPT.00.EM@css.one.microsoft.com -wrote: -> Ne peut pas =EAtre d=E9bloqu=E9 -> 31.170.8.119/32 -> Notre investigation a d=E9termin=E9 que les adresses IP ci-dessus ne -> peuvent pas =EAtre d=E9bloqu=E9es. - -Merci pour ce retour. N=E9anmoins, pouvez-vous nous expliquer la raison -de l'impossibilit=E9 de d=E9bloquer l'adresse IP en question ? - -De plus, au travers du programme SNDS, je constate bien l'absence -de blocage de 31.170.8.119/32 - -N=E9anmoins, l'envoi d'emails depuis cette machine vers des -adresses hotmail.fr est imm=E9diatement rejet=E9 comme en atteste les -journaux ainsi que le bounce : - -Journaux postfix :=20 - -May 5 16:42:08 exotismes-vo2max postfix/smtp[31956]: E1D616188E: -to=3D, -relay=3Deur.olc.protection.outlook.com[104.47.1.33]:25, delay=3D0.15, -delays=3D0.03/0.01/0.08/0.03, dsn=3D5.7.1, status=3Dbounced (host -eur.olc.protection.outlook.com[104.47.1.33] said: 550 5.7.1 -Unfortunately, messages from [31.170.8.119] weren't sent. Please -contact your Internet service provider since part of their network is -on our block list (S3150). You can also refer your provider to -https://nam06.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fmail.l= -i -ve.com%2Fmail%2Ftroubleshooting.aspx%23errors&data=3D02%7C01%7CWINLV.= -E -DFS.WW.00.FR.MSF.RMD.TS.T01.SPT.00.EM%40css.one.microsoft.com%7C0c63b8ba -f30a481517a008d7f65109fe%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C63 -7248700237133288&sdata=3DhI2oonR%2Bi27oc9x0u5MXo0uFq3UEvKk6Dtz5AN9ZTw= -k -%3D&reserved=3D0. -[VE1EUR01FT045.eop-EUR01.prod.protection.outlook.com] (in reply to MAIL -FROM command)) - -Bounce re=E7u :=20 - -: host -eur.olc.protection.outlook.com[104.47.1.33] -said: 550 5.7.1 Unfortunately, messages from [31.170.8.119] weren't -sent. -Please contact your Internet service provider since part of their -network -is on our block list (S3150). You can also refer your provider to -https://nam06.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fmail.l= -i -ve.com%2Fmail%2Ftroubleshooting.aspx%23errors&data=3D02%7C01%7CWINLV.= -E -DFS.WW.00.FR.MSF.RMD.TS.T01.SPT.00.EM%40css.one.microsoft.com%7C0c63b8ba -f30a481517a008d7f65109fe%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C63 -7248700237133288&sdata=3DhI2oonR%2Bi27oc9x0u5MXo0uFq3UEvKk6Dtz5AN9ZTw= -k -%3D&reserved=3D0. -[VE1EUR01FT045.eop-EUR01.prod.protection.outlook.com] (in reply to MAIL -FROM command) - -Reporting-MTA: dns; exotismes-vo2max.evolix.net -X-Postfix-Queue-ID: E1D616188E -X-Postfix-Sender: rfc822; www-prod_afcf@exotismes-vo2max.evolix.net -Arrival-Date: Tue, 5 May 2020 16:42:07 +0200 (CEST) - -Final-Recipient: rfc822; alain.chevassu@hotmail.fr -Action: failed -Status: 5.7.1 -Remote-MTA: dns; eur.olc.protection.outlook.com -Diagnostic-Code: smtp; 550 5.7.1 Unfortunately, messages from -[31.170.8.119] -weren't sent. Please contact your Internet service provider since part -of -their network is on our block list (S3150). You can also refer your -provider to -https://nam06.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fmail.l= -i -ve.com%2Fmail%2Ftroubleshooting.aspx%23errors&data=3D02%7C01%7CWINLV.= -E -DFS.WW.00.FR.MSF.RMD.TS.T01.SPT.00.EM%40css.one.microsoft.com%7C0c63b8ba -f30a481517a008d7f65109fe%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C63 -7248700237133288&sdata=3DhI2oonR%2Bi27oc9x0u5MXo0uFq3UEvKk6Dtz5AN9ZTw= -k -%3D&reserved=3D0. -[VE1EUR01FT045.eop-EUR01.prod.protection.outlook.com] - - -Pouvez-vous s'il vous plait : - -1/ Nous expliquer les raisons du blocage de 31.170.8.119/32 -2/ Nous expliquer pourquoi ce blocage n'apparait pas sur le SNDS -3/ Nous communiquer les d=E9marches =E0 faire pour d=E9bloquer l'adresse = -IP - -Merci d'avance pour vos r=E9ponses, - ---=20 -Ludovic Poujol=20 -Evolix - H=E9bergement et Infog=E9rance Open Source -Marseille (37 rue Guibal, P=F4le M=E9dia, 13003) / Paris / Montr=E9al -https://nam06.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fevolix= - -com%2F&data=3D02%7C01%7CWINLV.EDFS.WW.00.FR.MSF.RMD.TS.T01.SPT.00.EM%= -4 -0css.one.microsoft.com%7C0c63b8baf30a481517a008d7f65109fe%7C72f988bf86f1 -41af91ab2d7cd011db47%7C1%7C0%7C637248700237133288&sdata=3D5nhf0AsapDC= -1 -YoSCnUkSaS863X5W9m0kJDPYZRzx90g%3D&reserved=3D0 | Twitter: @Evolix -@EvolixNOC | -https://nam06.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fblog.e= -v -olix.com%2F&data=3D02%7C01%7CWINLV.EDFS.WW.00.FR.MSF.RMD.TS.T01.SPT.0= -0 -EM%40css.one.microsoft.com%7C0c63b8baf30a481517a008d7f65109fe%7C72f988b -f86f141af91ab2d7cd011db47%7C1%7C0%7C637248700237133288&sdata=3DUEPHCd= -p -k8iYN9y2HhJRm5ijmf0ZJReZmN2vell02aAg%3D&reserved=3D0 - - -------=_NextPart_000_E9B38D_01D62811.181431A0 -Content-Type: text/html; charset="iso-8859-1" -Content-Transfer-Encoding: quoted-printable - -
  =0A= -

Hello,

=0A= -

My name is Somashekhar and I work with the Outlook.com Deliver= -ability Support Team.

=0A= -

 

=0A= -

We have implemented mitigation for your IP (31.170.8.119) and = -this process may take 24 - 48 hours to replicate completely throughout our = -system.

=0A= -

Sincerely,

=0A= -

 

=0A= -

Somashekhar

=0A= -

Outlook.com Deliverability Support.


= -=0A= -
=0A= -
=0A= -

--- Original Mess= -age ---
From : "Ludovic Poujol"
Sent : Tuesday, May 12, 2020 8:48:16 AM UTC
To : "WINLV.EDFS.WW.00.FR.MSF.RMD.TS.T01.SPT.00.EM@css.one.mic= -rosoft.com"
Cc : "equipe@evolix.fr"
Subject : [EXTERNE] Re: Probl=E8me de remise des messages sig= -nal=E9 dans Outlook.com SRX1500300887ID$

Bonjour,

On 2020-05-= -05 15:48, WINLV.EDFS.WW.00.FR.MSF.RMD.TS.T01.SPT.00.EM@css.one.microsoft.co= -m wrote:
> Ne peut pas =EAtre d=E9bloqu=E9
> 31.170.8.119/32> Notre investigation a d=E9termin=E9 que les adresses IP ci-dessus ne<= -BR>> peuvent pas =EAtre d=E9bloqu=E9es.

Merci pour ce retour. N= -=E9anmoins, pouvez-vous nous expliquer la raison
de l'impossibilit=E9 de= - d=E9bloquer l'adresse IP en question ?

De plus, au travers du progr= -amme SNDS, je constate bien l'absence
de blocage de 31.170.8.119/32
<= -BR>N=E9anmoins, l'envoi d'emails depuis cette machine vers des
adresses = -hotmail.fr est imm=E9diatement rejet=E9 comme en atteste les
journaux ai= -nsi que le bounce :

Journaux postfix :

May  5 16:42:08 = -exotismes-vo2max postfix/smtp[31956]: E1D616188E: to=3D<alain.chevassu@h= -otmail.fr>, relay=3Deur.olc.protection.outlook.com[104.47.1.33]:25, dela= -y=3D0.15, delays=3D0.03/0.01/0.08/0.03, dsn=3D5.7.1, status=3Dbounced (host= - eur.olc.protection.outlook.com[104.47.1.33] said: 550 5.7.1 Unfortunately,= - messages from [31.170.8.119] weren't sent. Please contact your Internet se= -rvice provider since part of their network is on our block list (S3150). Yo= -u can also refer your provider to https://nam06.safelinks.protection.outloo= -k.com/?url=3Dhttp%3A%2F%2Fmail.live.com%2Fmail%2Ftroubleshooting.aspx%23err= -ors&amp;data=3D02%7C01%7CWINLV.EDFS.WW.00.FR.MSF.RMD.TS.T01.SPT.00.EM%4= -0css.one.microsoft.com%7C0c63b8baf30a481517a008d7f65109fe%7C72f988bf86f141a= -f91ab2d7cd011db47%7C1%7C0%7C637248700237133288&amp;sdata=3DhI2oonR%2Bi2= -7oc9x0u5MXo0uFq3UEvKk6Dtz5AN9ZTwk%3D&amp;reserved=3D0. [VE1EUR01FT045.e= -op-EUR01.prod.protection.outlook.com] (in reply to MAIL FROM command))
<= -BR>Bounce re=E7u :

<alain.chevassu@hotmail.fr>: host eur.olc.= -protection.outlook.com[104.47.1.33]
said: 550 5.7.1 Unfortunately, messa= -ges from [31.170.8.119] weren't sent.
Please contact your Internet servi= -ce provider since part of their network
is on our block list (S3150). Yo= -u can also refer your provider to
https://nam06.safelinks.protection.out= -look.com/?url=3Dhttp%3A%2F%2Fmail.live.com%2Fmail%2Ftroubleshooting.aspx%23= -errors&amp;data=3D02%7C01%7CWINLV.EDFS.WW.00.FR.MSF.RMD.TS.T01.SPT.00.E= -M%40css.one.microsoft.com%7C0c63b8baf30a481517a008d7f65109fe%7C72f988bf86f1= -41af91ab2d7cd011db47%7C1%7C0%7C637248700237133288&amp;sdata=3DhI2oonR%2= -Bi27oc9x0u5MXo0uFq3UEvKk6Dtz5AN9ZTwk%3D&amp;reserved=3D0.
[VE1EUR01F= -T045.eop-EUR01.prod.protection.outlook.com] (in reply to MAIL
FROM comma= -nd)

Reporting-MTA: dns; exotismes-vo2max.evolix.net
X-Postfix-Que= -ue-ID: E1D616188E
X-Postfix-Sender: rfc822; www-prod_afcf@exotismes-vo2m= -ax.evolix.net
Arrival-Date: Tue, 5 May 2020 16:42:07 +0200 (CEST)
Final-Recipient: rfc822; alain.chevassu@hotmail.fr
Action: failed
St= -atus: 5.7.1
Remote-MTA: dns; eur.olc.protection.outlook.com
Diagnosti= -c-Code: smtp; 550 5.7.1 Unfortunately, messages from [31.170.8.119]
were= -n't sent. Please contact your Internet service provider since part of
th= -eir network is on our block list (S3150). You can also refer your
provid= -er to https://nam06.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fma= -il.live.com%2Fmail%2Ftroubleshooting.aspx%23errors&amp;data=3D02%7C01%7= -CWINLV.EDFS.WW.00.FR.MSF.RMD.TS.T01.SPT.00.EM%40css.one.microsoft.com%7C0c6= -3b8baf30a481517a008d7f65109fe%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C= -637248700237133288&amp;sdata=3DhI2oonR%2Bi27oc9x0u5MXo0uFq3UEvKk6Dtz5AN= -9ZTwk%3D&amp;reserved=3D0.
[VE1EUR01FT045.eop-EUR01.prod.protection.= -outlook.com]


Pouvez-vous s'il vous plait :

1/ Nous expliq= -uer les raisons du blocage de 31.170.8.119/32
2/ Nous expliquer pourquoi= - ce blocage n'apparait pas sur le SNDS
3/ Nous communiquer les d=E9march= -es =E0 faire pour d=E9bloquer l'adresse IP

Merci d'avance pour vos r= -=E9ponses,

--
Ludovic Poujol
Evolix - H=E9bergement et Infog= -=E9rance Open Source                = -;                     &nb= -sp;                     &= -nbsp;  
Marseille (37 rue Guibal, P=F4le M=E9dia, 13003) / Paris / = -Montr=E9al                   &= -nbsp;                    = -
https://nam06.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fevol= -ix.com%2F&amp;data=3D02%7C01%7CWINLV.EDFS.WW.00.FR.MSF.RMD.TS.T01.SPT.0= -0.EM%40css.one.microsoft.com%7C0c63b8baf30a481517a008d7f65109fe%7C72f988bf8= -6f141af91ab2d7cd011db47%7C1%7C0%7C637248700237133288&amp;sdata=3D5nhf0A= -sapDC1YoSCnUkSaS863X5W9m0kJDPYZRzx90g%3D&amp;reserved=3D0 | Twitter: @E= -volix @EvolixNOC | https://nam06.safelinks.protection.outlook.com/?url=3Dht= -tp%3A%2F%2Fblog.evolix.com%2F&amp;data=3D02%7C01%7CWINLV.EDFS.WW.00.FR.= -MSF.RMD.TS.T01.SPT.00.EM%40css.one.microsoft.com%7C0c63b8baf30a481517a008d7= -f65109fe%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637248700237133288&am= -p;amp;sdata=3DUEPHCdpk8iYN9y2HhJRm5ijmf0ZJReZmN2vell02aAg%3D&amp;reserv= -ed=3D0
= - -------=_NextPart_000_E9B38D_01D62811.181431A0-- +dummy body diff --git a/test/fixtures/files/html_only.eml b/test/fixtures/files/html_only.eml index 714b8a3..240a600 100644 --- a/test/fixtures/files/html_only.eml +++ b/test/fixtures/files/html_only.eml @@ -1,35 +1,14 @@ -Return-Path: -X-Original-To: maintenance@evolix.fr -Delivered-To: equipe@evolix.fr -Received: from m207-15.mailgun.net (m207-15.mailgun.net [161.38.207.15]) - by pele.evolix.net (Postfix) with ESMTPS id 7D2077F5D1 - for ; Tue, 27 Oct 2020 12:58:19 +0100 (CET) -DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.s35798.fr; q=dns/txt; - s=krs; t=1603799902; h=Content-Transfer-Encoding: Mime-Version: - Content-Type: Subject: From: To: Sender: Reply-To: Message-Id: Date: - List-Unsubscribe: List-Unsubscribe-Post; - bh=bLPQd8jozY53WvIsLaomSUDhri3r+GcUcKSlfcoIpnY=; b=i7Kt8MTqEqLNlpP2Lm38A/l3Ynay1yZuPGDx7+ZfBpGWrOtyknKQRpU0NJyIilJGTSS6iLdc - 1Ezqr/7kR8O2zGxTM9m/Z4P4PJTr527ue+Ncl3dWfAcIM1MpvgAVvtbSkXnebRe26no9q1v/ - aQJH+fwxGUsRAjns2RsRfwGGwXY= -X-Mailgun-Sending-Ip: 161.38.207.15 -X-Mailgun-Sid: WyJmMTRjNyIsICJtYWludGVuYW5jZUBldm9saXguZnIiLCAiYWM1NyJd -List-Unsubscribe-Post: List-Unsubscribe=One-Click -List-Unsubscribe: , - -X-Mailgun-Batch-Id: 5f980b55fe8623b9ec342122 -Received: by luna.mailgun.net with HTTP; Tue, 27 Oct 2020 11:58:13 +0000 -Date: Tue, 27 Oct 2020 11:58:13 +0000 -Message-Id: <20201027115813.1.F2BD814B7DEAF8CE@mg.s35798.fr> -Reply-To: Alerte Formation Alerte Formation - -Sender: Alerte Formation -X-Mailgun-Tag: academy-fne-400k_175 -To: '' -From: Alerte Formation -Subject: =?utf-8?q?Fin_du_FNE_le_31/10_=3A_plus_que_quelques_jours_pour_f?= - =?utf-8?q?aire_financer_votre_formation_=C3=A0_100=25?= +Return-Path: +Delivered-To: delivered-to-1@example.com +Received: by mx.example.com (Postfix, from userid 1000) + id 8B3187F5D3; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) +From: from-foo@example.com +To: Foo +Subject: Dummy subject +Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST) +Message-Id: +MIME-Version: 1.0 Content-Type: text/html; charset="utf-8" -Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable -X-Original-To: abuse@evolix.fr -Delivered-To: abuse@evolix.fr -Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60136.outbound.protection.outlook.com [40.107.6.136]) - by pele.evolix.net (Postfix) with ESMTPS id DB52A7F52F - for ; Tue, 20 Oct 2020 15:48:21 +0200 (CEST) -ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; - b=g4IvLqHRp/cX29V2XPnfYiGL7at1C4R9PeLaUK+LyAlDnoYjJSQurFuMy/MNmI+ceT48cqyvcxhX9oMGxUmFEtclRLTLBQDUXOdM76PAzrdksuTKzcwGBvypaL4Z4saRd8zsAgqVlod/+nrnlP4htv8lE2MKlIO63QV5IqFWTgO/gUbVNHyw1CQGMX/trl8pKltXCl9dYV3vjSUIuE8/LXNtk4xX0rgKvcrMj5LZn+BHF5EG7Ny13LOXyk1JPViCNeDpQbbmdoXah3VfQzko12lZmnh+k6CRMBed0CtOrVygdeqSCX9vDyOQ7jBuXZFd88zlCTAGQH1W8Edt4CX7jQ== -ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; - s=arcselector9901; - h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; - bh=f5xj9bpJ8Y3XkL9GUFKLnstdE3L7yEv6lv/6bi4W3l4=; - b=k+4NJrAgkiFOLGv+OVO9Z5yfJTiT4niTimLdA6ZEeUj0lbpnU3ZZQeNhga3N8SM/xo62kUfFSGm8gDE56OvFi6QEaBu9iW3x3wbLcNHDCVtu8ycVwE45RFbbKSLNJFbKP/W06tBJnpqKBUk2ZJrKVEnVfK6Cgf4qrX4Ro4odQMqbfAZAE7Efkip3sfrEu7JcLtX+iSpUWLMV508pgO7ZFY3DF9TXFgy4ZuIWcBvZmLmc1rtkW1GkIme2YH8sght3ez4Gy6TYS1EtIht1pxBq5UCpHO0DO/zKSPaaqCH+BhwoJ7c8wgPozW331+bBtXvzG6/BSeZiJNZUfYD0+mxkhA== -ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is - 194.153.74.13) smtp.rcpttodomain=evolix.fr smtp.mailfrom=interxion.com; - dmarc=fail (p=none sp=none pct=100) action=none header.from=interxion.com; - dkim=none (message not signed); arc=none -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=interxion.onmicrosoft.com; s=selector2-interxion-onmicrosoft-com; - h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; - bh=f5xj9bpJ8Y3XkL9GUFKLnstdE3L7yEv6lv/6bi4W3l4=; - b=VekyYeKUzjHLReDljvWSmld5tVP4tx6Io5/TDxZvhqVk+jYWbWQiB0aGabvsTT6Ng6IGxjSzG2EmbtAKIRyfpzps/yL7f24yK+42qFG26FUzeDd9BK/k9C6rklYNVppG9MROM4r46+nfbFo2M6+W+NzruUef/JaAuKLYy6hYaUE= -Received: from BE0P281CA0010.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:a::20) by - DB3PR0102MB3482.eurprd01.prod.exchangelabs.com (2603:10a6:8:f::28) with - Microsoft SMTP Server (version=TLS1_2, - cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Tue, 20 Oct - 2020 13:48:20 +0000 -Received: from HE1EUR01FT047.eop-EUR01.prod.protection.outlook.com - (2603:10a6:b10:a:cafe::d9) by BE0P281CA0010.outlook.office365.com - (2603:10a6:b10:a::20) with Microsoft SMTP Server (version=TLS1_2, - cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend - Transport; Tue, 20 Oct 2020 13:48:20 +0000 -X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 194.153.74.13) - smtp.mailfrom=interxion.com; evolix.fr; dkim=none (message not signed) - header.d=none;evolix.fr; dmarc=fail action=none header.from=interxion.com; -Received-SPF: Fail (protection.outlook.com: domain of interxion.com does not - designate 194.153.74.13 as permitted sender) receiver=protection.outlook.com; - client-ip=194.153.74.13; helo=mail.interxion.com; -Received: from mail.interxion.com (194.153.74.13) by - HE1EUR01FT047.mail.protection.outlook.com (10.152.1.5) with Microsoft SMTP - Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id - 15.20.3477.21 via Frontend Transport; Tue, 20 Oct 2020 13:48:16 +0000 -Received: from nl-ams-mbx04.office.interxion.net (192.168.219.182) by - nl-ams-mbx03.office.interxion.net (192.168.219.56) with Microsoft SMTP Server - (TLS) id 15.0.1497.2; Tue, 20 Oct 2020 15:46:33 +0200 -Received: from nl-ams-smtp.office.interxion.net (192.168.210.15) by - owa.interxion.com (192.168.219.182) with Microsoft SMTP Server id 15.0.1497.2 - via Frontend Transport; Tue, 20 Oct 2020 15:46:32 +0200 -Received: from nl-ams-crmui-p1 ([192.168.219.90]) by nl-ams-smtp.office.interxion.net with Microsoft SMTPSVC(8.5.9600.16384); - Tue, 20 Oct 2020 15:46:32 +0200 -From: =?UTF-8?Q?European_Customer_Service_Center_?= =?UTF-8?Q?=28ECSC=29?= - -MIME-Version: 1.0 +Return-Path: +Delivered-To: delivered-to-1@example.com +Received: by mx.example.com (Postfix, from userid 1000) + id 8B3187F5D3; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) +From: from-foo@example.com +To: Foo +Subject: Dummy subject Date: Tue, 20 Oct 2020 15:46:32 +0200 -Subject: =?UTF-8?Q?=5B_INTERXION_FRANCE_=5D_=5B_Action_?= - =?UTF-8?Q?Required_=5D_=5B_Informational_Notification_?= - =?UTF-8?Q?=5D_1-1688022?= +Message-Id: +MIME-Version: 1.0 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: base64 Content-Disposition: inline -Message-ID: -X-OriginalArrivalTime: 20 Oct 2020 13:46:32.0027 (UTC) FILETIME=[6B348AB0:01D6A6E7] -X-EOPAttributedMessage: 0 -X-MS-PublicTrafficType: Email -X-MS-Office365-Filtering-Correlation-Id: c595d79d-59a9-4ce0-afc6-08d874fecc33 -X-MS-TrafficTypeDiagnostic: DB3PR0102MB3482: -X-Microsoft-Antispam-PRVS: - -X-MS-Oob-TLC-OOBClassifiers: OLM:10000; -X-MS-Exchange-SenderADCheck: 1 -X-Microsoft-Antispam: BCL:0; -X-Microsoft-Antispam-Message-Info: - rxES59CbtzSv7e1R2X/Caednd3hGFdURE+3ol4Qod6sxhJitXSfQam4INglaEoRO77up5f2WMfZkZEd5E4yheRq/lSrMBgZ/M6QtfncogWHCfE+uENU5yltbvYmtWS57BlnkmFYgKQCzJtcQ4suY5JAMptswY0ucFsTZoFpBzEfdl9arDpwO36haQQT4Ar0N86Ha1mba1Xc0HlOs5pjhzGOHALF1EncgEeB4Q/Hk3lzQVnYNLEFjMGhSYEfhkUeu+RsiuLNveCIaEwyk+8wjPUpwkUY1m22PSKr5i9vDxa4q/e2C9e8u0JGpN/jDGYs6/eBYO9jK5hi3Zzj5sIHMo2HxjqIONng2AUwsELBX79QryYudWzWI5zURhPzgNQ8t18y14uReNSLwmwS+YlJJgIULhQLBJlTizAq2TZpzKE7FD2efilCxBIoXSFcooLL50qTNsKhyJNMeEpCgCSQ5KYX4wjb6UhaoUquhPlLcrCjJzyPvvM9/frab0eKcGYaviwpsp7YFcb8wI20FeSAma1802v49o+PC6bMZEgVPJtE= -X-Forefront-Antispam-Report: - CIP:194.153.74.13;CTRY:NL;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.interxion.com;PTR:gate.interxion.com;CAT:NONE;SFS:(4636009)(39850400004)(396003)(136003)(376002)(346002)(46966005)(82310400003)(336012)(316002)(186003)(36906005)(5660300002)(26005)(966005)(15650500001)(70206006)(86362001)(83380400001)(109986005)(2906002)(478600001)(7636003)(47076004)(33310700002)(9686003)(70586007)(8936002)(8676002)(166002)(82740400003)(356005)(105050200001);DIR:OUT;SFP:1102; -X-OriginatorOrg: interxion.com -X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:48:16.8380 - (UTC) -X-MS-Exchange-CrossTenant-Network-Message-Id: c595d79d-59a9-4ce0-afc6-08d874fecc33 -X-MS-Exchange-CrossTenant-Id: 5226521a-cae0-4a6b-a04b-3ba17e7ac24f -X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5226521a-cae0-4a6b-a04b-3ba17e7ac24f;Ip=[194.153.74.13];Helo=[mail.interxion.com] -X-MS-Exchange-CrossTenant-AuthSource: - HE1EUR01FT047.eop-EUR01.prod.protection.outlook.com -X-MS-Exchange-CrossTenant-AuthAs: Anonymous -X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem -X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0102MB3482 DQo8SFRNTD48SEVBRD48TUVUQSBodHRwLWVxdWl2PSJDb250ZW50LVR5cGUiIGNvbnRlbnQ9InRl eHQvaHRtbDsgY2hhcnNldD11dGYtOCI+PE1FVEEgSFRUUC1FUVVJVj0iRXhwaXJlcyIgQ09OVEVO @@ -267,4 +194,3 @@ biBvZiB0aGUgbWF0ZXJpYWwgaW4gdGhpcyBlLW1haWwgaXMgc3RyaWN0bHkgZm9yYmlkZGVuLjwv c3Bhbj48L3NwYW4+PC9wPgoKPHAgc3R5bGU9Im1hcmdpbi1sZWZ0OjBpbjsgbWFyZ2luLXJpZ2h0 OjBpbiI+PHNwYW4gc3R5bGU9ImZvbnQtc2l6ZToxMHB0Ij48c3BhbiBzdHlsZT0iY29sb3I6IzAw MDAwMCI+Jm5ic3A7PC9zcGFuPjwvc3Bhbj48L3A+CjwvQk9EWT48L0hUTUw+DQo= - diff --git a/test/fixtures/files/html_only_multipart.eml b/test/fixtures/files/html_only_multipart.eml index caf4619..7170da9 100644 --- a/test/fixtures/files/html_only_multipart.eml +++ b/test/fixtures/files/html_only_multipart.eml @@ -1,30 +1,15 @@ -Return-Path: -X-Original-To: equipe@evolix.fr -Delivered-To: equipe@evolix.fr -Received: from pom-out.ft-hebergement.com (pom-out.ft-hebergement.com [194.2.122.131]) - by pele.evolix.net (Postfix) with ESMTPS id D9A637F5CF - for ; Wed, 21 Oct 2020 15:10:54 +0200 (CEST) -Received: from localhost (unknown [127.0.0.1]) - by pomprml51 (Postfix) with ESMTP id 58507D24B8 - for ; Wed, 21 Oct 2020 15:10:54 +0200 (CEST) -Received: from pom-out.ft-hebergement.com ([127.0.0.1]) - by localhost (pom-out.ft-hebergement.com [127.0.0.1]) (amavisd-new, port 10024) - with ESMTP id hNoPvsvFOoI2 for ; - Wed, 21 Oct 2020 15:10:54 +0200 (CEST) -Date: Wed, 21 Oct 2020 15:10:53 +0200 (CEST) -From: Orange Business Services -Reply-To: support-donotreply@orange.com -Message-ID: <5997175.120292.1603285853969@smlprwb71.sml.adml> -Subject: Prise en charge de l'incident No. 2010W79915 - PAU, 7 R MARCA, - 64000 Pau +Return-Path: +Delivered-To: delivered-to-1@example.com +Received: by mx.example.com (Postfix, from userid 1000) + id 8B3187F5D3; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) +From: from-foo@example.com +To: Foo +Subject: Dummy subject +Date: Tue, 20 Oct 2020 15:46:32 +0200 +Message-Id: MIME-Version: 1.0 Content-Type: multipart/related; - boundary="----=_Part_120291_30874261.1603285853882" -X-ServiceNow-Source: Notification-6f0a1748b9bc774018d4b2f52714cccc -X-ServiceNow-SysEmail-Version: 2 -Precedence: bulk -Auto-Submitted: auto-generated -X-ServiceNow-Generated: true + boundary="----=_Part_120291_30874261.1603285853882" ------=_Part_120291_30874261.1603285853882 Content-Transfer-Encoding: quoted-printable diff --git a/test/fixtures/files/tickets_multiple.eml b/test/fixtures/files/tickets_multiple.eml new file mode 100644 index 0000000..00a0d4d --- /dev/null +++ b/test/fixtures/files/tickets_multiple.eml @@ -0,0 +1,16 @@ +Return-Path: +Delivered-To: delivered-to-1@example.com +Received: by mx.example.com (Postfix, from userid 1000) + id 8B3187F5D3; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) +From: from-foo@example.com +To: Foo +Subject: Dummy subject +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST) +Message-Id: +X-Ticket-Id: 49123 +X-Ticket-Id: 12345 + +dummy body diff --git a/test/fixtures/files/tickets_single.eml b/test/fixtures/files/tickets_single.eml new file mode 100644 index 0000000..ce35dbe --- /dev/null +++ b/test/fixtures/files/tickets_single.eml @@ -0,0 +1,15 @@ +Return-Path: +Delivered-To: delivered-to-1@example.com +Received: by mx.example.com (Postfix, from userid 1000) + id 8B3187F5D3; Sat, 12 Sep 2020 06:43:04 +0200 (CEST) +From: from-foo@example.com +To: Foo +Subject: Dummy subject +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST) +Message-Id: +X-Ticket-Id: 49123 + +dummy body diff --git a/test/services/email_importer_test.rb b/test/services/email_importer_test.rb index ed2f493..9343dd1 100644 --- a/test/services/email_importer_test.rb +++ b/test/services/email_importer_test.rb @@ -43,12 +43,63 @@ class EmailImporterTest < ActiveSupport::TestCase test "single delivered-to" do email = email_from_eml("delivered_to_single.eml") - assert_equal email.delivered_to, "equipe+lpoujol@evolix.fr" + expected = "delivered-to-1@example.com" + actual = email.delivered_to + + assert_equal expected, actual end test "multiple delivered-to" do email = email_from_eml("delivered_to_multiple.eml") - assert_equal email.delivered_to, ["equipe@evolix.net", "alert3@evolix.fr", "root@stratis-www01.evolix.net"] + expected = ["delivered-to-1@example.com", "delivered-to-2@example.com", "delivered-to-3@example.com"] + actual = email.delivered_to + + assert_equal expected, actual + end + + test "missing delivered-to fallback to To field" do + email = email_from_eml("delivered_to_missing.eml") + + expected = ["to-foo@example.com"] + actual = email.delivered_to + + assert_equal expected, actual + end + + test "single ticket" do + email = email_from_eml("tickets_single.eml") + + expected = "49123" + actual = email.tickets + + assert_equal expected, actual + end + + test "multiple tickets" do + email = email_from_eml("tickets_multiple.eml") + + expected = ["49123", "12345"] + actual = email.tickets + + assert_equal expected, actual + end + + test "single client" do + email = email_from_eml("clients_single.eml") + + expected = "42QUUX4567" + actual = email.clients + + assert_equal expected, actual + end + + test "multiple clients" do + email = email_from_eml("clients_multiple.eml") + + expected = ["42QUUX4567", "75FOOB0123"] + actual = email.clients + + assert_equal expected, actual end end