Skip to content

Commit

Permalink
fix: more log for bodyParser (#3809)
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 authored Jul 17, 2019
1 parent 6dc8a2d commit 29a2f2f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ module.exports = appInfo => {
depth: 5,
parameterLimit: 1000,
},
onerror(err) {
err.message += ', check bodyParser config';
throw err;
},
};

/**
Expand Down
9 changes: 9 additions & 0 deletions test/app/middleware/body_parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ describe('test/app/middleware/body_parser.test.js', () => {
.expect(200, done);
});

it('should 413 when post json body over the limit', () => {
app.mockCsrf();
return app.httpRequest()
.post('/test/body_parser/user')
.send({ foo: 'a'.repeat(1024 * 200) })
.expect(/request entity too large, check bodyParser config/)
.expect(413);
});

it('should disable body parser', async () => {
app1 = utils.app('apps/body_parser_testapp_disable');
await app1.ready();
Expand Down

0 comments on commit 29a2f2f

Please sign in to comment.