github.com/teknogeek/dnscontrol@v0.2.8/pkg/spflib/parse_test.go (about) 1 package spflib 2 3 import ( 4 "strings" 5 "testing" 6 ) 7 8 func TestParse(t *testing.T) { 9 dnsres, err := NewCache("testdata-dns1.json") 10 if err != nil { 11 t.Fatal(err) 12 } 13 rec, err := Parse(strings.Join([]string{"v=spf1", 14 "ip4:198.252.206.0/24", 15 "ip4:192.111.0.0/24", 16 "include:_spf.google.com", 17 "include:mailgun.org", 18 "include:spf-basic.fogcreek.com", 19 "include:mail.zendesk.com", 20 "include:servers.mcsv.net", 21 "include:sendgrid.net", 22 "include:spf.mtasv.net", 23 "exists:%{i}._spf.sparkpostmail.com", 24 "ptr:sparkpostmail.com", 25 "~all"}, " "), dnsres) 26 if err != nil { 27 t.Fatal(err) 28 } 29 t.Log(rec.Print()) 30 } 31 32 func TestParseWithDoubleSpaces(t *testing.T) { 33 dnsres, err := NewCache("testdata-dns1.json") 34 if err != nil { 35 t.Fatal(err) 36 } 37 rec, err := Parse("v=spf1 ip4:192.111.0.0/24 ip4:192.111.1.0/24 -all", dnsres) 38 if err != nil { 39 t.Fatal(err) 40 } 41 t.Log(rec.Print()) 42 }