MCPcopy Create free account
hub / github.com/pollinations/pollinations / createTestApiKey

Function createTestApiKey

shared/test/fixtures/api-keys.ts:56–80  ·  view source on GitHub ↗
(opts: CreateTestApiKeyOptions = {})

Source from the content-addressed store, hash-verified

54}
55
56export async function createTestApiKey(opts: CreateTestApiKeyOptions = {}) {
57 const userId = opts.userId ?? (await createTestUser(opts.user));
58 const authClient = createApiKeyAuth(env);
59 const type = opts.type ?? "secret";
60
61 const created = await createApiKeyForUser({
62 authClient,
63 dbBinding: env.DB,
64 userId,
65 name: opts.name ?? `${type}-test-key`,
66 type,
67 expiresIn: opts.expiresIn,
68 allowedModels: opts.allowedModels,
69 pollenBudget: opts.pollenBudget,
70 accountPermissions: opts.accountPermissions,
71 metadata: opts.metadata,
72 allowAccountKeysPermission: true,
73 defaultCreatedVia: "test",
74 });
75
76 return {
77 ...created,
78 userId,
79 };
80}

Callers 3

index.tsFile · 0.90
realtime.test.tsFile · 0.90

Calls 3

createApiKeyAuthFunction · 0.90
createApiKeyForUserFunction · 0.90
createTestUserFunction · 0.85

Tested by

no test coverage detected