mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
add an integration test that performs frequent key updates
This commit is contained in:
parent
0f16e08e14
commit
6461c69045
1 changed files with 57 additions and 0 deletions
57
integrationtests/self/key_update_test.go
Normal file
57
integrationtests/self/key_update_test.go
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
package self_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
quic "github.com/lucas-clemente/quic-go"
|
||||||
|
"github.com/lucas-clemente/quic-go/integrationtests/tools/testserver"
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("Key Update tests", func() {
|
||||||
|
var server quic.Listener
|
||||||
|
|
||||||
|
runServer := func() {
|
||||||
|
var err error
|
||||||
|
// start the server
|
||||||
|
server, err = quic.ListenAddr("localhost:0", getTLSConfig(), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer GinkgoRecover()
|
||||||
|
sess, err := server.Accept(context.Background())
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
str, err := sess.OpenUniStream()
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
defer str.Close()
|
||||||
|
_, err = str.Write(testserver.PRDataLong)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
BeforeEach(func() {
|
||||||
|
// update keys as frequently as possible
|
||||||
|
os.Setenv("QUIC_GO_KEY_UPDATE_INTERVAL", "1")
|
||||||
|
runServer()
|
||||||
|
})
|
||||||
|
|
||||||
|
It("downloads a large file", func() {
|
||||||
|
sess, err := quic.DialAddr(
|
||||||
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
|
getTLSClientConfig(),
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
defer sess.Close()
|
||||||
|
str, err := sess.AcceptUniStream(context.Background())
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
data, err := ioutil.ReadAll(str)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(data).To(Equal(testserver.PRDataLong))
|
||||||
|
})
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue