Skip to content

Commit

Permalink
Fix test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed May 15, 2020
1 parent 331e15a commit 6c4537c
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const getActions = (): FindActionResult[] => [
referencedByCount: 0,
},
{
id: 'd611af27-3532-4da9-8034-271fee81d634',
id: '123',
actionTypeId: '.servicenow',
name: 'ServiceNow',
config: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const usePushToService = ({
description: (
<FormattedMessage
defaultMessage="To open and update cases in external systems, you must configure a {link}."
id="xpack.siem.case.caseView.pushToServiceDisableByNoCaseConfigDescription"
id="xpack.siem.case.caseView.pushToServiceDisableByNoConnectors"
values={{
link: (
<EuiLink href={getConfigureCasesUrl(urlSearch)} target="_blank">
Expand All @@ -99,7 +99,7 @@ export const usePushToService = ({
description: (
<FormattedMessage
defaultMessage="To open and update cases in external systems, you must select an external incident management system for this case."
id="xpack.siem.case.caseView.pushToServiceDisableByNoCaseConfigDesc"
id="xpack.siem.case.caseView.pushToServiceDisableByNoCaseConfigDescription"
/>
),
},
Expand All @@ -112,7 +112,7 @@ export const usePushToService = ({
description: (
<FormattedMessage
defaultMessage="The connector used to send updates to external service has been deleted. To update cases in external systems, select a different connector or create a new one."
id="xpack.siem.case.caseView.pushToServiceDisableByNoCaseConfigDesc"
id="xpack.siem.case.caseView.pushToServiceDisableByInvalidConnector"
/>
),
},
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -13132,7 +13132,6 @@
"xpack.siem.case.caseView.pushToServiceDisableByConfigTitle": "Kibana の構成ファイルで ServiceNow を有効にする",
"xpack.siem.case.caseView.pushToServiceDisableByLicenseDescription": "外部システムでケースを開くには、ライセンスをプラチナに更新するか、30 日間の無料トライアルを開始するか、AWS、GCP、または Azure で {link} にサインアップする必要があります。",
"xpack.siem.case.caseView.pushToServiceDisableByLicenseTitle": "E lastic Platinum へのアップグレード",
"xpack.siem.case.caseView.pushToServiceDisableByNoCaseConfigDescription": "外部システムでケースを開いて更新するには、{link} を設定する必要があります。",
"xpack.siem.case.caseView.pushToServiceDisableByNoCaseConfigTitle": "外部コネクターを構成",
"xpack.siem.case.caseView.reopenCase": "ケースを再開",
"xpack.siem.case.caseView.reopenedCase": "ケースを再開する",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -13139,7 +13139,6 @@
"xpack.siem.case.caseView.pushToServiceDisableByConfigTitle": "在 Kibana 配置文件中启用 ServiceNow",
"xpack.siem.case.caseView.pushToServiceDisableByLicenseDescription": "要在外部系统中打开案例,必须将许可证更新到白金级,开始为期 30 天的免费试用,或在 AWS、GCP 或 Azure 上快速部署 {link}。",
"xpack.siem.case.caseView.pushToServiceDisableByLicenseTitle": "升级到 Elastic 白金级",
"xpack.siem.case.caseView.pushToServiceDisableByNoCaseConfigDescription": "要在外部系统上打开和更新案例,必须配置 {link}。",
"xpack.siem.case.caseView.pushToServiceDisableByNoCaseConfigTitle": "配置外部连接器",
"xpack.siem.case.caseView.reopenCase": "重新打开案例",
"xpack.siem.case.caseView.reopenedCase": "重新打开的案例",
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/case_api_integration/basic/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import { createTestConfig } from '../common/config';
// eslint-disable-next-line import/no-default-export
export default createTestConfig('basic', {
disabledPlugins: [],
license: 'basic',
license: 'trial',
ssl: true,
});
28 changes: 26 additions & 2 deletions x-pack/test/case_api_integration/basic/tests/cases/push_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../common/ftr_provider_context';
import { ObjectRemover as ActionsRemover } from '../../../../alerting_api_integration/common/lib';

import { CASE_CONFIGURE_URL, CASES_URL } from '../../../../../plugins/case/common/constants';
import { postCaseReq, defaultUser, postCommentReq } from '../../../common/lib/mock';
Expand All @@ -15,6 +16,7 @@ import {
deleteComments,
deleteConfiguration,
getConfiguration,
getConnector,
} from '../../../common/lib/utils';

// eslint-disable-next-line import/no-default-export
Expand All @@ -23,19 +25,31 @@ export default ({ getService }: FtrProviderContext): void => {
const es = getService('es');

describe('push_case', () => {
const actionsRemover = new ActionsRemover(supertest);

afterEach(async () => {
await deleteCases(es);
await deleteComments(es);
await deleteConfiguration(es);
await deleteCasesUserActions(es);
await actionsRemover.removeAll();
});

it('should push a case', async () => {
const { body: connector } = await supertest
.post('/api/action')
.set('kbn-xsrf', 'true')
.send(getConnector())
.expect(200);

actionsRemover.add('default', connector.id, 'action');

const { body: configure } = await supertest
.post(CASE_CONFIGURE_URL)
.set('kbn-xsrf', 'true')
.send(getConfiguration())
.send(getConfiguration(connector.id))
.expect(200);

const { body: postedCase } = await supertest
.post(CASES_URL)
.set('kbn-xsrf', 'true')
Expand All @@ -58,11 +72,20 @@ export default ({ getService }: FtrProviderContext): void => {
});

it('pushes a comment appropriately', async () => {
const { body: connector } = await supertest
.post('/api/action')
.set('kbn-xsrf', 'true')
.send(getConnector())
.expect(200);

actionsRemover.add('default', connector.id, 'action');

const { body: configure } = await supertest
.post(CASE_CONFIGURE_URL)
.set('kbn-xsrf', 'true')
.send(getConfiguration())
.send(getConfiguration(connector.id))
.expect(200);

const { body: postedCase } = await supertest
.post(CASES_URL)
.set('kbn-xsrf', 'true')
Expand Down Expand Up @@ -99,6 +122,7 @@ export default ({ getService }: FtrProviderContext): void => {
.expect(200);
expect(body.comments[0].pushed_by).to.eql(defaultUser);
});

it('unhappy path - 404s when case does not exist', async () => {
await supertest
.post(`${CASES_URL}/fake-id/_push`)
Expand Down
1 change: 1 addition & 0 deletions x-pack/test/case_api_integration/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const enabledActionTypes = [
'.pagerduty',
'.server-log',
'.servicenow',
'.jira',
'.slack',
'.webhook',
'test.authorization',
Expand Down
31 changes: 31 additions & 0 deletions x-pack/test/case_api_integration/common/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,37 @@ export const getConfigurationOutput = (update = false): Partial<CasesConfigureRe
};
};

export const getConnector = () => ({
name: 'ServiceNow Connector',
actionTypeId: '.servicenow',
secrets: {
username: 'admin',
password: 'password',
},
config: {
apiUrl: 'http://some.non.existent.com',
casesConfiguration: {
mapping: [
{
source: 'title',
target: 'short_description',
actionType: 'overwrite',
},
{
source: 'description',
target: 'description',
actionType: 'append',
},
{
source: 'comments',
target: 'comments',
actionType: 'append',
},
],
},
},
});

export const removeServerGeneratedPropertiesFromConfigure = (
config: Partial<CasesConfigureResponse>
): Partial<CasesConfigureResponse> => {
Expand Down

0 comments on commit 6c4537c

Please sign in to comment.