Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('returns a logged bad request error when parser fails after request is setup (cleanStop false)', async () => {
const server = Hapi.server({ routes: { timeout: { server: false } }, operations: { cleanStop: false } });
server.route({ path: '/', method: 'GET', handler: Hoek.block });
await server.start();
const client = Net.connect(server.info.port);
const clientEnded = new Promise((resolve, reject) => {
let response = '';
client.on('data', (chunk) => {
response = response + chunk.toString();
});
client.on('end', () => resolve(response));
client.on('error', reject);
});
await new Promise((resolve) => client.on('connect', resolve));
it('errors saving a file without parse', async () => {
const server = Hapi.server();
server.route({ method: 'POST', path: '/file', options: { handler: Hoek.block, payload: { output: 'file', parse: false, uploads: '/a/b/c/d/not' } } });
const res = await server.inject({ method: 'POST', url: '/file', payload: 'abcde' });
expect(res.statusCode).to.equal(500);
});
it('returns a logged bad request error when parser fails after request is setup', async () => {
const server = Hapi.server({ routes: { timeout: { server: false } } });
server.route({ path: '/', method: 'GET', handler: Hoek.block });
await server.start();
const log = server.events.once('response');
const client = Net.connect(server.info.port);
const clientEnded = new Promise((resolve, reject) => {
let response = '';
client.on('data', (chunk) => {
response = response + chunk.toString();
});
client.on('end', () => resolve(response));
client.on('error', reject);
});
const ext = (request) => {
return Hoek.block();
};
const preStop = function (srv) {
return Hoek.block();
};
generateFunc: async function (id) {
await Hoek.block();
}
};