package main_test
import (
"sort"
s "github.com/carlostrub/sisyphus"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Mail", func() {
Context("Maildir", func() {
It("Create a slice of mail keys", func() {
result, err := s.Index("test/Maildir")
Ω(err).ShouldNot(HaveOccurred())
Ω(result).Should(Equal(
[]*s.Mail{
{
Key: "1488230510.M141612P8565.mail.carlostrub.ch,S=5978,W=6119",
Subject: nil,
Body: nil,
Junk: false,
},
{
Key: "1488181583.M633084P4781.mail.carlostrub.ch,S=708375,W=720014",
Subject: nil,
Body: nil,
Junk: true,
},
{
Key: "1488226337.M327824P8269.mail.carlostrub.ch,S=8044,W=8167",
Subject: nil,
Body: nil,
Junk: true,
},
{
Key: "1488226337.M327825P8269.mail.carlostrub.ch,S=802286,W=812785",
Subject: nil,
Body: nil,
Junk: true,
},
{
Key: "1488228352.M339670P8269.mail.carlostrub.ch,S=12659,W=12782",
Subject: nil,
Body: nil,
Junk: true,
},
{
Key: "1488226337.M327822P8269.mail.carlostrub.ch,S=3620,W=3730",
Subject: nil,
Body: nil,
Junk: true,
},
{
Key: "1488226337.M327833P8269.mail.carlostrub.ch,S=6960,W=7161",
Subject: nil,
Body: nil,
Junk: true,
},
}))
})
It("Fail if Maildir does not exist", func() {
_, err := s.Index("test/DOESNOTEXIST")
Ω(err).Should(HaveOccurred())
})
})
Context("Mail", func() {
It("Load mail content into struct", func() {
m := s.Mail{
Key: "1488226337.M327822P8269.mail.carlostrub.ch,S=3620,W=3730",
Subject: nil,
Body: nil,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).ShouldNot(HaveOccurred())
subject := "hello"
body := "This is a multi-part message in MIME format. ------=_NextPart_000_0032_01D2912F.05324BC6 Content-Type: text/plain; \tcharset=\"cp-850\" Content-Transfer-Encoding: quoted-printable Dear cs, We are looking for employees working remotely. My name is Kari, I am the personnel manager of a large International company. Most of the work you can do from home, that is, at a distance. Salary is $2000-$5300. If you are interested in this offer, please visit Our Site Best regards! ------=_NextPart_000_0032_01D2912F.05324BC6 Content-Type: text/html; \tcharset=\"cp-850\" Content-Transfer-Encoding: quoted-printable
Dear cs,
We are looking for employees working remotely.
My name is Kari, I am the personnel manager of a large International company.
Most of the work you can do from home, that is, at a distance.
Salary is $2000-$5300.
If you are interested in this offer, please visit Our Site
Best regards!
------=_NextPart_000_0032_01D2912F.05324BC6-- "
Ω(m).Should(Equal(
s.Mail{
Key: "1488226337.M327822P8269.mail.carlostrub.ch,S=3620,W=3730",
Subject: &subject,
Body: &body,
Junk: true,
}))
})
It("Fail if Subject has already content", func() {
st := "test"
m := s.Mail{
Key: "1488226337.M327822P8269.mail.carlostrub.ch,S=3620,W=3730",
Subject: &st,
Body: nil,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).Should(HaveOccurred())
})
It("Fail if Body has already content", func() {
b := "test"
m := s.Mail{
Key: "1488226337.M327822P8269.mail.carlostrub.ch,S=3620,W=3730",
Subject: nil,
Body: &b,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).Should(HaveOccurred())
})
It("Clean regular mail content", func() {
m := s.Mail{
Key: "1488226337.M327822P8269.mail.carlostrub.ch,S=3620,W=3730",
Subject: nil,
Body: nil,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).ShouldNot(HaveOccurred())
err = m.Clean()
Ω(err).ShouldNot(HaveOccurred())
subjectOutput := "hello"
bodyOutput := " ------ 000 0032 01d2912f.05324bc6 : ; : dear cs we are looking for employees working remotely my name is kari i am the personnel manager of a large international company most of the work you can do from home that is at a distance salary is 2000- 5300 if you are interested in this offer please visit our site best regards ------ 000 0032 01d2912f.05324bc6 : ; : dear cs we are looking for employees working remotely. my name is kari i am the personnel manager of a large international company. most of the work you can do from home that is at a distance. salary is 2000- 5300. if you are interested in this offer please visit our site best regards ------ 000 0032 01d2912f.05324bc6-- "
Ω(m).Should(Equal(
s.Mail{
Key: "1488226337.M327822P8269.mail.carlostrub.ch,S=3620,W=3730",
Subject: &subjectOutput,
Body: &bodyOutput,
Junk: true,
}))
})
It("Clean mail with base64 content", func() {
m := s.Mail{
Key: "1488181583.M633084P4781.mail.carlostrub.ch,S=708375,W=720014:2,a",
Subject: nil,
Body: nil,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).ShouldNot(HaveOccurred())
err = m.Clean()
Ω(err).ShouldNot(HaveOccurred())
subjectOutput := "confirm remittance"
bodyOutput := " ------ 000 0085 01c2a9a6.0d17aca6 : ; ---- 001 0086 01c2a9a6.0d17aca6 ------ 001 0086 01c2a9a6.0d17aca6 : ; : 7bit pfa remmittance copy value date 27022017 confirm payment detail thanks best regards admin director alliance bank this e-mail has been scanned for all known computer viruses this e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed if you are not the intended recipient you are hereby notified that any dissemination forwarding copying or use of any of the information is strictly prohibited and the e-mail should immediately be deleted cobantur boltas makes no warranty as to the accuracy or completeness of any information contained in this message and hereby excludes any liability of any kind for the information contained therein or for the information transmission reception storage or use of such in any way whatsoever the opinions expressed in this message belong to sender alone and may not necessarily reflect the opinions of cobantur boltas ------ 001 0086 01c2a9a6.0d17aca6 : ; index.jpeg "
Ω(m).Should(Equal(
s.Mail{
Key: "1488181583.M633084P4781.mail.carlostrub.ch,S=708375,W=720014:2,a",
Subject: &subjectOutput,
Body: &bodyOutput,
Junk: true,
}))
})
It("More Junk", func() {
m := s.Mail{
Key: "1488226337.M327824P8269.mail.carlostrub.ch,S=8044,W=8167:2,Sa",
Subject: nil,
Body: nil,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).ShouldNot(HaveOccurred())
err = m.Clean()
Ω(err).ShouldNot(HaveOccurred())
subjectOutput := "herpes breakthrough shocks medical world"
bodyOutput := "--5ba77035ef2d5e8c615e79c26f9448f3 : ; : 8bit --5ba77035ef2d5e8c615e79c26f9448f3 : ; : 8bit i got herpes from this girl at a club but i got rid of it fast with this alert: herpes finally cured by rachael rettner senior writer february 27 2017 studies in mice suggest that gut bacteria can influence anxiety and other mental states. credit: dreamstime view full size image a new drug has successfully combated the virus that causes genital herpes starting today it will be used as a treatment for people with the condition. there have been many topical creams and drugs used as herpes cure treatments these treatments for herpes give short-term relief but only this can remove the virus and prevent re-occurrences to cure herpes. end your embarrassment - cure your herpes were appointed as provincial governors alongside members of the local aristocracy the title of doux was used but unlike earlier times these were mostly civilian governors with little military authority theodore awarded titles with such largesse that erly exclusive titles such as pansebastos sebastos or megalodoxotatos were devalued and came to be held by city notables to secure his new capital theodore instituted a guard of tzakones under a kastrophylax he portrait of a middle-aged man with a dark forked beard wearing a golden jewel-encrusted domed crown john iii doukas vatatzes emperor of nicaea from a 15th-century manuscript of the extracts of history of john zonaras --5ba77035ef2d5e8c615e79c26f9448f3-- "
Ω(m).Should(Equal(
s.Mail{
Key: "1488226337.M327824P8269.mail.carlostrub.ch,S=8044,W=8167:2,Sa",
Subject: &subjectOutput,
Body: &bodyOutput,
Junk: true,
}))
})
It("More Junk", func() {
m := s.Mail{
Key: "1488226337.M327825P8269.mail.carlostrub.ch,S=802286,W=812785",
Subject: nil,
Body: nil,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).ShouldNot(HaveOccurred())
err = m.Clean()
Ω(err).ShouldNot(HaveOccurred())
subjectOutput := "cosan day 2017 new york friday march 24"
bodyOutput := " --97bb499b431c6ea9472ef64c004b1106 : ; b82d2d2d1215b6505c0692de003f7694 --b82d2d2d1215b6505c0692de003f7694 : ; 075713cc6dc6562a324d22c8001fd90a --075713cc6dc6562a324d22c8001fd90a : ; : invitation cosan day 2017 new york friday march 24 2017 venue: park hyatt new york 153 west 57th street between 6th and 7th avenue new york ny 10019 the onyx room second level program 08:30 am registration 09:00 am cosan s/a csan3 presentations and q amp;a 10:45 am rumo s/a rumo3 presentation and q amp;a 11:30 am cosan limited czz presentation and q amp;a 12:10 pm closing and lunch rsvp http://www.invite-taylor-rafferty.com/ cosan/irday2017/default.htm or call briget ampudia at taylor rafferty 212 889 4350 or email cosan taylor-rafferty.com czz listed nyse csan3 novo mercado bm amp;fbovespa cgas5 cgas3 bm amp;fbovespa rlog3 novo mercado bm amp;fbovespa rumo3 novo mercado bm amp;fbovespa --075713cc6dc6562a324d22c8001fd90a : ; : if you cannot download the image below please view invitation and register online here --075713cc6dc6562a324d22c8001fd90a-- --b82d2d2d1215b6505c0692de003f7694 : ; cosan day 2017.jpg "
Ω(m).Should(Equal(
s.Mail{
Key: "1488226337.M327825P8269.mail.carlostrub.ch,S=802286,W=812785",
Subject: &subjectOutput,
Body: &bodyOutput,
Junk: true,
}))
})
It("More Junk", func() {
m := s.Mail{
Key: "1488226337.M327833P8269.mail.carlostrub.ch,S=6960,W=7161:2,Sa",
Subject: nil,
Body: nil,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).ShouldNot(HaveOccurred())
err = m.Clean()
Ω(err).ShouldNot(HaveOccurred())
subjectOutput := "wear glasses your eyes are headed for serious trouble"
bodyOutput := "--c2389532b48d1db204cfca8189242aeb : ; : 8bit --c2389532b48d1db204cfca8189242aeb : ; : 8bit snc .container width: 420px; .container .columns .container .column margin: 0; .container .fourteen.columns .container .fifteen.columns .container .sixteen.columns .container .one-third.column .container .two-thirds.column width: 420px; / self clearing goodness / .container:after content: 0020 ; display: block; height: 0; clear: both; visibility: hidden; .clearfix:before .clearfix:after .row:before .row:after content: 0020; display: block; overflow: hidden; visibility: hidden; width: 0; height: 0; .row:after .clearfix:after clear: both; .row .clearfix zoom: 1; .clear clear: both; display: block; overflow: hidden; visibility: hidden; width: 0; height: 0; if you wear glasses contacts or even if you think your vision can be improved you need to know about this.. in the link below youll discover 1 weird trick that will drastically improve your vision gt; 1 trick to improve your vision today to your success 1 place ville marie 39th floor montreal quebec h3b4m7 canada email marketing by unsu bscribe westcott railway station served the village of westcott buckinghamshire near baron ferdinand de rothschilds estate at manor it was built by the duke of buckingham in 1871 as part of a short horse-drawn tramway that met the aylesbury and buckingham railway at quainton the next year it was converted for passenger use extended to brill railway station and renamed the brill tramway the poor quality locomotives running on the built and line were very slow initially limited to 5 miles per hour 8 km/h the line was taken over by the metropolitan railway in 1899 and transferred to public ownership in 1933 westcott station became part of the london underground despite being over 40 miles 60 km from central london until the closure of the line in 1935 the station building and its associated house pictured are the only significant buildings from the brill tramway to survive other than the junction station at quainton full article.. --c2389532b48d1db204cfca8189242aeb-- "
Ω(m).Should(Equal(
s.Mail{
Key: "1488226337.M327833P8269.mail.carlostrub.ch,S=6960,W=7161:2,Sa",
Subject: &subjectOutput,
Body: &bodyOutput,
Junk: true,
}))
})
It("More Junk", func() {
m := s.Mail{
Key: "1488228352.M339670P8269.mail.carlostrub.ch,S=12659,W=12782:2,Sa",
Subject: nil,
Body: nil,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).ShouldNot(HaveOccurred())
err = m.Clean()
Ω(err).ShouldNot(HaveOccurred())
subjectOutput := "always in good form with our viagra super active."
bodyOutput := " body .maintable height:100 important; width:100 important; margin:0; padding:0; img a img border:0; outline:none; text-decoration:none; .imagefix display:block; table td border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; p margin:0; padding:0; margin-bottom:0; .readmsgbody width:100 ; .externalclass width:100 ; .externalclass .externalclass p .externalclass span .externalclass font .externalclass td .externalclass div line-height:100 ; img -ms-interpolation-mode: bicubic; body table td p a li blockquote -ms-text-size-adjust:100 ; -webkit-text-size-adjust:100 ; 96 \u00a0 if you cant read this email please view it online http://6url.ru/lhcj \u00a0 most popular products and special deals limited time offer hola the leading online store presents pharmaceuticals with delivery service in europe the united states and canada you can buy anti-acidity antifungals blood pressure herpes medication antifungals antibiotics anti-depressant diabetes medication antiviral anti-allergy/asthma and other various products keep your eye out for discount when purchasing\u00a0\u00a0\u00a0 check it now amazon web services inc is a subsidiary of amazon.com inc amazon.com is a registered trademark of amazon.com inc this message was produced and distributed by amazon web services inc 410 terry ave north seattle.https://aws.amazon.com/support if you no longer wish to receive these emails simply click on the following link unsubscribe © 2016 amazon all rights reserved \u00a0 "
Ω(m).Should(Equal(
s.Mail{
Key: "1488228352.M339670P8269.mail.carlostrub.ch,S=12659,W=12782:2,Sa",
Subject: &subjectOutput,
Body: &bodyOutput,
Junk: true,
}))
})
It("Wordlist 1", func() {
m := s.Mail{
Key: "1488181583.M633084P4781.mail.carlostrub.ch,S=708375,W=720014:2,a",
Subject: nil,
Body: nil,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).ShouldNot(HaveOccurred())
err = m.Clean()
Ω(err).ShouldNot(HaveOccurred())
subject, body, err := m.Wordlists()
sort.Strings(subject)
sort.Strings(body)
Ω(err).ShouldNot(HaveOccurred())
Ω(subject).Should(Equal(
[]string{"confirm", "remittance"}))
Ω(body).Should(Equal(
[]string{"accuracy", "addressed", "admin", "alliance", "alone", "bank", "been", "belong", "best", "boltas", "cobantur", "computer", "confirm", "contained", "copy", "copying", "date", "deleted", "detail", "director", "entity", "excludes", "expressed", "files", "forwarding", "hereby", "individual", "intended", "kind", "known", "liability", "makes", "message", "notified", "opinions", "payment", "prohibited", "reception", "recipient", "reflect", "regards", "scanned", "sender", "should", "solely", "storage", "strictly", "such", "thanks", "that", "therein", "they", "this", "value", "viruses", "warranty", "whatsoever", "whom", "with"}))
})
It("Wordlist 2", func() {
m := s.Mail{
Key: "1488226337.M327822P8269.mail.carlostrub.ch,S=3620,W=3730:2,Sa",
Subject: nil,
Body: nil,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).ShouldNot(HaveOccurred())
err = m.Clean()
Ω(err).ShouldNot(HaveOccurred())
subject, body, err := m.Wordlists()
sort.Strings(subject)
sort.Strings(body)
Ω(err).ShouldNot(HaveOccurred())
Ω(subject).Should(Equal(
[]string{"hello"}))
Ω(body).Should(Equal(
[]string{"best", "company", "dear", "distance", "employees", "from", "home", "interested", "kari", "large", "looking", "manager", "most", "name", "offer", "personnel", "please", "regards", "remotely", "salary", "site", "that", "this", "visit", "work", "working"}))
})
It("Wordlist 3", func() {
m := s.Mail{
Key: "1488226337.M327824P8269.mail.carlostrub.ch,S=8044,W=8167:2,Sa",
Subject: nil,
Body: nil,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).ShouldNot(HaveOccurred())
err = m.Clean()
Ω(err).ShouldNot(HaveOccurred())
subject, body, err := m.Wordlists()
sort.Strings(subject)
sort.Strings(body)
Ω(err).ShouldNot(HaveOccurred())
Ω(subject).Should(Equal(
[]string{"herpes", "medical", "shocks", "world"}))
Ω(body).Should(Equal(
[]string{"alongside", "anxiety", "appointed", "authority", "awarded", "bacteria", "beard", "been", "came", "capital", "causes", "city", "civilian", "club", "combated", "creams", "crown", "cure", "cured", "dark", "devalued", "domed", "doukas", "doux", "dreamstime", "drug", "drugs", "earlier", "emperor", "erly", "exclusive", "extracts", "fast", "february", "finally", "forked", "from", "full", "genital", "girl", "give", "golden", "governors", "guard", "have", "held", "herpes", "history", "image", "influence", "instituted", "john", "largesse", "little", "local", "manuscript", "many", "members", "mental", "mice", "military", "mostly", "nicaea", "notables", "only", "other", "people", "portrait", "prevent", "provincial", "rachael", "relief", "remove", "rettner", "sebastos", "secure", "senior", "size", "starting", "studies", "such", "suggest", "that", "theodore", "there", "these", "this", "times", "title", "titles", "today", "topical", "treatment", "treatments", "tzakones", "under", "unlike", "used", "vatatzes", "view", "virus", "wearing", "were", "will", "with", "writer", "your", "zonaras"}))
})
It("Wordlist 4", func() {
m := s.Mail{
Key: "1488226337.M327825P8269.mail.carlostrub.ch,S=802286,W=812785:2,Sa",
Subject: nil,
Body: nil,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).ShouldNot(HaveOccurred())
err = m.Clean()
Ω(err).ShouldNot(HaveOccurred())
subject, body, err := m.Wordlists()
sort.Strings(subject)
sort.Strings(body)
Ω(err).ShouldNot(HaveOccurred())
Ω(subject).Should(Equal(
[]string{"cosan", "friday", "march", "york"}))
Ω(body).Should(Equal(
[]string{"ampudia", "avenue", "below", "between", "briget", "call", "cannot", "closing", "cosan", "download", "email", "friday", "here", "hyatt", "image", "invitation", "level", "limited", "listed", "lunch", "march", "mercado", "novo", "nyse", "online", "onyx", "park", "please", "program", "rafferty", "register", "room", "rsvp", "rumo", "second", "street", "taylor", "view", "west", "york"}))
})
It("Wordlist 5", func() {
m := s.Mail{
Key: "1488226337.M327833P8269.mail.carlostrub.ch,S=6960,W=7161:2,Sa",
Subject: nil,
Body: nil,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).ShouldNot(HaveOccurred())
err = m.Clean()
Ω(err).ShouldNot(HaveOccurred())
subject, body, err := m.Wordlists()
sort.Strings(subject)
sort.Strings(body)
Ω(err).ShouldNot(HaveOccurred())
Ω(subject).Should(Equal(
[]string{"eyes", "glasses", "headed", "serious", "trouble", "wear", "your"}))
Ω(body).Should(Equal(
[]string{"about", "associated", "aylesbury", "baron", "became", "being", "below", "brill", "bscribe", "buckingham", "building", "buildings", "built", "canada", "central", "clearing", "closure", "contacts", "converted", "despite", "discover", "duke", "email", "estate", "even", "extended", "ferdinand", "floor", "from", "full", "glasses", "goodness", "hour", "house", "improve", "improved", "initially", "junction", "know", "limited", "line", "link", "london", "manor", "marie", "marketing", "miles", "montreal", "near", "need", "next", "only", "other", "over", "ownership", "part", "passenger", "pictured", "place", "poor", "public", "quainton", "quality", "quebec", "railway", "renamed", "running", "self", "served", "short", "slow", "station", "success", "survive", "taken", "than", "that", "think", "today", "tramway", "trick", "unsu", "until", "very", "village", "ville", "vision", "wear", "weird", "were", "westcott", "will", "year", "youll", "your"}))
})
It("Wordlist 6", func() {
m := s.Mail{
Key: "1488228352.M339670P8269.mail.carlostrub.ch,S=12659,W=12782:2,Sa",
Subject: nil,
Body: nil,
Junk: true,
}
err := m.Load("test/Maildir" + "/.Junk")
Ω(err).ShouldNot(HaveOccurred())
err = m.Clean()
Ω(err).ShouldNot(HaveOccurred())
subject, body, err := m.Wordlists()
sort.Strings(subject)
sort.Strings(body)
Ω(err).ShouldNot(HaveOccurred())
Ω(subject).Should(Equal(
[]string{"always", "form", "good", "super", "viagra", "with"}))
Ω(body).Should(Equal(
[]string{"amazon", "antiviral", "blockquote", "blood", "body", "canada", "cant", "check", "click", "deals", "delivery", "diabetes", "discount", "email", "emails", "europe", "following", "font", "herpes", "hola", "keep", "leading", "limited", "link", "longer", "medication", "message", "most", "north", "offer", "online", "other", "please", "popular", "presents", "pressure", "produced", "products", "read", "receive", "registered", "reserved", "rights", "service", "services", "simply", "span", "special", "states", "store", "subsidiary", "table", "terry", "these", "this", "time", "trademark", "united", "various", "view", "when", "wish", "with", "your"}))
})
})
})