Skip to content

Commit

Permalink
Add another test case based on new cleaner messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
mstevens committed Apr 20, 2010
1 parent 330cf45 commit 1f38451
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Email/ARF/Hotmail.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ our @EXPORT = qw(
);

our $VERSION = '0.05-alpha';
our $VERSION = '0.05';
$VERSION = eval $VERSION;

use constant HOTMAIL_SENDER => '[email protected]';
Expand Down
74 changes: 74 additions & 0 deletions t/corpus/hotmail-complaint.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Delivered-To: [email protected]
Received: by 10.239.193.68 with SMTP id h4cs332821hbi;
Tue, 20 Apr 2010 06:16:38 -0700 (PDT)
Received: by 10.101.145.35 with SMTP id x35mr16241647ann.236.1271769394998;
Tue, 20 Apr 2010 06:16:34 -0700 (PDT)
Return-Path: <[email protected]>
Received: from bay0-omc2-s13.bay0.hotmail.com (bay0-omc2-s13.bay0.hotmail.com [65.54.190.88])
by mx.google.com with ESMTP id z7si17174481ank.82.2010.04.20.06.16.34;
Tue, 20 Apr 2010 06:16:34 -0700 (PDT)
Received-SPF: pass (google.com: domain of [email protected] designates 65.54.190.88 as permitted sender) client-ip=65.54.190.88;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of [email protected] designates 65.54.190.88 as permitted sender) [email protected]
Received: from BAY0-JMR-DB02 ([65.54.190.125]) by bay0-omc2-s13.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959);
Tue, 20 Apr 2010 06:16:33 -0700
Date: Tue, 20 Apr 10 06:16:33 -0700
From: [email protected]
Subject: complaint about message from 5.6.7.8
To: [email protected]
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="C7EB3CC8-9FC0-40B0-9791-3417722338E4"
Return-Path: [email protected]
Message-ID: <[email protected]>
X-OriginalArrivalTime: 20 Apr 2010 13:16:33.0911 (UTC) FILETIME=[B2D8D070:01CAE08B]

--C7EB3CC8-9FC0-40B0-9791-3417722338E4
Content-Type: message/rfc822
Content-Disposition: inline

X-HmXmrOriginalRecipient: [email protected]
X-Reporter-IP: 99.99.99.99
X-Message-Delivery: Vj0xLjE7dXM9MDtsPTA7YT0wO0Q9MTtTQ0w9Mw==
X-Message-Status: n:0
X-SID-PRA: John Smith <[email protected]>
X-SID-Result: Pass
X-AUTH-Result: PASS
X-Message-Info: /Afko6AgMSzR+GtmoXnTOBDadFZsZAuuOvmMsNSoDUIh5hy8pENL+6i/MkJyEqTm+wMNYmkYBV4apGzk/hrbuIf8CXXqRYIH
Received: from server4.example.co.uk ([94.236.45.212]) by snt0-mc4-f41.Snt0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959);
Tue, 20 Apr 2010 05:46:45 -0700
Received: by server4.example.co.uk (Postfix, from userid 505)
id 7B5911658274; Tue, 20 Apr 2010 13:46:44 +0100 (BST)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=email.example.com;
s=default10; t=1271767604;
bh=oc2w0vJOflLXBUeavWX0PGS74yERJAR5PzeMPamgnkk=;
h=MIME-Version:Content-Transfer-Encoding:Content-Type:Date:From:
Subject:List-Unsubscribe:To:Message-Id;
b=YqhpwXpAILFSYdqqJ7StYO9IvGLMYWo8EYZ8lviIprIb2z7EwIkWfiqOwG4/K6XeW
R2Cj/xQo7VQDSWsMZAcprrTIe4udfDmJSF2pY+oXmGPFadpheR3/FDKc1qJvMV9Z19
ax1M95VeP1jqN0Qr8qIxl1MRx7zDPfqnJ+MeQNRE=
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: multipart/related; boundary="_----------=_12717676043827782"
X-Mailer: MIME::Lite 3.027 (F2.77; T1.28; A2.04; B3.08; Q3.08)
Date: Tue, 20 Apr 2010 13:46:44 +0100
From: John Smith <[email protected]>
Subject: xxx
X-Campaignid: xxx
List-Unsubscribe: <http://www.example.co.uk/unsubscribe.epl?uuid=C6870D98-4C7A-11DF-8D9D-867427AE845C>
To: Jane Smith <[email protected]>
Message-Id: <[email protected]>
Return-Path: automated-bounces+C6870D98-4C7A-11DF-8D9D-867427AE845C@email.example.com
X-OriginalArrivalTime: 20 Apr 2010 12:46:45.0323 (UTC) FILETIME=[88C3F1B0:01CAE087]

This is a multi-part message in MIME format.

--_----------=_12717676043827782
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html

hello=
world
--_----------=_12717676043827782--


--C7EB3CC8-9FC0-40B0-9791-3417722338E4--
38 changes: 38 additions & 0 deletions t/hotmail-complaint.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/perl -w

use strict;
use Test::More tests => 8;

use Email::ARF::Hotmail;

# FH because we're being backcompat to pre-lexical
sub readfile {
my $fn = shift;
open FH, "$fn" or die $!;
local $/;
my $text = <FH>;
close FH;
return $text;
}

my $message = readfile('t/corpus/hotmail-complaint.msg');

my $report = Email::ARF::Hotmail->create_report($message);

my $des = $report->description;
chomp $des;

is($des, "An email abuse report from hotmail", "description is right");
is($report->field("Source-IP"), "5.6.7.8", "source IP is right");
is($report->field("Feedback-Type"), "abuse", "feedback type is right");
is($report->field("User-Agent"), "Email::ARF::Hotmail-conversion", "user agent is right");
is($report->field("Version"), "0.1", "version is right");
is($report->field("Original-Rcpt-To"), '[email protected]', "Original rcpt to is right");

is($report->original_email->header("From"), 'John Smith <[email protected]>', "Original email from is right");
my @parts = $report->original_email->parts;

my $body = $parts[0]->body;

like($body, qr/^helloworld/, "original mail body is right");

0 comments on commit 1f38451

Please sign in to comment.