fixing mangling of floating point numbers by console (#23685) (#24271)

* fixing mangling of floating point numbers by console

* fixing tests

* fixing issue with large requests

* restoring old code for server side as it handles large responses better
This commit is contained in:
Bill McConaghy 2018-10-19 14:17:26 -04:00 committed by GitHub
parent 0b2beedc21
commit 57c7bd509a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 8 deletions

View file

@ -173,7 +173,7 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output, openDocu
if (mode === null || mode === 'application/json') {
// assume json - auto pretty
try {
value = utils.expandLiteralStrings(JSON.stringify(JSON.parse(value), null, 2));
value = utils.expandLiteralStrings(value);
}
catch (e) {
// nothing to do here

View file

@ -126,7 +126,7 @@ describe('Console Proxy Route', () => {
expect(args[0]).to.have.property('path', '/api/console/proxy');
expect(args[0]).to.have.property('method', 'post');
expect(args[0]).to.have.property('query').eql({ method: 'HEAD', path: '/index/type/id' });
expect(args[1]).to.be('/index/type/id');
expect(args[1]).to.be('/index/type/id?pretty');
});
it('sends the returned timeout, rejectUnauthorized, agent, and base headers to Wreck', async () => {

View file

@ -66,7 +66,7 @@ describe('Console Proxy Route', () => {
await request('GET', 'http://evil.com/test');
sinon.assert.calledOnce(Wreck.request);
const args = Wreck.request.getCall(0).args;
expect(args[1]).to.be('http://localhost:9200/http://evil.com/test');
expect(args[1]).to.be('http://localhost:9200/http://evil.com/test?pretty');
});
});
describe('is missing', () => {
@ -87,14 +87,14 @@ describe('Console Proxy Route', () => {
it('combines well with the base url', async () => {
await request('GET', '/index/type/id');
sinon.assert.calledOnce(Wreck.request);
expect(Wreck.request.getCall(0).args[1]).to.be('http://localhost:9200/index/type/id');
expect(Wreck.request.getCall(0).args[1]).to.be('http://localhost:9200/index/type/id?pretty');
});
});
describe(`doesn't start with a slash`, () => {
it('combines well with the base url', async () => {
await request('GET', 'index/type/id');
sinon.assert.calledOnce(Wreck.request);
expect(Wreck.request.getCall(0).args[1]).to.be('http://localhost:9200/index/type/id');
expect(Wreck.request.getCall(0).args[1]).to.be('http://localhost:9200/index/type/id?pretty');
});
});
});

View file

@ -23,7 +23,16 @@ import Wreck from 'wreck';
import { trimLeft, trimRight } from 'lodash';
function resolveUri(base, path) {
return `${trimRight(base, '/')}/${trimLeft(path, '/')}`;
let pathToUse = `${trimRight(base, '/')}/${trimLeft(path, '/')}`;
const questionMarkIndex = pathToUse.indexOf('?');
// no query string in pathToUse, append '?pretty'
if (questionMarkIndex === -1) {
pathToUse = `${pathToUse}?pretty`;
} else {
// pathToUse has query string, append '&pretty'
pathToUse = `${pathToUse}&pretty`;
}
return pathToUse;
}
function extendCommaList(obj, property, value) {

View file

@ -51,8 +51,8 @@ export default function ({ getService, getPageObjects }) {
});
});
it('default request response should include `"timed_out": false`', async function () {
const expectedResponseContains = '"timed_out": false,';
it('default request response should include `"timed_out" : false`', async function () {
const expectedResponseContains = '"timed_out" : false,';
await PageObjects.console.clickPlay();
await retry.try(async function () {
const actualResponse = await PageObjects.console.getResponse();