retire the stateless reset token when the session is closed

This commit is contained in:
Marten Seemann 2019-10-26 17:56:37 +07:00
parent 9a81603b4a
commit ccb777b834
6 changed files with 62 additions and 0 deletions

View file

@ -13,6 +13,7 @@ var _ = Describe("Connection ID Manager", func() {
frameQueue []wire.Frame
tokenAdded *[16]byte
retiredTokens [][16]byte
removedTokens [][16]byte
)
initialConnID := protocol.ConnectionID{1, 1, 1, 1}
@ -20,9 +21,11 @@ var _ = Describe("Connection ID Manager", func() {
frameQueue = nil
tokenAdded = nil
retiredTokens = nil
removedTokens = nil
m = newConnIDManager(
initialConnID,
func(token [16]byte) { tokenAdded = &token },
func(token [16]byte) { removedTokens = append(removedTokens, token) },
func(token [16]byte) { retiredTokens = append(retiredTokens, token) },
func(f wire.Frame,
) {
@ -209,4 +212,20 @@ var _ = Describe("Connection ID Manager", func() {
Expect(retiredTokens).To(HaveLen(1))
Expect(retiredTokens[0]).To(Equal([16]byte{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}))
})
It("removes the currently active stateless reset token when it is closed", func() {
m.Close()
Expect(retiredTokens).To(BeEmpty())
Expect(removedTokens).To(BeEmpty())
Expect(m.Add(&wire.NewConnectionIDFrame{
SequenceNumber: 1,
ConnectionID: protocol.ConnectionID{1, 2, 3, 4},
StatelessResetToken: [16]byte{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1},
})).To(Succeed())
Expect(m.Get()).To(Equal(protocol.ConnectionID{1, 2, 3, 4}))
m.Close()
Expect(retiredTokens).To(BeEmpty())
Expect(removedTokens).To(HaveLen(1))
Expect(removedTokens[0]).To(Equal([16]byte{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}))
})
})