(opts: CreateTestApiKeyOptions = {})
| 54 | } |
| 55 | |
| 56 | export 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 | } |
no test coverage detected