Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func verifyExp(exp *time.Time, now time.Time, required bool) bool {
if exp == nil {
return !required
}
return now.Before(*exp) || now.Equal(*exp)
return now.Before(*exp)
}

func verifyIat(iat *time.Time, now time.Time, required bool) bool {
Expand Down
24 changes: 24 additions & 0 deletions map_claims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package jwt

import (
"testing"
"time"
)

func TestVerifyAud(t *testing.T) {
Expand Down Expand Up @@ -97,3 +98,26 @@ func TestMapclaimsVerifyExpiresAtInvalidTypeString(t *testing.T) {
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got)
}
}

func TestMapClaimsVerifyExpiresAtExpire(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

note to self to consider rewriting these tests as table tests

exp := time.Now().Unix()
mapClaims := MapClaims{
"exp": float64(exp),
}
want := false
got := mapClaims.VerifyExpiresAt(exp, true)
if want != got {
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got)
}

got = mapClaims.VerifyExpiresAt(exp + 1, true)
if want != got {
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got)
}

want = true
got = mapClaims.VerifyExpiresAt(exp - 1, true)
if want != got {
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got)
}
}