test: cover JSON body parsing for /api/provider
Guards the selective express.json allowlist so custom provider upsert requests keep a parsed body. Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>
This commit is contained in:
co-authored by
Serhii Dziupin
parent
0131c66bdd
commit
d84e4e0312
@@ -127,6 +127,37 @@ describe('core-routes', () => {
|
|||||||
expect(response.body).toEqual({ body: { content: 'Snippet body' } });
|
expect(response.body).toEqual({ body: { content: 'Snippet body' } });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should parse JSON bodies for custom provider upsert routes', async () => {
|
||||||
|
const app = express();
|
||||||
|
registerCommonRequestMiddleware(app, { express });
|
||||||
|
app.put('/api/provider', (req, res) => {
|
||||||
|
res.json({ body: req.body });
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await request(app)
|
||||||
|
.put('/api/provider')
|
||||||
|
.send({
|
||||||
|
providerID: 'campus-llm',
|
||||||
|
config: {
|
||||||
|
name: 'Campus LLM',
|
||||||
|
options: { baseURL: 'https://llm.example.edu/v1' },
|
||||||
|
models: { fast: { name: 'Fast' } },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
|
expect(response.body).toEqual({
|
||||||
|
body: {
|
||||||
|
providerID: 'campus-llm',
|
||||||
|
config: {
|
||||||
|
name: 'Campus LLM',
|
||||||
|
options: { baseURL: 'https://llm.example.edu/v1' },
|
||||||
|
models: { fast: { name: 'Fast' } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should require API auth before probing loopback preview URLs', async () => {
|
it('should require API auth before probing loopback preview URLs', async () => {
|
||||||
const app = express();
|
const app = express();
|
||||||
const originalFetch = globalThis.fetch;
|
const originalFetch = globalThis.fetch;
|
||||||
|
|||||||
Reference in New Issue
Block a user