close session when crypto stream errors

This commit is contained in:
Lucas Clemente 2016-04-27 12:49:55 +02:00
parent 2056960e07
commit 607ab843d6
3 changed files with 39 additions and 18 deletions

View file

@ -244,4 +244,23 @@ var _ = Describe("Session", func() {
Expect(conn.written[0]).To(ContainSubstring(string("foobar")))
})
})
It("closes when crypto stream errors", func() {
path := os.Getenv("GOPATH") + "/src/github.com/lucas-clemente/quic-go/example/"
signer, err := crypto.NewRSASigner(path+"cert.der", path+"key.der")
Expect(err).ToNot(HaveOccurred())
scfg := handshake.NewServerConfig(crypto.NewCurve25519KEX(), signer)
session = NewSession(conn, 0, 0, scfg, nil).(*Session)
s, err := session.NewStream(3)
Expect(err).NotTo(HaveOccurred())
err = session.handleStreamFrame(&frames.StreamFrame{
StreamID: 1,
Data: []byte("4242\x00\x00\x00\x00"),
})
Expect(err).NotTo(HaveOccurred())
time.Sleep(time.Millisecond)
Expect(session.closed).To(BeTrue())
_, err = s.Write([]byte{})
Expect(err).To(MatchError("CryptoSetup: expected CHLO"))
})
})