From d72c0c80bca062208b265e3314ba364b8ee82a29 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Tue, 11 Jul 2017 16:33:06 +0700 Subject: [PATCH] fix check for STK generation time --- handshake/stk_generator_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/handshake/stk_generator_test.go b/handshake/stk_generator_test.go index 1e38d1fa..e224d312 100644 --- a/handshake/stk_generator_test.go +++ b/handshake/stk_generator_test.go @@ -38,7 +38,9 @@ var _ = Describe("STK Generator", func() { stk, err := stkGen.DecodeToken(token) Expect(err).ToNot(HaveOccurred()) Expect(stk.RemoteAddr).To(Equal("192.168.0.1")) - Expect(stk.SentTime).To(BeTemporally("~", time.Now(), time.Second)) + // the time resolution of the STK is just 1 second + // if STK generation and this check happen in "different seconds", the difference will be between 1 and 2 seconds + Expect(stk.SentTime).To(BeTemporally("~", time.Now(), 2*time.Second)) }) It("rejects invalid tokens", func() { @@ -89,7 +91,9 @@ var _ = Describe("STK Generator", func() { stk, err := stkGen.DecodeToken(token) Expect(err).ToNot(HaveOccurred()) Expect(stk.RemoteAddr).To(Equal(ip.String())) - Expect(stk.SentTime).To(BeTemporally("~", time.Now(), time.Second)) + // the time resolution of the STK is just 1 second + // if STK generation and this check happen in "different seconds", the difference will be between 1 and 2 seconds + Expect(stk.SentTime).To(BeTemporally("~", time.Now(), 2*time.Second)) } })