-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Webhook action - make user and password secrets optional #56823
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
Changes from all commits
010e6aa
b672c85
3fb020a
f8673f1
b4808e3
c4d5c87
a8f5f5a
e33dd8d
2b1b8ea
92e1ca5
6847827
79b4cde
afc62be
c7362a6
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 |
|---|---|---|
|
|
@@ -212,8 +212,8 @@ export default function webhookTest({ getService }: FtrProviderContext) { | |
| .expect(200); | ||
|
|
||
| expect(result.status).to.eql('error'); | ||
| expect(result.message).to.match(/error calling webhook, invalid response/); | ||
| expect(result.serviceMessage).to.eql('[400] Bad Request'); | ||
| expect(result.message).to.match(/error calling webhook, retry later/); | ||
|
Contributor
Author
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. The expected result here was incorrect due to a typo in the webhook simulator when the body is |
||
| expect(result.serviceMessage).to.eql('[500] Internal Server Error'); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import expect from '@kbn/expect'; | ||
| import { URL, format as formatUrl } from 'url'; | ||
| import { FtrProviderContext } from '../../../../common/ftr_provider_context'; | ||
| import { | ||
| getExternalServiceSimulatorPath, | ||
| ExternalServiceSimulator, | ||
| } from '../../../../common/fixtures/plugins/actions'; | ||
|
|
||
| // eslint-disable-next-line import/no-default-export | ||
| export default function webhookTest({ getService }: FtrProviderContext) { | ||
| const supertest = getService('supertest'); | ||
| const esArchiver = getService('esArchiver'); | ||
| const kibanaServer = getService('kibanaServer'); | ||
|
|
||
| async function createWebhookAction( | ||
| urlWithCreds: string, | ||
| config: Record<string, string | Record<string, string>> = {} | ||
| ): Promise<string> { | ||
| const url = formatUrl(new URL(urlWithCreds), { auth: false }); | ||
| const composedConfig = { | ||
| headers: { | ||
| 'Content-Type': 'text/plain', | ||
| }, | ||
| ...config, | ||
| url, | ||
| }; | ||
|
|
||
| const { body: createdAction } = await supertest | ||
| .post('/api/action') | ||
| .set('kbn-xsrf', 'test') | ||
| .send({ | ||
| name: 'A generic Webhook action', | ||
| actionTypeId: '.webhook', | ||
| secrets: {}, | ||
| config: composedConfig, | ||
| }) | ||
| .expect(200); | ||
|
|
||
| return createdAction.id; | ||
| } | ||
|
|
||
| describe('webhook action', () => { | ||
| let webhookSimulatorURL: string = '<could not determine kibana url>'; | ||
|
|
||
| // need to wait for kibanaServer to settle ... | ||
| before(() => { | ||
| webhookSimulatorURL = kibanaServer.resolveUrl( | ||
| getExternalServiceSimulatorPath(ExternalServiceSimulator.WEBHOOK) | ||
| ); | ||
| }); | ||
|
|
||
| after(() => esArchiver.unload('empty_kibana')); | ||
|
|
||
| it('webhook can be executed without username and password', async () => { | ||
|
Contributor
Author
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. This test is in the |
||
| const webhookActionId = await createWebhookAction(webhookSimulatorURL); | ||
| const { body: result } = await supertest | ||
| .post(`/api/action/${webhookActionId}/_execute`) | ||
| .set('kbn-xsrf', 'test') | ||
| .send({ | ||
| params: { | ||
| body: 'success', | ||
| }, | ||
| }) | ||
| .expect(200); | ||
|
|
||
| expect(result.status).to.eql('ok'); | ||
| }); | ||
| }); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.