mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Console] Only allow to send requests that have a valid method (#189515)
This commit is contained in:
parent
bd5c273032
commit
cca1a3c968
2 changed files with 17 additions and 9 deletions
|
@ -221,8 +221,20 @@ export class MonacoEditorActionsProvider {
|
|||
} = context;
|
||||
const { toasts } = notifications;
|
||||
try {
|
||||
const requests = await this.getRequests();
|
||||
if (!requests.length) {
|
||||
const allRequests = await this.getRequests();
|
||||
// if any request doesnt have a method then we gonna treat it as a non-valid
|
||||
// request
|
||||
const requests = allRequests.filter((request) => request.method);
|
||||
|
||||
// If we do have requests but none have methods we are not sending the request
|
||||
if (allRequests.length > 0 && !requests.length) {
|
||||
toasts.addWarning(
|
||||
i18n.translate('console.notification.monaco.error.nonSupportedRequest', {
|
||||
defaultMessage: 'The selected request is not valid.',
|
||||
})
|
||||
);
|
||||
return;
|
||||
} else if (!requests.length) {
|
||||
toasts.add(
|
||||
i18n.translate('console.notification.monaco.error.noRequestSelectedTitle', {
|
||||
defaultMessage:
|
||||
|
|
|
@ -14,6 +14,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
|
|||
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const retry = getService('retry');
|
||||
const log = getService('log');
|
||||
const toasts = getService('toasts');
|
||||
const browser = getService('browser');
|
||||
const PageObjects = getPageObjects(['common', 'console', 'header']);
|
||||
const security = getService('security');
|
||||
|
@ -57,17 +58,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
expect(initialSize.width).to.be.greaterThan(afterSize.width);
|
||||
});
|
||||
|
||||
it('should return statusCode 400 to unsupported HTTP verbs', async () => {
|
||||
const expectedResponseContains = '"statusCode": 400';
|
||||
it('should not send request with unsupported HTTP verbs', async () => {
|
||||
await PageObjects.console.monaco.clearEditorText();
|
||||
await PageObjects.console.monaco.enterText('OPTIONS /');
|
||||
await PageObjects.console.clickPlay();
|
||||
await retry.try(async () => {
|
||||
const actualResponse = await PageObjects.console.monaco.getOutputText();
|
||||
log.debug(actualResponse);
|
||||
expect(actualResponse).to.contain(expectedResponseContains);
|
||||
|
||||
expect(await PageObjects.console.hasSuccessBadge()).to.be(false);
|
||||
expect(await toasts.getCount()).to.equal(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue