feat: connect console to catalog and project keys
This commit is contained in:
1 parent
5e8e462548
commit
ec51e8c802
13 files changed
+503
-22
No files matched your search
@@ -43,3 +43,18 @@ test('key model allowlist is enforced by the service', async () => {
|
||||
assert.equal(created.apiKey.modelIds[0], 'model-mock-text')
|
||||
assert.equal(created.apiKey.scopes.includes('invoke'), true)
|
||||
})
|
||||
|
||||
test('personal and project keys can coexist with project ownership checks', async () => {
|
||||
const catalog = createCatalog()
|
||||
const project = await catalog.createProject('user-1', { name: 'AI SoulMate 联调' })
|
||||
const personal = await catalog.createApiKey('user-1', { name: '个人调试' })
|
||||
const projectKey = await catalog.createApiKey('user-1', { name: '项目服务', projectId: project.id })
|
||||
|
||||
assert.equal(personal.apiKey.scopeType, 'personal')
|
||||
assert.equal(projectKey.apiKey.scopeType, 'project')
|
||||
assert.equal(projectKey.apiKey.projectId, project.id)
|
||||
await assert.rejects(
|
||||
catalog.createApiKey('user-2', { projectId: project.id }),
|
||||
(error: unknown) => error instanceof Error && error.message === '项目不存在或无权访问',
|
||||
)
|
||||
})
|
||||
Reference in new issue
Block a user