forked from quic-go/quic-go
run client integration tests with every QUIC version
This commit is contained in:
@@ -2,18 +2,25 @@ package integrationtests
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/h2quic"
|
||||
"github.com/lucas-clemente/quic-go/protocol"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Client tests", func() {
|
||||
var client *http.Client
|
||||
var supportedVersions []protocol.VersionNumber
|
||||
|
||||
for _, v := range protocol.SupportedVersions {
|
||||
supportedVersions = append(supportedVersions, v)
|
||||
}
|
||||
|
||||
BeforeEach(func() {
|
||||
err := os.Setenv("HOSTALIASES", "quic.clemente.io 127.0.0.1")
|
||||
@@ -28,43 +35,57 @@ var _ = Describe("Client tests", func() {
|
||||
}
|
||||
})
|
||||
|
||||
It("downloads a hello", func() {
|
||||
resp, err := client.Get("https://quic.clemente.io:" + port + "/hello")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(resp.StatusCode).To(Equal(200))
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(string(body)).To(Equal("Hello, World!\n"))
|
||||
AfterEach(func() {
|
||||
protocol.SupportedVersions = supportedVersions
|
||||
})
|
||||
|
||||
It("downloads a small file", func() {
|
||||
dataMan.GenerateData(dataLen)
|
||||
resp, err := client.Get("https://quic.clemente.io:" + port + "/data")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(resp.StatusCode).To(Equal(200))
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(body).To(Equal(dataMan.GetData()))
|
||||
})
|
||||
for _, v := range supportedVersions {
|
||||
version := v
|
||||
|
||||
It("downloads a large file", func() {
|
||||
dataMan.GenerateData(dataLongLen)
|
||||
resp, err := client.Get("https://quic.clemente.io:" + port + "/data")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(resp.StatusCode).To(Equal(200))
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(body).To(Equal(dataMan.GetData()))
|
||||
})
|
||||
Context(fmt.Sprintf("with quic version %d", version), func() {
|
||||
BeforeEach(func() {
|
||||
protocol.SupportedVersions = []protocol.VersionNumber{version}
|
||||
})
|
||||
|
||||
It("uploads a file", func() {
|
||||
dataMan.GenerateData(dataLen)
|
||||
data := bytes.NewReader(dataMan.GetData())
|
||||
resp, err := client.Post("https://quic.clemente.io:"+port+"/echo", "text/plain", data)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(resp.StatusCode).To(Equal(200))
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(body).To(Equal(dataMan.GetData()))
|
||||
})
|
||||
It("downloads a hello", func() {
|
||||
resp, err := client.Get("https://quic.clemente.io:" + port + "/hello")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(resp.StatusCode).To(Equal(200))
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(string(body)).To(Equal("Hello, World!\n"))
|
||||
})
|
||||
|
||||
It("downloads a small file", func() {
|
||||
dataMan.GenerateData(dataLen)
|
||||
resp, err := client.Get("https://quic.clemente.io:" + port + "/data")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(resp.StatusCode).To(Equal(200))
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(body).To(Equal(dataMan.GetData()))
|
||||
})
|
||||
|
||||
It("downloads a large file", func() {
|
||||
dataMan.GenerateData(dataLongLen)
|
||||
resp, err := client.Get("https://quic.clemente.io:" + port + "/data")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(resp.StatusCode).To(Equal(200))
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(body).To(Equal(dataMan.GetData()))
|
||||
})
|
||||
|
||||
It("uploads a file", func() {
|
||||
dataMan.GenerateData(dataLen)
|
||||
data := bytes.NewReader(dataMan.GetData())
|
||||
resp, err := client.Post("https://quic.clemente.io:"+port+"/echo", "text/plain", data)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(resp.StatusCode).To(Equal(200))
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(body).To(Equal(dataMan.GetData()))
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user