process the NewSessionTicket TLS message

This commit is contained in:
Marten Seemann 2019-03-28 11:07:40 +01:00
parent da4b3e3176
commit 2adf923ee6
6 changed files with 32 additions and 14 deletions

View file

@ -18,13 +18,15 @@ var _ = Describe("Crypto Stream Manager", func() {
initialStream *MockCryptoStream
handshakeStream *MockCryptoStream
oneRTTStream *MockCryptoStream
)
BeforeEach(func() {
initialStream = NewMockCryptoStream(mockCtrl)
handshakeStream = NewMockCryptoStream(mockCtrl)
oneRTTStream = NewMockCryptoStream(mockCtrl)
cs = NewMockCryptoDataHandler(mockCtrl)
csm = newCryptoStreamManager(cs, initialStream, handshakeStream)
csm = newCryptoStreamManager(cs, initialStream, handshakeStream, oneRTTStream)
})
It("passes messages to the initial stream", func() {
@ -49,6 +51,17 @@ var _ = Describe("Crypto Stream Manager", func() {
Expect(encLevelChanged).To(BeFalse())
})
It("passes messages to the 1-RTT stream", func() {
cf := &wire.CryptoFrame{Data: []byte("foobar")}
oneRTTStream.EXPECT().HandleCryptoFrame(cf)
oneRTTStream.EXPECT().GetCryptoData().Return([]byte("foobar"))
oneRTTStream.EXPECT().GetCryptoData()
cs.EXPECT().HandleMessage([]byte("foobar"), protocol.Encryption1RTT)
encLevelChanged, err := csm.HandleCryptoFrame(cf, protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
Expect(encLevelChanged).To(BeFalse())
})
It("doesn't call the message handler, if there's no message", func() {
cf := &wire.CryptoFrame{Data: []byte("foobar")}
handshakeStream.EXPECT().HandleCryptoFrame(cf)
@ -98,12 +111,6 @@ var _ = Describe("Crypto Stream Manager", func() {
Expect(err).To(MatchError(err))
})
It("ignores post-handshake crypto data", func() {
changed, err := csm.HandleCryptoFrame(&wire.CryptoFrame{}, protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
Expect(changed).To(BeFalse())
})
It("errors for unknown encryption levels", func() {
_, err := csm.HandleCryptoFrame(&wire.CryptoFrame{}, 42)
Expect(err).To(HaveOccurred())