Merge pull request #182 from cita-777/codex/downstream-key-whitelist-select-all-persistence
[codex] fix downstream key whitelist select-all persistence
This commit is contained in:
@@ -116,6 +116,12 @@ describe('downstreamApiKeyService', () => {
|
||||
expect(service.isModelAllowedByPolicy('gemini-2.0-flash', result.policy)).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps all explicitly selected supported models when list exceeds 200 items', () => {
|
||||
const selectedModels = Array.from({ length: 260 }, (_, index) => `model-${String(index + 1).padStart(3, '0')}`);
|
||||
|
||||
expect(service.normalizeSupportedModelsInput(selectedModels)).toEqual(selectedModels);
|
||||
});
|
||||
|
||||
it('treats selected groups as additional allowed exposed route scope (union semantics)', async () => {
|
||||
const claudeGroup = await db.insert(schema.tokenRoutes).values({
|
||||
modelPattern: 're:^claude-(opus|sonnet)-4-6$',
|
||||
|
||||
@@ -131,16 +131,14 @@ export function normalizeSupportedModelsInput(input: unknown): string[] {
|
||||
if (Array.isArray(input)) {
|
||||
return input
|
||||
.map((item) => (typeof item === 'string' ? item.trim() : ''))
|
||||
.filter((item, index, arr) => item.length > 0 && arr.indexOf(item) === index)
|
||||
.slice(0, 200);
|
||||
.filter((item, index, arr) => item.length > 0 && arr.indexOf(item) === index);
|
||||
}
|
||||
|
||||
if (typeof input === 'string') {
|
||||
return input
|
||||
.split(/\r?\n|,/g)
|
||||
.map((item) => item.trim())
|
||||
.filter((item, index, arr) => item.length > 0 && arr.indexOf(item) === index)
|
||||
.slice(0, 200);
|
||||
.filter((item, index, arr) => item.length > 0 && arr.indexOf(item) === index);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user