read source address token and server nonce from SHLO

This commit is contained in:
Marten Seemann
2016-11-10 17:42:31 +07:00
parent 5b72a535d0
commit dbee83b8de
2 changed files with 41 additions and 0 deletions

View File

@@ -43,6 +43,25 @@ var _ = Describe("Crypto setup", func() {
// note that if this was a complete handshake message, HandleCryptoStream would fail with a qerr.InvalidCryptoMessageType
Expect(err).To(MatchError(qerr.HandshakeFailed))
})
It("passes the message on for parsing, and reads the source address token", func() {
stk := []byte("foobar")
tagMap[TagSTK] = stk
WriteHandshakeMessage(&stream.dataToRead, TagREJ, tagMap)
// this will throw a qerr.HandshakeFailed due to an EOF in WriteHandshakeMessage
// this is because the mockStream doesn't block if there's no data to read
err := cs.HandleCryptoStream()
Expect(err).To(MatchError(qerr.HandshakeFailed))
Expect(cs.stk).Should(Equal(stk))
})
It("saves the server nonce", func() {
nonc := []byte("servernonce")
tagMap[TagSNO] = nonc
err := cs.handleREJMessage(tagMap)
Expect(err).ToNot(HaveOccurred())
Expect(cs.sno).To(Equal(nonc))
})
})
Context("CHLO generation", func() {