add support for the version negotiation test

This commit is contained in:
Marten Seemann
2019-11-01 18:26:45 +07:00
parent e0c4c97a46
commit 06d8eda0e9
2 changed files with 20 additions and 1 deletions

View File

@@ -9,8 +9,10 @@ import (
"log"
"net/http"
"os"
"strings"
"github.com/lucas-clemente/quic-go/http3"
"github.com/lucas-clemente/quic-go/internal/protocol"
"github.com/lucas-clemente/quic-go/interop/http09"
"golang.org/x/sync/errgroup"
)
@@ -49,6 +51,8 @@ func runTestcase(testcase string) error {
defer r.Close()
return downloadFiles(r, urls)
case "handshake", "transfer", "retry":
case "versionnegotiation":
return runVersionNegotiationTest(urls)
case "resumption":
return runResumptionTest(urls)
default:
@@ -62,6 +66,21 @@ func runTestcase(testcase string) error {
return downloadFiles(r, urls)
}
func runVersionNegotiationTest(urls []string) error {
if len(urls) != 1 {
return errors.New("expected at least 2 URLs")
}
protocol.SupportedVersions = []protocol.VersionNumber{0x1a2a3a4a}
err := downloadFile(&http09.RoundTripper{}, urls[0])
if err == nil {
return errors.New("expected version negotiation to fail")
}
if !strings.Contains(err.Error(), "No compatible QUIC version found") {
return fmt.Errorf("expect version negotiation error, got: %s", err.Error())
}
return nil
}
func runResumptionTest(urls []string) error {
if len(urls) < 2 {
return errors.New("expected at least 2 URLs")