"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "svcb_test.go" between
dns-1.1.48.tar.gz and dns-1.1.49.tar.gz

About: GO DNS implements a DNS library in Go.

svcb_test.go  (dns-1.1.48):svcb_test.go  (dns-1.1.49)
skipping to change at line 21 skipping to change at line 21
key string key string
data string data string
}{ }{
{`mandatory`, `alpn,key65000`}, {`mandatory`, `alpn,key65000`},
{`alpn`, `h2,h2c`}, {`alpn`, `h2,h2c`},
{`port`, `499`}, {`port`, `499`},
{`ipv4hint`, `3.4.3.2,1.1.1.1`}, {`ipv4hint`, `3.4.3.2,1.1.1.1`},
{`no-default-alpn`, ``}, {`no-default-alpn`, ``},
{`ipv6hint`, `1::4:4:4:4,1::3:3:3:3`}, {`ipv6hint`, `1::4:4:4:4,1::3:3:3:3`},
{`ech`, `YUdWc2JHOD0=`}, {`ech`, `YUdWc2JHOD0=`},
{`dohpath`, `/dns-query{?dns}`},
{`key65000`, `4\ 3`}, {`key65000`, `4\ 3`},
{`key65001`, `\"\ `}, {`key65001`, `\"\ `},
{`key65002`, ``}, {`key65002`, ``},
{`key65003`, `=\"\"`}, {`key65003`, `=\"\"`},
{`key65004`, `\254\ \ \030\000`}, {`key65004`, `\254\ \ \030\000`},
} }
for _, o := range svcbs { for _, o := range svcbs {
keyCode := svcbStringToKey(o.key) keyCode := svcbStringToKey(o.key)
kv := makeSVCBKeyValue(keyCode) kv := makeSVCBKeyValue(keyCode)
skipping to change at line 97 skipping to change at line 98
}, },
} }
for _, o := range svcbs { for _, o := range svcbs {
err := makeSVCBKeyValue(SVCBKey(o.key)).unpack(o.data) err := makeSVCBKeyValue(SVCBKey(o.key)).unpack(o.data)
if err == nil { if err == nil {
t.Error("accepted invalid svc value with key ", SVCBKey(o .key).String()) t.Error("accepted invalid svc value with key ", SVCBKey(o .key).String())
} }
} }
} }
func TestPresentationSVCBAlpn(t *testing.T) {
tests := map[string]string{
"h2": "h2",
"http": "http",
"\xfa": `\250`,
"some\"other,chars": `some\"other\\\044chars`,
}
for input, want := range tests {
e := new(SVCBAlpn)
e.Alpn = []string{input}
if e.String() != want {
t.Errorf("improper conversion with String(), wanted %v go
t %v", want, e.String())
}
}
}
func TestSVCBAlpn(t *testing.T) {
tests := map[string][]string{
`. 1 IN SVCB 10 one.test. alpn=h2`:
{"h2"},
`. 2 IN SVCB 20 two.test. alpn=h2,h3-19`:
{"h2", "h3-19"},
`. 3 IN SVCB 30 three.test. alpn="f\\\\oo\\,bar,h2"`:
{`f\oo,bar`, "h2"},
`. 4 IN SVCB 40 four.test. alpn="part1,part2,part3\\,part4\\\\"`:
{"part1", "part2", `part3,part4\`},
`. 5 IN SVCB 50 five.test. alpn=part1\,\p\a\r\t2\044part3\092,par
t4\092\\`: {"part1", "part2", `part3,part4\`},
}
for s, v := range tests {
rr, err := NewRR(s)
if err != nil {
t.Error("failed to parse RR: ", err)
continue
}
alpn := rr.(*SVCB).Value[0].(*SVCBAlpn).Alpn
if len(v) != len(alpn) {
t.Fatalf("parsing alpn failed, wanted %v got %v", v, alpn
)
}
for i := range v {
if v[i] != alpn[i] {
t.Fatalf("parsing alpn failed, wanted %v got %v",
v, alpn)
}
}
}
}
func TestCompareSVCB(t *testing.T) { func TestCompareSVCB(t *testing.T) {
val1 := []SVCBKeyValue{ val1 := []SVCBKeyValue{
&SVCBPort{ &SVCBPort{
Port: 117, Port: 117,
}, },
&SVCBAlpn{ &SVCBAlpn{
Alpn: []string{"h2", "h3"}, Alpn: []string{"h2", "h3"},
}, },
} }
val2 := []SVCBKeyValue{ val2 := []SVCBKeyValue{
 End of changes. 2 change blocks. 
0 lines changed or deleted 51 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)