forked from quic-go/quic-go
expose the ConnectionState in the Session
The ConnectionState contains basic details about the QUIC connection.
This commit is contained in:
@@ -2,6 +2,7 @@ package handshake
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/x509"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
"github.com/lucas-clemente/quic-go/internal/crypto"
|
||||
"github.com/lucas-clemente/quic-go/internal/mocks/crypto"
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
"github.com/lucas-clemente/quic-go/internal/testdata"
|
||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||
"github.com/lucas-clemente/quic-go/qerr"
|
||||
. "github.com/onsi/ginkgo"
|
||||
@@ -34,6 +36,8 @@ type mockCertManager struct {
|
||||
|
||||
commonCertificateHashes []byte
|
||||
|
||||
chain []*x509.Certificate
|
||||
|
||||
leafCert []byte
|
||||
leafCertHash uint64
|
||||
leafCertHashError error
|
||||
@@ -45,6 +49,8 @@ type mockCertManager struct {
|
||||
verifyCalled bool
|
||||
}
|
||||
|
||||
var _ crypto.CertManager = &mockCertManager{}
|
||||
|
||||
func (m *mockCertManager) SetData(data []byte) error {
|
||||
m.setDataCalledWith = data
|
||||
return m.setDataError
|
||||
@@ -72,6 +78,10 @@ func (m *mockCertManager) Verify(hostname string) error {
|
||||
return m.verifyError
|
||||
}
|
||||
|
||||
func (m *mockCertManager) GetChain() []*x509.Certificate {
|
||||
return m.chain
|
||||
}
|
||||
|
||||
var _ = Describe("Client Crypto Setup", func() {
|
||||
var (
|
||||
cs *cryptoSetupClient
|
||||
@@ -841,6 +851,22 @@ var _ = Describe("Client Crypto Setup", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Context("reporting the connection state", func() {
|
||||
It("reports the connection state before the handshake completes", func() {
|
||||
chain := []*x509.Certificate{testdata.GetCertificate().Leaf}
|
||||
certManager.chain = chain
|
||||
state := cs.ConnectionState()
|
||||
Expect(state.HandshakeComplete).To(BeFalse())
|
||||
Expect(state.PeerCertificates).To(Equal(chain))
|
||||
})
|
||||
|
||||
It("reports the connection state after the handshake completes", func() {
|
||||
doSHLO()
|
||||
state := cs.ConnectionState()
|
||||
Expect(state.HandshakeComplete).To(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("forcing encryption levels", func() {
|
||||
It("forces null encryption", func() {
|
||||
cs.nullAEAD.(*mockcrypto.MockAEAD).EXPECT().Seal(nil, []byte("foobar"), protocol.PacketNumber(4), []byte{}).Return([]byte("foobar unencrypted"))
|
||||
|
||||
Reference in New Issue
Block a user