author | Alberto Bertogli
<albertito@blitiri.com.ar> 2020-09-20 14:45:31 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2020-09-20 14:50:43 UTC |
parent | 41d86b0894b2f5c3c6d0f3124e0b2080fe9f2542 |
spf.go | +2 | -1 |
spf_test.go | +16 | -0 |
diff --git a/spf.go b/spf.go index 42ee8d5..3d9dfda 100644 --- a/spf.go +++ b/spf.go @@ -42,7 +42,8 @@ var ( lookupMX = net.DefaultResolver.LookupMX lookupIP = net.DefaultResolver.LookupIP lookupAddr = net.DefaultResolver.LookupAddr - trace = func(f string, a ...interface{}) {} + nullTrace = func(f string, a ...interface{}) {} + trace = nullTrace ) // The Result of an SPF check. Note the values have meaning, we use them in diff --git a/spf_test.go b/spf_test.go index 1d7c9f7..db94c25 100644 --- a/spf_test.go +++ b/spf_test.go @@ -452,6 +452,22 @@ func TestInvalidMacro(t *testing.T) { } } +// Test that the null tracer doesn't cause unexpected issues, since all the +// other tests override it. +func TestNullTrace(t *testing.T) { + dns := NewDefaultResolver() + trace = nullTrace + + dns.txt["domain1"] = []string{"v=spf1 include:domain2"} + dns.txt["domain2"] = []string{"v=spf1 +all"} + + // Do a normal resolution, check it passes. + res, err := CheckHostWithSender(ip1111, "helo", "user@domain1") + if res != Pass { + t.Errorf("expected pass, got %q / %q", res, err) + } +} + func TestOverrideLookupLimit(t *testing.T) { dns = NewDNS() trace = t.Logf