mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
* [SIEM] Adds 'Load prebuilt rules' Cypress test (#59529) * adds 'load prebuilt rules' * fixes typecheck issue * updates jest snapshot * [SIEM] Adds 'Load prebuilt rules' Cypress test (#59529) * adds 'load prebuilt rules' * fixes typecheck issue * updates jest snapshot Co-authored-by: patrykkopycinski <patryk.kopycinski@elastic.co>
This commit is contained in:
parent
aade597f89
commit
96e3c611dc
13 changed files with 166 additions and 3 deletions
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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 { ELASTIC_RULES_BTN, RULES_TABLE, RULES_ROW } from '../screens/signal_detection_rules';
|
||||
|
||||
import {
|
||||
changeToThreeHundredRowsPerPage,
|
||||
loadPrebuiltDetectionRules,
|
||||
waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded,
|
||||
waitForPrebuiltDetectionRulesToBeLoaded,
|
||||
waitForRulesToBeLoaded,
|
||||
} from '../tasks/signal_detection_rules';
|
||||
import {
|
||||
goToManageSignalDetectionRules,
|
||||
waitForSignalsIndexToBeCreated,
|
||||
waitForSignalsPanelToBeLoaded,
|
||||
} from '../tasks/detections';
|
||||
import { loginAndWaitForPageWithoutDateRange } from '../tasks/login';
|
||||
|
||||
import { DETECTIONS } from '../urls/navigation';
|
||||
|
||||
describe('Signal detection rules', () => {
|
||||
before(() => {
|
||||
loginAndWaitForPageWithoutDateRange(DETECTIONS);
|
||||
});
|
||||
it('Loads prebuilt rules', () => {
|
||||
waitForSignalsPanelToBeLoaded();
|
||||
waitForSignalsIndexToBeCreated();
|
||||
goToManageSignalDetectionRules();
|
||||
waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded();
|
||||
loadPrebuiltDetectionRules();
|
||||
waitForPrebuiltDetectionRulesToBeLoaded();
|
||||
|
||||
const expectedElasticRulesBtnText = 'Elastic rules (92)';
|
||||
cy.get(ELASTIC_RULES_BTN)
|
||||
.invoke('text')
|
||||
.should('eql', expectedElasticRulesBtnText);
|
||||
|
||||
changeToThreeHundredRowsPerPage();
|
||||
waitForRulesToBeLoaded();
|
||||
|
||||
const expectedNumberOfRules = 92;
|
||||
cy.get(RULES_TABLE).then($table => {
|
||||
cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules);
|
||||
});
|
||||
});
|
||||
});
|
9
x-pack/legacy/plugins/siem/cypress/screens/detections.ts
Normal file
9
x-pack/legacy/plugins/siem/cypress/screens/detections.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export const LOADING_SIGNALS_PANEL = '[data-test-subj="loading-signals-panel"]';
|
||||
|
||||
export const MANAGE_SIGNAL_DETECTION_RULES_BTN = '[data-test-subj="manage-signal-detection-rules"]';
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export const ELASTIC_RULES_BTN = '[data-test-subj="show-elastic-rules-filter-button"]';
|
||||
|
||||
export const LOAD_PREBUILT_RULES_BTN = '[data-test-subj="load-prebuilt-rules"]';
|
||||
|
||||
export const LOADING_INITIAL_PREBUILT_RULES_TABLE =
|
||||
'[data-test-subj="initialLoadingPanelAllRulesTable"]';
|
||||
|
||||
export const LOADING_SPINNER = '[data-test-subj="loading-spinner"]';
|
||||
|
||||
export const PAGINATION_POPOVER_BTN = '[data-test-subj="tablePaginationPopoverButton"]';
|
||||
|
||||
export const RULES_TABLE = '[data-test-subj="rules-table"]';
|
||||
|
||||
export const RULES_ROW = '.euiTableRow';
|
||||
|
||||
export const THREE_HUNDRED_ROWS = '[data-test-subj="tablePagination-300-rows"]';
|
28
x-pack/legacy/plugins/siem/cypress/tasks/detections.ts
Normal file
28
x-pack/legacy/plugins/siem/cypress/tasks/detections.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* 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 { LOADING_SIGNALS_PANEL, MANAGE_SIGNAL_DETECTION_RULES_BTN } from '../screens/detections';
|
||||
|
||||
export const goToManageSignalDetectionRules = () => {
|
||||
cy.get(MANAGE_SIGNAL_DETECTION_RULES_BTN)
|
||||
.should('exist')
|
||||
.click({ force: true });
|
||||
};
|
||||
|
||||
export const waitForSignalsIndexToBeCreated = () => {
|
||||
cy.request({ url: '/api/detection_engine/index', retryOnStatusCodeFailure: true }).then(
|
||||
response => {
|
||||
if (response.status !== 200) {
|
||||
cy.wait(7500);
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export const waitForSignalsPanelToBeLoaded = () => {
|
||||
cy.get(LOADING_SIGNALS_PANEL).should('exist');
|
||||
cy.get(LOADING_SIGNALS_PANEL).should('not.exist');
|
||||
};
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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 {
|
||||
LOAD_PREBUILT_RULES_BTN,
|
||||
LOADING_INITIAL_PREBUILT_RULES_TABLE,
|
||||
LOADING_SPINNER,
|
||||
PAGINATION_POPOVER_BTN,
|
||||
RULES_TABLE,
|
||||
THREE_HUNDRED_ROWS,
|
||||
} from '../screens/signal_detection_rules';
|
||||
|
||||
export const changeToThreeHundredRowsPerPage = () => {
|
||||
cy.get(PAGINATION_POPOVER_BTN).click({ force: true });
|
||||
cy.get(THREE_HUNDRED_ROWS).click();
|
||||
};
|
||||
|
||||
export const loadPrebuiltDetectionRules = () => {
|
||||
cy.get(LOAD_PREBUILT_RULES_BTN)
|
||||
.should('exist')
|
||||
.click({ force: true });
|
||||
};
|
||||
|
||||
export const waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded = () => {
|
||||
cy.get(LOADING_INITIAL_PREBUILT_RULES_TABLE).should('exist');
|
||||
cy.get(LOADING_INITIAL_PREBUILT_RULES_TABLE).should('not.exist');
|
||||
};
|
||||
|
||||
export const waitForPrebuiltDetectionRulesToBeLoaded = () => {
|
||||
cy.get(LOAD_PREBUILT_RULES_BTN).should('not.exist');
|
||||
cy.get(RULES_TABLE).should('exist');
|
||||
};
|
||||
|
||||
export const waitForRulesToBeLoaded = () => {
|
||||
cy.get(LOADING_SPINNER).should('exist');
|
||||
cy.get(LOADING_SPINNER).should('not.exist');
|
||||
};
|
|
@ -4,6 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export const DETECTIONS = 'app/siem#/detections';
|
||||
export const HOSTS_PAGE = '/app/siem#/hosts/allHosts';
|
||||
export const HOSTS_PAGE_TAB_URLS = {
|
||||
allHosts: '/app/siem#/hosts/allHosts',
|
||||
|
|
|
@ -16,6 +16,7 @@ exports[`rendering renders correctly 1`] = `
|
|||
grow={false}
|
||||
>
|
||||
<EuiLoadingSpinner
|
||||
data-test-subj="loading-spinner"
|
||||
size="xl"
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
|
|
|
@ -62,7 +62,7 @@ export const Loader = React.memo<LoaderProps>(({ children, overlay, overlayBackg
|
|||
<Aside overlay={overlay} overlayBackground={overlayBackground}>
|
||||
<FlexGroup overlay={{ overlay }}>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiLoadingSpinner size={size} />
|
||||
<EuiLoadingSpinner data-test-subj="loading-spinner" size={size} />
|
||||
</EuiFlexItem>
|
||||
|
||||
{children && (
|
||||
|
|
|
@ -290,7 +290,7 @@ const SignalsTableComponent: React.FC<SignalsTableComponentProps> = ({
|
|||
return (
|
||||
<EuiPanel>
|
||||
<HeaderSection title={i18n.SIGNALS_TABLE_TITLE} />
|
||||
<EuiLoadingContent />
|
||||
<EuiLoadingContent data-test-subj="loading-signals-panel" />
|
||||
</EuiPanel>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -129,7 +129,12 @@ const DetectionEnginePageComponent: React.FC<PropsFromRedux> = ({
|
|||
}
|
||||
title={i18n.PAGE_TITLE}
|
||||
>
|
||||
<EuiButton fill href={getRulesUrl()} iconType="gear">
|
||||
<EuiButton
|
||||
fill
|
||||
href={getRulesUrl()}
|
||||
iconType="gear"
|
||||
data-test-subj="manage-signal-detection-rules"
|
||||
>
|
||||
{i18n.BUTTON_MANAGE_RULES}
|
||||
</EuiButton>
|
||||
</DetectionEngineHeaderPage>
|
||||
|
|
|
@ -317,6 +317,7 @@ export const AllRules = React.memo<AllRulesProps>(
|
|||
</UtilityBarSection>
|
||||
</UtilityBar>
|
||||
<MyEuiBasicTable
|
||||
data-test-subj="rules-table"
|
||||
columns={columns}
|
||||
isSelectable={!hasNoPermissions ?? false}
|
||||
itemId="id"
|
||||
|
|
|
@ -43,6 +43,7 @@ const PrePackagedRulesPromptComponent: React.FC<PrePackagedRulesPromptProps> = (
|
|||
isDisabled={userHasNoPermissions}
|
||||
isLoading={loading}
|
||||
onClick={handlePreBuiltCreation}
|
||||
data-test-subj="load-prebuilt-rules"
|
||||
>
|
||||
{i18n.PRE_BUILT_ACTION}
|
||||
</EuiButton>
|
||||
|
|
|
@ -8,6 +8,8 @@ import { resolve } from 'path';
|
|||
|
||||
import { FtrConfigProviderContext } from '@kbn/test/types/ftr';
|
||||
|
||||
import { CA_CERT_PATH } from '@kbn/dev-utils';
|
||||
|
||||
import { SiemCypressTestRunner } from './runner';
|
||||
|
||||
export default async function({ readConfigFile }: FtrConfigProviderContext) {
|
||||
|
@ -32,6 +34,8 @@ export default async function({ readConfigFile }: FtrConfigProviderContext) {
|
|||
serverArgs: [
|
||||
...xpackFunctionalTestsConfig.get('esTestCluster.serverArgs'),
|
||||
// define custom es server here
|
||||
'xpack.security.authc.api_key.enabled=true',
|
||||
'xpack.security.enabled=true',
|
||||
],
|
||||
},
|
||||
|
||||
|
@ -41,6 +45,7 @@ export default async function({ readConfigFile }: FtrConfigProviderContext) {
|
|||
...xpackFunctionalTestsConfig.get('kbnTestServer.serverArgs'),
|
||||
'--csp.strict=false',
|
||||
// define custom kibana server args here
|
||||
`--elasticsearch.ssl.certificateAuthorities=${CA_CERT_PATH}`,
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue