MCPcopy
hub / github.com/golang-jwt/jwt / TestMapClaimsVerifyExpiresAtExpire

Function TestMapClaimsVerifyExpiresAtExpire

map_claims_test.go:114–141  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

112}
113
114func TestMapClaimsVerifyExpiresAtExpire(t *testing.T) {
115 exp := time.Now()
116 mapClaims := MapClaims{
117 "exp": float64(exp.Unix()),
118 }
119 want := false
120 got := NewValidator(WithTimeFunc(func() time.Time {
121 return exp
122 })).Validate(mapClaims)
123 if want != (got == nil) {
124 t.Fatalf("Failed to verify claims, wanted: %v got %v", want, (got == nil))
125 }
126
127 got = NewValidator(WithTimeFunc(func() time.Time {
128 return exp.Add(1 * time.Second)
129 })).Validate(mapClaims)
130 if want != (got == nil) {
131 t.Fatalf("Failed to verify claims, wanted: %v got %v", want, (got == nil))
132 }
133
134 want = true
135 got = NewValidator(WithTimeFunc(func() time.Time {
136 return exp.Add(-1 * time.Second)
137 })).Validate(mapClaims)
138 if want != (got == nil) {
139 t.Fatalf("Failed to verify claims, wanted: %v got %v", want, (got == nil))
140 }
141}
142
143func TestMapClaims_parseString(t *testing.T) {
144 type args struct {

Callers

nothing calls this directly

Calls 3

NewValidatorFunction · 0.85
WithTimeFuncFunction · 0.85
ValidateMethod · 0.65

Tested by

no test coverage detected