mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-09 10:57:03 +08:00
Fix/api key concurrency runtime miss (#309)
* test(cli): 覆盖 API key 并发等待与超时路径 * feat(scheduler): API key 并发饱和时等待可用槽位 * fix(proxy): 区分 API key 并发受限与真正的 runtime miss * fix(outcome): runtime miss 仅归因真实执行候选 * feat(api-keys): 统一 concurrent_limit 默认值与校验辅助 * feat(admin): 独立 Key 接口支持 concurrent_limit * feat(admin): 用户 API Key 路由支持 concurrent_limit * feat(public): 自助 API Key 路由支持 concurrent_limit * feat(import): 导入与存储层持久化 concurrent_limit * feat(frontend): 同步 API Key concurrent_limit 类型定义 * feat(frontend): 独立 Key 表单支持 concurrent_limit * feat(frontend): 管理员用户 API Key 表单支持 concurrent_limit * feat(frontend): 自助 API Key 页面支持 concurrent_limit * chore(fmt): 统一 runtime 归因相关 Rust 格式 * chore(fmt): 统一 admin API key 路由 Rust 格式 * chore(fmt): 统一 public 路由与相关测试 Rust 格式 * fix(test): 对齐 no-execution usage 归因断言 * test(middleware): 固定 access log tracing 用例线程模型 * fix(frontend): 提取用户 API Key payload 默认并发辅助 * fix(frontend): 保留用户 Key 的 concurrent_limit 默认值 * fix(api-keys): remove hardcoded concurrent limit default --------- Co-authored-by: fawney19 <[email protected]>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { buildUserApiKeyMutationPayload } from '@/features/api-keys/utils/userKeyPayload'
|
||||
|
||||
describe('userKeyPayload', () => {
|
||||
it('omits concurrent_limit when the field is left blank', () => {
|
||||
expect(buildUserApiKeyMutationPayload({
|
||||
name: 'writer-key',
|
||||
rate_limit: 30,
|
||||
concurrent_limit: undefined,
|
||||
})).toEqual({
|
||||
name: 'writer-key',
|
||||
rate_limit: 30,
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps explicit unlimited concurrent_limit values', () => {
|
||||
expect(buildUserApiKeyMutationPayload({
|
||||
name: 'writer-key',
|
||||
rate_limit: undefined,
|
||||
concurrent_limit: 0,
|
||||
})).toEqual({
|
||||
name: 'writer-key',
|
||||
rate_limit: 0,
|
||||
concurrent_limit: 0,
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps positive concurrent_limit values', () => {
|
||||
expect(buildUserApiKeyMutationPayload({
|
||||
name: 'writer-key',
|
||||
rate_limit: 15,
|
||||
concurrent_limit: 4,
|
||||
})).toEqual({
|
||||
name: 'writer-key',
|
||||
rate_limit: 15,
|
||||
concurrent_limit: 4,
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,21 @@
|
||||
export interface UserApiKeyMutationPayload {
|
||||
name: string
|
||||
rate_limit: number
|
||||
concurrent_limit?: number
|
||||
}
|
||||
|
||||
interface BuildUserApiKeyMutationPayloadInput {
|
||||
name: string
|
||||
rate_limit?: number
|
||||
concurrent_limit?: number
|
||||
}
|
||||
|
||||
export function buildUserApiKeyMutationPayload(
|
||||
input: BuildUserApiKeyMutationPayloadInput,
|
||||
): UserApiKeyMutationPayload {
|
||||
return {
|
||||
name: input.name,
|
||||
rate_limit: input.rate_limit ?? 0,
|
||||
...(input.concurrent_limit === undefined ? {} : { concurrent_limit: input.concurrent_limit }),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user