Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
csucu committed Sep 4, 2023
1 parent a1c4fcf commit 8f9dca2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
17 changes: 9 additions & 8 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]",
},
}

Expand Down Expand Up @@ -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},
}

Expand Down Expand Up @@ -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)},
},
Expand Down

0 comments on commit 8f9dca2

Please sign in to comment.