aboutsummaryrefslogtreecommitdiff
path: root/lib/paseto/payload_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-03-30 03:49:19 +0700
committerShulhan <ms@kilabit.info>2026-03-30 06:35:53 +0700
commite931ffed0aada7427d7016ce681b2d038b668ba3 (patch)
treeef3efc06d880698cd0cecf80f3792bfc69db7c68 /lib/paseto/payload_test.go
parent5335f8d5e049866c904b506e28a7e48c8c787024 (diff)
downloadpakakeh.go-e931ffed0aada7427d7016ce681b2d038b668ba3.tar.xz
lib/paseto: store the time as Unix epoch inside Payload
Previously, we use time.Time to store the value for ExpiredAt, NotBefore, and IssuedAt. Even thought this is allowed (see RFC 7519 section 2, NumericDate) but it is not a standard practices. This changes them to store Unix epoch with int64.
Diffstat (limited to 'lib/paseto/payload_test.go')
-rw-r--r--lib/paseto/payload_test.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/paseto/payload_test.go b/lib/paseto/payload_test.go
index 81d1c67f..75f18ba4 100644
--- a/lib/paseto/payload_test.go
+++ b/lib/paseto/payload_test.go
@@ -11,11 +11,11 @@ import (
)
func TestPayload_Validate(t *testing.T) {
- now := time.Now().Round(time.Second)
+ now := time.Now().UTC().Unix()
peer := Peer{}
- issued1sAgo := now.Add(-1 * time.Second)
- issued6sAgo := now.Add(-6 * time.Second)
+ issued1sAgo := now - 1
+ issued6sAgo := now - 6
listCase := []struct {
desc string
@@ -24,12 +24,12 @@ func TestPayload_Validate(t *testing.T) {
}{{
desc: `With IssuedAt less than current time`,
pload: &Payload{
- IssuedAt: &issued1sAgo,
+ IssuedAt: issued1sAgo,
},
}, {
desc: `With IssuedAt greater than drift`,
pload: &Payload{
- IssuedAt: &issued6sAgo,
+ IssuedAt: issued6sAgo,
},
expErr: `payload: issued-at is after current time`,
}}