Skip to content

Commit

Permalink
[Security Solution][API testing] Move and restructures Privileges rel…
Browse files Browse the repository at this point in the history
…ated tests and Action Throttle (#171397)

## Summary

Following the initial work in this
#166755
- Addresses part of #151902 for
Privileges related tests and Action Throttle
- Moved the utility files associated with telemetry to the new directory
`security_solution_api_integration`. Files not actively used in the
previous folder were moved, while duplicate files remained in their
original positions.
- Updated the CodeOwner file for the newly moved tests
- Old/new group details, decisions, and execution time are mentioned in
this
[document](https://docs.google.com/document/d/1CRFfDWMzw3ob03euWIvT4-IoiLXjoiPWI8mTBqP4Zks/edit)
- The **Privileges** Tests are skipped in Serverless now until the FTR
Roles [PR](#170131) gets merged

| Action | File | New Path if moved |
|--------|------|----------|
| Delete| security_and_spaces/group4| - |
|
Move|detection_engine_api_integration/security_and_spaces/group10/throttle|detections_response/default_license/action/throttle|
|
Move|detection_engine_api_integration/security_and_spaces/group1/check_privileges|detections_response/default_license/actions/check_privileges|
|
Move|detection_engine_api_integration/security_and_spaces/group10/read_privileges|detections_response/default_license/user_roles/read_privileges|
  • Loading branch information
WafaaNasr authored Nov 16, 2023
1 parent ac13f73 commit 7c80161
Show file tree
Hide file tree
Showing 18 changed files with 168 additions and 54 deletions.
4 changes: 3 additions & 1 deletion .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -474,4 +474,6 @@ enabled:
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/update_prebuilt_rules_package/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/update_prebuilt_rules_package/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_execution_logic/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_execution_logic/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_execution_logic/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/user_roles/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/user_roles/configs/ess.config.ts
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,7 @@ x-pack/test/security_solution_api_integration/test_suites/detections_response/de
x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_creation @elastic/security-detection-engine
x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/actions @elastic/security-detection-engine
x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/alerts @elastic/security-detection-engine
x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/user_roles @elastic/security-detection-engine
/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users @elastic/security-detection-engine

## Security Threat Intelligence - Under Security Platform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default ({ loadTestFile }: FtrProviderContext): void => {
// action migration code. We are monitoring legacy action telemetry to clean up once we see their
// existence being near 0.

loadTestFile(require.resolve('./check_privileges'));
loadTestFile(require.resolve('./create_rules_bulk'));
loadTestFile(require.resolve('./delete_rules'));
loadTestFile(require.resolve('./delete_rules_bulk'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,5 @@ export default ({ loadTestFile }: FtrProviderContext): void => {
loadTestFile(require.resolve('./perform_bulk_action'));
loadTestFile(require.resolve('./perform_bulk_action_dry_run'));
loadTestFile(require.resolve('./patch_rules'));
loadTestFile(require.resolve('./read_privileges'));
loadTestFile(require.resolve('./throttle'));
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export * from './create_exception_list_item';
export * from './create_legacy_rule_action';
export * from './create_new_action';
export * from './create_rule';
export * from './create_rule_with_auth';
export * from './create_rule_with_exception_entries';
export * from './create_rule_saved_object';
export * from './create_signals_index';
Expand Down
8 changes: 6 additions & 2 deletions x-pack/test/security_solution_api_integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@
"rule_execution_logic:runner:serverless": "npm run run-tests:dr:default rule_execution_logic serverless serverlessEnv",
"rule_execution_logic:qa:serverless": "npm run run-tests:dr:default rule_execution_logic serverless qaEnv",
"rule_execution_logic:server:ess": "npm run initialize-server:dr:default rule_execution_logic ess",
"rule_execution_logic:runner:ess": "npm run run-tests:dr:default rule_execution_logic ess essEnv"

"rule_execution_logic:runner:ess": "npm run run-tests:dr:default rule_execution_logic ess essEnv",
"user_roles:server:serverless": "npm run initialize-server:dr:default user_roles serverless",
"user_roles:runner:serverless": "npm run run-tests:dr:default user_roles serverless serverlessEnv",
"user_roles:qa:serverless": "npm run run-tests:dr:default user_roles serverless qaEnv",
"user_roles:server:ess": "npm run initialize-server:dr:default user_roles ess",
"user_roles:runner:ess": "npm run run-tests:dr:default user_roles ess essEnv"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import expect from 'expect';

import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
import { DETECTION_ENGINE_RULES_URL } from '@kbn/security-solution-plugin/common/constants';
import {
deleteAllRules,
Expand Down Expand Up @@ -55,7 +55,7 @@ export default ({ getService }: FtrProviderContext) => {
const { body } = await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.set('elastic-api-version', '2023-10-31')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.send(
getCustomQueryRuleParams({
actions: [ruleAction],
Expand All @@ -74,7 +74,7 @@ export default ({ getService }: FtrProviderContext) => {
} = await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.set('elastic-api-version', '2023-10-31')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.send(
getCustomQueryRuleParams({
index: ['logs-test'],
Expand Down Expand Up @@ -108,7 +108,7 @@ export default ({ getService }: FtrProviderContext) => {
} = await supertest
.post(DETECTION_ENGINE_RULES_URL)
.set('kbn-xsrf', 'true')
.set('elastic-api-version', '2023-10-31')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.send(
getCustomQueryRuleParams({
index: ['logs-test'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,34 @@ import expect from '@kbn/expect';
import { DETECTION_ENGINE_RULES_URL } from '@kbn/security-solution-plugin/common/constants';
import { ROLES } from '@kbn/security-solution-plugin/common/test';
import { ThresholdRuleCreateProps } from '@kbn/security-solution-plugin/common/api/detection_engine';
import { FtrProviderContext } from '../../common/ftr_provider_context';

import {
createSignalsIndex,
createAlertsIndex,
deleteAllRules,
waitForRulePartialFailure,
getRuleForSignalTesting,
getRuleForAlertTesting,
createRuleWithAuth,
getThresholdRuleForSignalTesting,
getThresholdRuleForAlertTesting,
deleteAllAlerts,
} from '../../utils';
import { createUserAndRole, deleteUserAndRole } from '../../../common/services/security_solution';
import {
createUserAndRole,
deleteUserAndRole,
} from '../../../../../common/services/security_solution';

// eslint-disable-next-line import/no-default-export
import { FtrProviderContext } from '../../../../ftr_provider_context';
export default ({ getService }: FtrProviderContext) => {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
const supertestWithoutAuth = getService('supertestWithoutAuth');
const log = getService('log');
const es = getService('es');

describe('check_privileges', () => {
describe('@ess @serverless @brokenInServerless check_privileges', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
await esArchiver.load('x-pack/test/functional/es_archives/security_solution/alias');
await createSignalsIndex(supertest, log);
await createAlertsIndex(supertest, log);
});

after(async () => {
Expand All @@ -60,7 +63,7 @@ export default ({ getService }: FtrProviderContext) => {
indexTestCases.forEach((index) => {
it(`for KQL rule with index param: ${index}`, async () => {
const rule = {
...getRuleForSignalTesting(index),
...getRuleForAlertTesting(index),
query: 'process.executable: "/usr/bin/sudo"',
};
await createUserAndRole(getService, ROLES.detections_admin);
Expand Down Expand Up @@ -96,7 +99,7 @@ export default ({ getService }: FtrProviderContext) => {
thresholdIndexTestCases.forEach((index) => {
it(`for threshold rule with index param: ${index}`, async () => {
const rule: ThresholdRuleCreateProps = {
...getThresholdRuleForSignalTesting(index),
...getThresholdRuleForAlertTesting(index),
threshold: {
field: [],
value: 700,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ export default function ({ loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./add_actions'));
loadTestFile(require.resolve('./update_actions'));
loadTestFile(require.resolve('./migrations'));
loadTestFile(require.resolve('./throttle'));
loadTestFile(require.resolve('./check_privileges'));
});
}
Loading

0 comments on commit 7c80161

Please sign in to comment.