MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestGetUserByAPIKey

Function TestGetUserByAPIKey

internal/identity/store_test.go:240–258  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

238}
239
240func TestGetUserByAPIKey(t *testing.T) {
241 pool := testutil.TestDB(t)
242 store := identity.NewStore(pool)
243 ctx := context.Background()
244
245 user, _ := store.CreateOrGetUser(ctx, "apikey-lookup@example.com", "Owner", "google-apikey-lookup")
246 key, _ := store.CreateAPIKey(ctx, user.ID, "lookup-key", nil)
247
248 got, err := store.GetUserByAPIKey(ctx, key.PlaintextKey)
249 if err != nil {
250 t.Fatalf("GetUserByAPIKey: %v", err)
251 }
252 if got.ID != user.ID {
253 t.Errorf("ID = %q, want %q", got.ID, user.ID)
254 }
255 if got.Email != "apikey-lookup@example.com" {
256 t.Errorf("Email = %q", got.Email)
257 }
258}
259
260// TestAPIKey_ListReturnsLastUsedAtAndExpiresAt asserts the columns
261// added/exposed by migration 011: last_used_at is populated by

Callers

nothing calls this directly

Calls 5

CreateOrGetUserMethod · 0.95
CreateAPIKeyMethod · 0.95
GetUserByAPIKeyMethod · 0.95
TestDBFunction · 0.92
NewStoreFunction · 0.92

Tested by

no test coverage detected