-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(http-server): discard request body if the content-length header i… #2103
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -514,13 +514,27 @@ describe('body params validation', () => { | |
}); | ||
|
||
describe('and no content is specified', () => { | ||
test('returns 200', async () => { | ||
test('returns 200 with no body', async () => { | ||
const response = await makeRequest('/empty-body', { | ||
method: 'GET', | ||
headers: { 'content-type': 'application/json' }, | ||
}); | ||
expect(response.status).toBe(200); | ||
}); | ||
test('returns 200 with empty plain body', async () => { | ||
const response = await makeRequest('/empty-body', { | ||
method: 'GET', | ||
headers: { 'content-type': 'text/plain', 'content-length': '0' }, | ||
}); | ||
expect(response.status).toBe(200); | ||
}); | ||
test('returns 200 with empty JSON body', async () => { | ||
const response = await makeRequest('/empty-body', { | ||
method: 'GET', | ||
headers: { 'content-type': 'application/json', 'content-length': '0' }, | ||
}); | ||
expect(response.status).toBe(200); | ||
}); | ||
}); | ||
}); | ||
|
||
|
@@ -669,6 +683,7 @@ describe('body params validation', () => { | |
request: { | ||
body: { | ||
id: faker.random.word(), | ||
required: true, | ||
contents: [ | ||
{ | ||
id: faker.random.word(), | ||
|
@@ -716,16 +731,9 @@ describe('body params validation', () => { | |
type: 'https://stoplight.io/prism/errors#UNPROCESSABLE_ENTITY', | ||
validation: [ | ||
{ | ||
location: ['body'], | ||
severity: 'Error', | ||
code: 'required', | ||
message: "must have required property 'id'", | ||
}, | ||
{ | ||
location: ['body'], | ||
severity: 'Error', | ||
code: 'required', | ||
message: "must have required property 'status'", | ||
message: 'Body parameter is required', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be better to update this test to have one of the required properties (either id or status) so that the spirit of the test is still the same: throws error if there's a missing required property in the body. Otherwise this test now changes to testing the behavior if the body is missing completely. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe there is a problem:
My understanding of the I have made a change which I think should reflect a bit better the usecase this test was meant to test. The |
||
}, | ||
], | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have taken the freedom to add a NVM RC file. Let me know if you would like this out