From 8f9dca2dc163e6c2072a85da5606972020b0d38b Mon Sep 17 00:00:00 2001 From: csucu Date: Mon, 4 Sep 2023 09:49:42 +0100 Subject: [PATCH] update tests --- parser.go | 4 ++-- parser_test.go | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/parser.go b/parser.go index 4de2078..18258f1 100644 --- a/parser.go +++ b/parser.go @@ -209,10 +209,10 @@ func (p *parser) checkHost(ip net.IP, domain, sender string) (r Result, expl str // more than one record, check_host() produces the "permerror" result. spf, err = filterSPF(txts) if err != nil { - return Permerror, "", "", err + return Permerror, "", "", SpfError{kind: Validation, err: err} } if spf == "" { - return None, "", "", ErrSPFNotFound + return None, "", "", SpfError{kind: Validation, err: ErrSPFNotFound} } r, expl, u, err = newParserWithVisited(p.visited, p.fireFirstMatchOnce, p.options...).with(spf, sender, domain, ip).check() diff --git a/parser_test.go b/parser_test.go index 0e8da2f..86e32c7 100644 --- a/parser_test.go +++ b/parser_test.go @@ -1087,13 +1087,13 @@ func TestCheckHost_RecursionLoop(t *testing.T) { "v=spf1 include:loop.matching.net -all", net.IP{10, 0, 0, 1}, Permerror, - "infinite recursion detected [include:loop.matching.net include:loop1.matching.net include:loop2.matching.net include:loop.matching.net]", + "infinite recursion detected [include:loop.matching.net include:loop1.matching.net include:loop2.matching.net include:loop.matching.net ]", }, { "v=spf1 redirect=loop.matching.net", net.IP{10, 0, 0, 1}, Permerror, - "infinite recursion detected [include:loop1.matching.net include:loop2.matching.net include:loop.matching.net]", + "infinite recursion detected [include:loop1.matching.net include:loop2.matching.net include:loop.matching.net ]", }, } @@ -1322,11 +1322,11 @@ func TestSelectingRecord(t *testing.T) { r Result e error }{ - {"notexists", None, DNSError{err: ErrDNSPermerror}}, - {"v-spf2", None, ValidationError{err: ErrSPFNotFound}}, - {"v-spf10", None, ValidationError{err: ErrSPFNotFound}}, - {"no-record", None, ValidationError{err: ErrSPFNotFound}}, - {"many-records", Permerror, ValidationError{err: ErrTooManySPFRecords}}, + {"notexists", None, SpfError{kind: DNS, err: ErrDNSPermerror}}, + {"v-spf2", None, SpfError{kind: Validation, err: ErrSPFNotFound}}, + {"v-spf10", None, SpfError{kind: Validation, err: ErrSPFNotFound}}, + {"no-record", None, SpfError{kind: Validation, err: ErrSPFNotFound}}, + {"many-records", Permerror, SpfError{kind: Validation, err: ErrTooManySPFRecords}}, {"mixed-records", Pass, nil}, } @@ -1401,8 +1401,9 @@ func TestCheckHost_Loops(t *testing.T) { { "normal mode", "ab.example.com", Permerror, SpfError{ + Validation, &token{tInclude, qPlus, "ba.example.com"}, - SpfError{&token{tInclude, qPlus, "ab.example.com"}, ErrLoopDetected}, + SpfError{Validation, &token{tInclude, qPlus, "ab.example.com"}, SpfError{kind: Validation, err: ErrLoopDetected}}, }, []Option{WithResolver(testResolver)}, },