Skip to content
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

[Security Solution] [Threat Hunting] [Cases] Fix API integration tests and enable in CI #75313

Merged
merged 1 commit into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x-pack/scripts/functional_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const onlyNotInCoverageTests = [
require.resolve('../test/alerting_api_integration/basic/config.ts'),
require.resolve('../test/alerting_api_integration/spaces_only/config.ts'),
require.resolve('../test/alerting_api_integration/security_and_spaces/config.ts'),
require.resolve('../test/case_api_integration/basic/config.ts'),
require.resolve('../test/apm_api_integration/basic/config.ts'),
require.resolve('../test/apm_api_integration/trial/config.ts'),
require.resolve('../test/detection_engine_api_integration/security_and_spaces/config.ts'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context';

import { CASE_CONFIGURE_CONNECTORS_URL } from '../../../../../plugins/case/common/constants';
import { ObjectRemover as ActionsRemover } from '../../../../alerting_api_integration/common/lib';
import { getServiceNowConnector, getJiraConnector } from '../../../common/lib/utils';
import {
getServiceNowConnector,
getJiraConnector,
getResilientConnector,
} from '../../../common/lib/utils';

// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
Expand Down Expand Up @@ -61,23 +65,33 @@ export default ({ getService }: FtrProviderContext): void => {
.send(getJiraConnector())
.expect(200);

const { body: connectorFour } = await supertest
.post('/api/actions/action')
.set('kbn-xsrf', 'true')
.send(getResilientConnector())
.expect(200);

actionsRemover.add('default', connectorOne.id, 'action', 'actions');
actionsRemover.add('default', connectorTwo.id, 'action', 'actions');
actionsRemover.add('default', connectorThree.id, 'action', 'actions');
actionsRemover.add('default', connectorFour.id, 'action', 'actions');

const { body: connectors } = await supertest
.get(`${CASE_CONFIGURE_CONNECTORS_URL}/_find`)
.set('kbn-xsrf', 'true')
.send()
.expect(200);

expect(connectors.length).to.equal(2);
expect(connectors.length).to.equal(3);
stephmilovic marked this conversation as resolved.
Show resolved Hide resolved
expect(
connectors.some((c: { actionTypeId: string }) => c.actionTypeId === '.servicenow')
).to.equal(true);
expect(connectors.some((c: { actionTypeId: string }) => c.actionTypeId === '.jira')).to.equal(
true
);
expect(
connectors.some((c: { actionTypeId: string }) => c.actionTypeId === '.resilient')
).to.equal(true);
});
});
};
3 changes: 2 additions & 1 deletion x-pack/test/case_api_integration/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ interface CreateTestConfigOptions {
const enabledActionTypes = [
'.email',
'.index',
'.jira',
'.pagerduty',
'.resilient',
'.server-log',
'.servicenow',
'.jira',
'.slack',
'.webhook',
'test.authorization',
Expand Down
35 changes: 34 additions & 1 deletion x-pack/test/case_api_integration/common/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const getServiceNowConnector = () => ({
},
config: {
apiUrl: 'http://some.non.existent.com',
casesConfiguration: {
incidentConfiguration: {
mapping: [
{
source: 'title',
Expand All @@ -52,6 +52,7 @@ export const getServiceNowConnector = () => ({
},
],
},
isCaseOwned: true,
},
});

Expand Down Expand Up @@ -87,6 +88,38 @@ export const getJiraConnector = () => ({
},
});

export const getResilientConnector = () => ({
name: 'Resilient Connector',
actionTypeId: '.resilient',
secrets: {
apiKeyId: 'id',
apiKeySecret: 'secret',
},
config: {
apiUrl: 'http://some.non.existent.com',
orgId: 'pkey',
casesConfiguration: {
mapping: [
{
source: 'title',
target: 'summary',
actionType: 'overwrite',
},
{
source: 'description',
target: 'description',
actionType: 'overwrite',
},
{
source: 'comments',
target: 'comments',
actionType: 'append',
},
],
},
},
});

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