mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-05 13:17:36 +03:00
improve the version negotiation integration test
This commit is contained in:
parent
c481645276
commit
46f8c07daa
4 changed files with 14 additions and 7 deletions
|
@ -12,6 +12,10 @@ import (
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type versioner interface {
|
||||||
|
GetVersion() protocol.VersionNumber
|
||||||
|
}
|
||||||
|
|
||||||
var _ = Describe("Handshake tests", func() {
|
var _ = Describe("Handshake tests", func() {
|
||||||
var (
|
var (
|
||||||
server quic.Listener
|
server quic.Listener
|
||||||
|
@ -67,19 +71,22 @@ var _ = Describe("Handshake tests", func() {
|
||||||
// but it supports a bunch of versions that the client doesn't speak
|
// but it supports a bunch of versions that the client doesn't speak
|
||||||
serverConfig.Versions = []protocol.VersionNumber{protocol.SupportedVersions[1], 7, 8, 9}
|
serverConfig.Versions = []protocol.VersionNumber{protocol.SupportedVersions[1], 7, 8, 9}
|
||||||
runServer()
|
runServer()
|
||||||
_, err := quic.DialAddr(server.Addr().String(), &tls.Config{InsecureSkipVerify: true}, nil)
|
sess, err := quic.DialAddr(server.Addr().String(), &tls.Config{InsecureSkipVerify: true}, nil)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(sess.(versioner).GetVersion()).To(Equal(protocol.SupportedVersions[1]))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("when the client supports more versions than the server supports", func() {
|
It("when the client supports more versions than the server supports", func() {
|
||||||
// the server doesn't support the highest supported version, which is the first one the client will try
|
// the server doesn't support the highest supported version, which is the first one the client will try
|
||||||
// but it supports a bunch of versions that the client doesn't speak
|
// but it supports a bunch of versions that the client doesn't speak
|
||||||
|
serverConfig.Versions = supportedVersions
|
||||||
runServer()
|
runServer()
|
||||||
conf := &quic.Config{
|
conf := &quic.Config{
|
||||||
Versions: []protocol.VersionNumber{7, 8, 9, protocol.SupportedVersions[1], 10},
|
Versions: []protocol.VersionNumber{7, 8, 9, protocol.SupportedVersions[1], 10},
|
||||||
}
|
}
|
||||||
_, err := quic.DialAddr(server.Addr().String(), &tls.Config{InsecureSkipVerify: true}, conf)
|
sess, err := quic.DialAddr(server.Addr().String(), &tls.Config{InsecureSkipVerify: true}, conf)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(sess.(versioner).GetVersion()).To(Equal(protocol.SupportedVersions[1]))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ func IsValidVersion(v VersionNumber) bool {
|
||||||
|
|
||||||
// UsesTLS says if this QUIC version uses TLS 1.3 for the handshake
|
// UsesTLS says if this QUIC version uses TLS 1.3 for the handshake
|
||||||
func (vn VersionNumber) UsesTLS() bool {
|
func (vn VersionNumber) UsesTLS() bool {
|
||||||
return vn == VersionTLS
|
return !vn.isGQUIC()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vn VersionNumber) String() string {
|
func (vn VersionNumber) String() string {
|
||||||
|
|
|
@ -267,7 +267,7 @@ var _ = Describe("Header", func() {
|
||||||
PacketNumber: 2,
|
PacketNumber: 2,
|
||||||
PacketNumberLen: protocol.PacketNumberLen2,
|
PacketNumberLen: protocol.PacketNumberLen2,
|
||||||
}
|
}
|
||||||
err := hdr.Write(buf, protocol.PerspectiveServer, protocol.VersionWhatever)
|
err := hdr.Write(buf, protocol.PerspectiveServer, versionPublicHeader)
|
||||||
Expect(err).To(MatchError("PublicHeader: wrong length for Connection ID: 7 (expected 8)"))
|
Expect(err).To(MatchError("PublicHeader: wrong length for Connection ID: 7 (expected 8)"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ var _ = Describe("Header", func() {
|
||||||
DestConnectionID: connID,
|
DestConnectionID: connID,
|
||||||
PacketNumber: 2,
|
PacketNumber: 2,
|
||||||
}
|
}
|
||||||
err := hdr.Write(buf, protocol.PerspectiveServer, protocol.VersionWhatever)
|
err := hdr.Write(buf, protocol.PerspectiveServer, versionPublicHeader)
|
||||||
Expect(err).To(MatchError("PublicHeader: PacketNumberLen not set"))
|
Expect(err).To(MatchError("PublicHeader: PacketNumberLen not set"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ var _ = Describe("Header", func() {
|
||||||
PacketNumberLen: protocol.PacketNumberLen1,
|
PacketNumberLen: protocol.PacketNumberLen1,
|
||||||
PacketNumber: 1,
|
PacketNumber: 1,
|
||||||
}
|
}
|
||||||
err := hdr.Write(buf, protocol.PerspectiveServer, protocol.VersionWhatever)
|
err := hdr.Write(buf, protocol.PerspectiveServer, versionPublicHeader)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(buf.Bytes()).To(Equal([]byte{0x0, 0x1}))
|
Expect(buf.Bytes()).To(Equal([]byte{0x0, 0x1}))
|
||||||
})
|
})
|
||||||
|
|
|
@ -24,7 +24,7 @@ var _ = Describe("Packet Handler Map", func() {
|
||||||
err := (&wire.Header{
|
err := (&wire.Header{
|
||||||
DestConnectionID: connID,
|
DestConnectionID: connID,
|
||||||
PacketNumberLen: protocol.PacketNumberLen1,
|
PacketNumberLen: protocol.PacketNumberLen1,
|
||||||
}).Write(buf, protocol.PerspectiveServer, protocol.VersionWhatever)
|
}).Write(buf, protocol.PerspectiveServer, versionGQUICFrames)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
return buf.Bytes()
|
return buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue