-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
non issueIssue is not a problem or requires changesIssue is not a problem or requires changes
Description
I am trying the following test and I am sending non-urlencoded data to a route that 'allows' url encoded data. Since content type of this request is set to 'application/x-www-form-urlencoded', it should encode the payload but it does not.
context('with invalid payload (not URL-encoded)', () => {
it('returns 400', () => {
return server.inject({
url: '/books',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: internals.headers.Authorization
},
payload: 'title=💣'
}).then(res => {
expect(res.statusCode).to.equal(400);
});
});
});
and the following routes config:
this.server.route({
method: 'POST',
path: '/books',
config: {
handler: (request, reply) => {
this.handleBooks(request, response);
},
description: 'Create a new book',
payload: {
allow: 'application/x-www-form-urlencoded'
},
validate: {
payload: {
title: Joi.string().required().description('Title of the new book')
}
}
}
})
This results in 200 status code instead of 400, since routes should not let users post not encoded characters by default.
Context
- node version: v7.1.0
- hapi version: 16.0.2
- os: MacOS Sierra v 10.12
Metadata
Metadata
Assignees
Labels
non issueIssue is not a problem or requires changesIssue is not a problem or requires changes