1
0
forked from boos/BoosAPI

fix downstream key whitelist select-all persistence

This commit is contained in:
cita
2026-03-20 10:54:02 +08:00
parent 77d6a415d1
commit 9077703503
2 changed files with 8 additions and 4 deletions
@@ -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 [];