(t *testing.T)
| 112 | } |
| 113 | |
| 114 | func 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 | |
| 143 | func TestMapClaims_parseString(t *testing.T) { |
| 144 | type args struct { |
nothing calls this directly
no test coverage detected