fix check for STK generation time

This commit is contained in:
Marten Seemann
2017-07-11 16:33:06 +07:00
parent 598d36ae96
commit d72c0c80bc

View File

@@ -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))
}
})