MCPcopy
hub / github.com/appleboy/gin-jwt / TestInMemoryRefreshTokenStore_GetAll

Function TestInMemoryRefreshTokenStore_GetAll

store/memory_test.go:281–310  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

279}
280
281func TestInMemoryRefreshTokenStore_GetAll(t *testing.T) {
282 store := NewInMemoryRefreshTokenStore()
283
284 // Add some tokens
285 validExpiry := time.Now().Add(time.Hour)
286 expiredExpiry := time.Now().Add(-time.Hour)
287
288 _ = store.Set(context.Background(), "valid1", &User{ID: "1"}, validExpiry)
289 _ = store.Set(context.Background(), "valid2", &User{ID: "2"}, validExpiry)
290 _ = store.Set(context.Background(), "expired1", &User{ID: "3"}, expiredExpiry)
291
292 all := store.GetAll()
293
294 // Should only return valid tokens
295 if len(all) != 2 {
296 t.Fatalf("Expected 2 valid tokens, got %d", len(all))
297 }
298
299 if _, exists := all["valid1"]; !exists {
300 t.Fatal("valid1 should be in GetAll() result")
301 }
302
303 if _, exists := all["valid2"]; !exists {
304 t.Fatal("valid2 should be in GetAll() result")
305 }
306
307 if _, exists := all["expired1"]; exists {
308 t.Fatal("expired1 should not be in GetAll() result")
309 }
310}
311
312func TestInMemoryRefreshTokenStore_Clear(t *testing.T) {
313 store := NewInMemoryRefreshTokenStore()

Callers

nothing calls this directly

Calls 3

SetMethod · 0.95
GetAllMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…