-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[6.4] Do not limit payload size for requests that are proxied to the …
…legacy Kibana. (#21952) * Do not limit payload size for requests that are proxied to the legacy Kibana. (#21750) * Adapt basepath tests to the 6.x behaviour.
- Loading branch information
Showing
10 changed files
with
118 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`fails with 400 if payload size is larger than default and route config allows 1`] = `"{\\"statusCode\\":400,\\"error\\":\\"Bad Request\\",\\"message\\":\\"Payload content length greater than maximum allowed: 200\\"}"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`xsrf request filter destructiveMethod: DELETE rejects requests without either an xsrf or version header: DELETE reject response 1`] = `"{\\"statusCode\\":400,\\"error\\":\\"Bad Request\\",\\"message\\":\\"Request must contain a kbn-xsrf header.\\"}"`; | ||
|
||
exports[`xsrf request filter destructiveMethod: POST rejects requests without either an xsrf or version header: POST reject response 1`] = `"{\\"statusCode\\":400,\\"error\\":\\"Bad Request\\",\\"message\\":\\"Request must contain a kbn-xsrf header.\\"}"`; | ||
|
||
exports[`xsrf request filter destructiveMethod: PUT rejects requests without either an xsrf or version header: PUT reject response 1`] = `"{\\"statusCode\\":400,\\"error\\":\\"Bad Request\\",\\"message\\":\\"Request must contain a kbn-xsrf header.\\"}"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import * as kbnTestServer from '../../test_utils/kbn_server'; | ||
|
||
let kbnServer; | ||
async function makeServer({ maxPayloadBytesDefault, maxPayloadBytesRoute }) { | ||
kbnServer = kbnTestServer.createServer({ | ||
server: { maxPayloadBytes: maxPayloadBytesDefault } | ||
}); | ||
|
||
await kbnServer.ready(); | ||
|
||
kbnServer.server.route({ | ||
path: '/payload_size_check/test/route', | ||
method: 'POST', | ||
config: { payload: { maxBytes: maxPayloadBytesRoute } }, | ||
handler: function (req, reply) { | ||
reply(null, req.payload.data.slice(0, 5)); | ||
} | ||
}); | ||
} | ||
|
||
async function makeRequest(opts) { | ||
return await kbnTestServer.makeRequest(kbnServer, opts); | ||
} | ||
|
||
afterEach(async () => await kbnServer.close()); | ||
|
||
test('accepts payload with a size larger than default but smaller than route config allows', async () => { | ||
await makeServer({ maxPayloadBytesDefault: 100, maxPayloadBytesRoute: 200 }); | ||
|
||
const resp = await makeRequest({ | ||
url: '/payload_size_check/test/route', | ||
method: 'POST', | ||
payload: { data: Array(150).fill('+').join('') }, | ||
}); | ||
|
||
expect(resp.statusCode).toBe(200); | ||
expect(resp.payload).toBe('+++++'); | ||
}); | ||
|
||
test('fails with 400 if payload size is larger than default and route config allows', async () => { | ||
await makeServer({ maxPayloadBytesDefault: 100, maxPayloadBytesRoute: 200 }); | ||
|
||
const resp = await makeRequest({ | ||
url: '/payload_size_check/test/route', | ||
method: 'POST', | ||
payload: { data: Array(250).fill('+').join('') }, | ||
}); | ||
|
||
expect(resp.statusCode).toBe(400); | ||
expect(resp.payload).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters