fix(backend): validate configured model provider pair
This commit is contained in:
@@ -64,6 +64,33 @@ test("PUT /settings rejects an unknown model when a model list is available", as
|
||||
}
|
||||
});
|
||||
|
||||
test("PUT /settings validates provider and model as one composite identifier", async () => {
|
||||
const { app, dir } = appWithTmpSettings({}, {
|
||||
listModels: async () => [
|
||||
{ provider: "provider-a", id: "shared-id", name: "A", reasoning: false },
|
||||
],
|
||||
});
|
||||
try {
|
||||
const wrongProvider = await app.inject({
|
||||
method: "PUT", url: "/settings",
|
||||
payload: {
|
||||
workspace: "psd", provider: "provider-b", model: "shared-id", thinking: "low",
|
||||
},
|
||||
});
|
||||
expect(wrongProvider.statusCode).toBe(400);
|
||||
|
||||
const exactPair = await app.inject({
|
||||
method: "PUT", url: "/settings",
|
||||
payload: {
|
||||
workspace: "psd", provider: "provider-a", model: "shared-id", thinking: "low",
|
||||
},
|
||||
});
|
||||
expect(exactPair.statusCode).toBe(200);
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("PUT /settings allows any model when model list is empty (Pi unavailable)", async () => {
|
||||
const { app, dir } = appWithTmpSettings({}, { listModels: async () => [] });
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user