Quic tests
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
grumbulon 2022-07-01 12:38:30 -04:00
parent 345ae3a0eb
commit 494998b88d
1 changed files with 47 additions and 0 deletions

View File

@ -2,6 +2,8 @@ package query
import (
"fmt"
"net"
"strconv"
"strings"
"testing"
@ -63,3 +65,48 @@ func Test3ResolveHTTPS(t *testing.T) {
assert.Nil(t, in)
}
func TestQuic(t *testing.T) {
var err error
testCase := util.Answers{Server: "dns.adguard.com", Request: dns.TypeA, Name: "git.froth.zone"}
testCase2 := util.Answers{Server: "dns.adguard.com", Request: dns.TypeA, Name: "git.froth.zone"}
var testCases []util.Answers
testCases = append(testCases, testCase)
testCases = append(testCases, testCase2)
for i := range testCases {
switch i {
case 0:
port := 853
testCases[i].Server = net.JoinHostPort(testCases[i].Server, strconv.Itoa(port))
fmt.Println(testCases[i].Server)
// if the domain is not canonical, make it canonical
if !strings.HasSuffix(testCase.Name, ".") {
testCases[i].Name = fmt.Sprintf("%s.", testCases[i].Name)
}
msg := new(dns.Msg)
msg.SetQuestion(testCase.Name, testCase.Request)
msg = msg.SetQuestion(testCase.Name, testCase.Request)
var in *dns.Msg
in, testCase.RTT, err = ResolveQUIC(msg, testCase.Server)
assert.NotNil(t, err)
assert.Nil(t, in)
case 1:
port := 853
testCases[i].Server = net.JoinHostPort(testCases[i].Server, strconv.Itoa(port))
// if the domain is not canonical, make it canonical
if !strings.HasSuffix(testCase.Name, ".") {
testCases[i].Name = fmt.Sprintf("%s.", testCases[i].Name)
}
msg := new(dns.Msg)
msg.SetQuestion(testCases[i].Name, testCases[i].Request)
msg = msg.SetQuestion(testCases[i].Name, testCases[i].Request)
var in *dns.Msg
in, testCase.RTT, err = ResolveQUIC(msg, testCases[i].Server)
assert.Nil(t, err)
assert.NotNil(t, in)
}
}
}