Create benign email test fixture (#2445)

1. The previous one was an Ebay email and flagged by AVs, create something simple.
2. Add test case for another header
This commit is contained in:
Chris Gillespie 2020-08-29 09:57:50 -07:00 committed by GitHub
parent e3c4d82798
commit 0390ec97f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 98 deletions

View file

@ -2,7 +2,7 @@ use nu_test_support::{nu, pipeline};
const TEST_CWD: &str = "tests/fixtures/formats"; const TEST_CWD: &str = "tests/fixtures/formats";
// The To field in this email is just "username@domain.com", which gets parsed out as the Address. The Name is empty. // The To field in this email is just "to@example.com", which gets parsed out as the Address. The Name is empty.
#[test] #[test]
fn from_eml_get_to_field() { fn from_eml_get_to_field() {
let actual = nu!( let actual = nu!(
@ -17,7 +17,7 @@ fn from_eml_get_to_field() {
) )
); );
assert_eq!(actual.out, "username@domain.com"); assert_eq!(actual.out, "to@example.com");
let actual = nu!( let actual = nu!(
cwd: TEST_CWD, cwd: TEST_CWD,
@ -34,7 +34,7 @@ fn from_eml_get_to_field() {
assert_eq!(actual.out, ""); assert_eq!(actual.out, "");
} }
// The Reply-To field in this email is "aw-confirm@ebay.com" <aw-confirm@ebay.com>, meaning both the Name and Address values are identical. // The Reply-To field in this email is "replyto@example.com" <replyto@example.com>, meaning both the Name and Address values are identical.
#[test] #[test]
fn from_eml_get_replyto_field() { fn from_eml_get_replyto_field() {
let actual = nu!( let actual = nu!(
@ -49,7 +49,7 @@ fn from_eml_get_replyto_field() {
) )
); );
assert_eq!(actual.out, "aw-confirm@ebay.com"); assert_eq!(actual.out, "replyto@example.com");
let actual = nu!( let actual = nu!(
cwd: TEST_CWD, cwd: TEST_CWD,
@ -63,10 +63,9 @@ fn from_eml_get_replyto_field() {
) )
); );
assert_eq!(actual.out, "aw-confirm@ebay.com"); assert_eq!(actual.out, "replyto@example.com");
} }
// The Reply-To field in this email is "aw-confirm@ebay.com" <aw-confirm@ebay.com>, meaning both the Name and Address values are identical.
#[test] #[test]
fn from_eml_get_subject_field() { fn from_eml_get_subject_field() {
let actual = nu!( let actual = nu!(
@ -80,5 +79,21 @@ fn from_eml_get_subject_field() {
) )
); );
assert_eq!(actual.out, "Billing Issues"); assert_eq!(actual.out, "Test Message");
}
#[test]
fn from_eml_get_another_header_field() {
let actual = nu!(
cwd: TEST_CWD,
pipeline(
r#"
open sample.eml
| get MIME-Version
| echo $it
"#
)
);
assert_eq!(actual.out, "1.0");
} }

View file

@ -1,97 +1,20 @@
Return-Path: <aw-confirm@ebay.com>
X-Original-To: username@domain.com
Delivered-To: username@domain.com
Received: from 81.18.87.130 (unknown [81.18.87.190])
by spanky.domain.com (Postfix) with SMTP id CCC115378FC
for <username@domain.com>; Sat, 27 Nov 2004 15:33:24 -0500 (EST)
Received: from 20.84.152.113 by 65.23.81.142; Sat, 27 Nov 2004 15:24:27 -0500
Message-ID: <LCCOVYFMRBWQCHUDWYCOYUW@hotmail.com>
From: "aw-confirm@ebay.com" <aw-confirm@ebay.com>
Reply-To: "aw-confirm@ebay.com" <aw-confirm@ebay.com>
To: username@domain.com
Subject: Billing Issues
Date: Sun, 28 Nov 2004 00:30:27 +0400
MIME-Version: 1.0 MIME-Version: 1.0
Content-Type: multipart/alternative; Date: Fri, 28 Aug 2020 13:59:02 -0700
boundary="--591699981497957" Message-ID: <CAOSGo93NuHieXLAKy6iC-0fqO_CxFtUO9asdzyAzdG6wLjGeouw@example.com>
X-Priority: 3 Subject: Test Message
X-CS-IP: 224.248.218.116 From: "from@example.com" <from@example.com>
Status: O Reply-To: "replyto@example.com" <replyto@example.com>
X-Status: To: to@example.com
X-Keywords: Content-Type: multipart/alternative; boundary="0000000000009d71fb05adf6528a"
X-UID: 1
----591699981497957 --0000000000009d71fb05adf6528a
Content-Type: text/html; Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<html> Test Message
<p>
<A target=3D"_blank"
href=3D"http://click3.ebay.com/99019653.50692.0.20283"
><IMG
src=3D"http://emailpics3.ebay.com/627422250/images/logo-18.gif"
border=3D0></A></p>
<p><br>
<FONT SIZE=3D2 PTSIZE=3D10 FAMILY=3D"SANSSERIF"
FACE=3D"Arial" LANG=3D"0"><FONT SIZE=3D2 PTSIZE=3D10
FAMILY=3D"SANSSERIF" FACE=3D"Arial" LANG=3D"0">Dear valued
eBay member:<BR>
<BR>
We recently have determined that different computers
have logged onto your eBay account, and multiple
password failures were present before the logons. We
now need you to re-confirm your account information to
us. If this is not completed by <strong>November 30,
2004</strong>, we will be forced to suspend your
account indefinitely, as it may have been used for
fraudulent purposes. We thank you for your cooperation
in this manner.</FONT>
<p>To confirm your eBay records click here: <br>
<a
HREF=3Dhttp://140.130.108.11/account/aw-confirm/ebayDLLupdate/index.html
target=3D"_self">http://cgi1.ebay.com/aw-cgi/ebayISAPI.dll?UPdate</a></p>
<p><font size=3D"2" face=3D"Arial, Helvetica,
sans-serif"><font color=3D"#000000">We appreciate your
support and understanding, as we work together to keep
eBay a safe place to trade.</font></font><font
color=3D"#000000" size=3D"2" face=3D"Arial, Helvetica,
sans-serif"><BR>
Thank you for your patience in this matter.</font><br>
<br>
</p>
<p><font color=3D"#000000" size=3D"2" face=3D"Arial,
Helvetica, sans-serif">Trust and Safety
Department</font><br>
<font color=3D"#000000" size=3D"2" face=3D"Arial,
Helvetica, sans-serif">eBay Inc.</font></p>
<p><font size=3D"2" face=3D"Arial, Helvetica,
sans-serif"><font color=3D"#999999" size=3D"1">Please do
not reply to this e-mail as this is only a
notification. Mail sent to this address cannot be
answered. </font></font></p>
<p><font color=3D"#000000" size=3D"1" face=3D"Arial,
Helvetica, sans-serif"><font color=3D"black"><span
style=3D"color: black;">Copyright 1995-2004 <a
target=3D"_blank"
href=3D"http://pages.ebay.com/community/aboutebay/index.html">eBay
Inc.</a> All Rights Reserved. Designated trademarks
and brands are the property of their respective
owners. Use of this Web site constitutes acceptance of
the eBay <a target=3D"_blank"
href=3D"http://pages.ebay.com/help/community/png-user.html">User
Agreement</a> and <a target=3D"_blank"
href=3D"http://pages.ebay.com/help/community/png-priv.html">Privacy
Policy</a>.</span> </font></font><font color=3D"#000000"
size=3D"1" face=3D"Arial,
Helvetica, sans-serif">Designated trademarks and
brands are the property of their respective owners.
eBay and the eBay logo are trademarks of eBay Inc.
eBay is located at 2145 Hamilton Avenue, San Jose, CA
95125. </font><br>
</p>
</html>
--0000000000009d71fb05adf6528a
Content-Type: text/html; charset="UTF-8"
<div dir="ltr">Test Message</div>
----591699981497957-- --0000000000009d71fb05adf6528a--