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][API testing] Move and restructures Lists APIS #171992

Merged
merged 20 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2dd0ea2
move out the tests and split them into two groups to reduce execution…
WafaaNasr Nov 27, 2023
24998c5
rename index
WafaaNasr Nov 27, 2023
cdbb1bc
Merge branch 'main' of https://github.com/elastic/kibana into move-st…
WafaaNasr Nov 27, 2023
cbd7ba2
undo package.json
WafaaNasr Nov 27, 2023
32b751a
Update package.json
WafaaNasr Nov 27, 2023
eb81493
undo package.json new line
WafaaNasr Nov 27, 2023
33d4305
Merge branch 'move-structure-list-apis' of https://github.com/WafaaNa…
WafaaNasr Nov 27, 2023
164ce62
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 27, 2023
ebc230b
update old files
WafaaNasr Nov 27, 2023
2610c09
Merge branch 'move-structure-list-apis' of https://github.com/WafaaNa…
WafaaNasr Nov 27, 2023
4252208
fix import in index
WafaaNasr Nov 27, 2023
ab80e94
Merge branch 'main' of https://github.com/elastic/kibana into move-st…
WafaaNasr Nov 27, 2023
9512890
Merge branch 'main' of https://github.com/elastic/kibana into move-st…
WafaaNasr Nov 28, 2023
638fdf8
duplicate list utils in old detection_engine to fix types import unti…
WafaaNasr Nov 28, 2023
ea6b10f
Merge branch 'main' of https://github.com/elastic/kibana into move-st…
WafaaNasr Nov 28, 2023
df2a0ea
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 28, 2023
c4e4216
remove the rest of unused utils
WafaaNasr Nov 28, 2023
1c88db3
Merge branch 'move-structure-list-apis' of https://github.com/WafaaNa…
WafaaNasr Nov 28, 2023
ab329e5
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 28, 2023
e7c6037
Merge branch 'main' into move-structure-list-apis
WafaaNasr Nov 28, 2023
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
6 changes: 5 additions & 1 deletion .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ enabled:
- x-pack/test/kubernetes_security/basic/config.ts
- x-pack/test/licensing_plugin/config.public.ts
- x-pack/test/licensing_plugin/config.ts
- x-pack/test/lists_api_integration/security_and_spaces/config.ts
- x-pack/test/monitoring_api_integration/config.ts
- x-pack/test/observability_api_integration/basic/config.ts
- x-pack/test/observability_api_integration/trial/config.ts
Expand Down Expand Up @@ -492,4 +491,9 @@ enabled:
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/telemetry/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/basic_essentials_license/detection_engine/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/basic_essentials_license/detection_engine/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/default_license/exception_lists_items/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/default_license/exception_lists_items/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/default_license/lists_items/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/default_license/lists_items/configs/ess.config.ts


14 changes: 7 additions & 7 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,6 @@ x-pack/plugins/cloud_integrations/cloud_full_story/server/config.ts @elastic/kib
/x-pack/test/functional/es_archives/endpoint/ @elastic/security-solution
/x-pack/test/plugin_functional/test_suites/resolver/ @elastic/security-solution
/x-pack/test/detection_engine_api_integration @elastic/security-solution
/x-pack/test/lists_api_integration @elastic/security-solution
/x-pack/test/api_integration/apis/security_solution @elastic/security-solution
#CC# /x-pack/plugins/security_solution/ @elastic/security-solution

Expand Down Expand Up @@ -1394,13 +1393,14 @@ x-pack/test/security_solution_cypress/cypress/tasks/expandable_flyout @elastic/
/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics @elastic/security-detection-engine
/x-pack/test/security_solution_cypress/cypress/e2e/exceptions @elastic/security-detection-engine
/x-pack/test/security_solution_cypress/cypress/e2e/overview @elastic/security-detection-engine
x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/exceptions @elastic/security-detection-engine
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/test/security_solution_api_integration/test_suites/detections_response/basic_essentials_license/detection_engine @elastic/security-detection-engine
/x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/exceptions @elastic/security-detection-engine
/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/test/security_solution_api_integration/test_suites/detections_response/basic_essentials_license/detection_engine @elastic/security-detection-engine
/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users @elastic/security-detection-engine
/x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists @elastic/security-detection-engine

## Security Threat Intelligence - Under Security Platform
/x-pack/plugins/security_solution/public/common/components/threat_match @elastic/security-detection-engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,19 @@ export const getExceptionListItemSchemaMock = (
* This is useful for end to end tests where we remove the auto generated parts for comparisons
* such as created_at, updated_at, and id.
*/
export const getExceptionListItemResponseMockWithoutAutoGeneratedValues =
(): Partial<ExceptionListItemSchema> => ({
comments: [],
created_by: ELASTIC_USER,
description: DESCRIPTION,
entries: ENTRIES,
item_id: ITEM_ID,
list_id: LIST_ID,
name: NAME,
namespace_type: 'single',
os_types: OS_TYPES,
tags: [],
type: ITEM_TYPE,
updated_by: ELASTIC_USER,
});
export const getExceptionListItemResponseMockWithoutAutoGeneratedValues = (
elasticUser: string = ELASTIC_USER
): Partial<ExceptionListItemSchema> => ({
comments: [],
created_by: elasticUser,
description: DESCRIPTION,
entries: ENTRIES,
item_id: ITEM_ID,
list_id: LIST_ID,
name: NAME,
namespace_type: 'single',
os_types: OS_TYPES,
tags: [],
type: ITEM_TYPE,
updated_by: elasticUser,
});
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,18 @@ export const getTrustedAppsListSchemaMock = (): ExceptionListSchema => {
* This is useful for end to end tests where we remove the auto generated parts for comparisons
* such as created_at, updated_at, and id.
*/
export const getExceptionResponseMockWithoutAutoGeneratedValues =
(): Partial<ExceptionListSchema> => ({
created_by: ELASTIC_USER,
description: DESCRIPTION,
immutable: IMMUTABLE,
list_id: LIST_ID,
name: NAME,
namespace_type: 'single',
os_types: [],
tags: [],
type: ENDPOINT_TYPE,
updated_by: ELASTIC_USER,
version: VERSION,
});
export const getExceptionResponseMockWithoutAutoGeneratedValues = (
elasticUser: string = ELASTIC_USER
): Partial<ExceptionListSchema> => ({
created_by: elasticUser,
description: DESCRIPTION,
immutable: IMMUTABLE,
list_id: LIST_ID,
name: NAME,
namespace_type: 'single',
os_types: [],
tags: [],
type: ENDPOINT_TYPE,
updated_by: elasticUser,
version: VERSION,
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ export const getListItemResponseMock = (): ListItemSchema => ({
* This is useful for end to end tests where we remove the auto generated parts for comparisons
* such as created_at, updated_at, and id.
*/
export const getListItemResponseMockWithoutAutoGeneratedValues = (): Partial<ListItemSchema> => ({
created_by: ELASTIC_USER,
export const getListItemResponseMockWithoutAutoGeneratedValues = (
elasticUser: string = ELASTIC_USER
): Partial<ListItemSchema> => ({
created_by: elasticUser,
list_id: LIST_ID,
type: TYPE,
updated_by: ELASTIC_USER,
updated_by: elasticUser,
value: VALUE,
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ export const getListResponseMock = (): ListSchema => ({
* This is useful for end to end tests where we remove the auto generated parts for comparisons
* such as created_at, updated_at, and id.
*/
export const getListResponseMockWithoutAutoGeneratedValues = (): Partial<ListSchema> => ({
created_by: ELASTIC_USER,
export const getListResponseMockWithoutAutoGeneratedValues = (
elasticUser: string = ELASTIC_USER
): Partial<ListSchema> => ({
created_by: elasticUser,
description: DESCRIPTION,
immutable: IMMUTABLE,
name: NAME,
type: TYPE,
updated_by: ELASTIC_USER,
updated_by: elasticUser,
version: VERSION,
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import {
deleteAllRules,
deleteAllAlerts,
getSimpleRule,
deleteAllExceptions,
} from '../../utils';
import { deleteAllExceptions } from '../../../lists_api_integration/utils';
import { createUserAndRole, deleteUserAndRole } from '../../../common/services/security_solution';

// This test was meant to be more full flow, ensuring that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import {
createRule,
getRule,
getRuleSOById,
deleteAllExceptions,
} from '../../utils';
import { deleteAllExceptions } from '../../../lists_api_integration/utils';
import { createUserAndRole, deleteUserAndRole } from '../../../common/services/security_solution';

const getImportRuleBuffer = (connectorId: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { getCreateExceptionListDetectionSchemaMock } from '@kbn/lists-plugin/com
import { EXCEPTION_LIST_ITEM_URL, EXCEPTION_LIST_URL } from '@kbn/securitysolution-list-constants';
import { getCreateExceptionListItemMinimalSchemaMock } from '@kbn/lists-plugin/common/schemas/request/create_exception_list_item_schema.mock';
import { WebhookAuthType } from '@kbn/stack-connectors-plugin/common/webhook/constants';
import { deleteAllExceptions } from '../../../lists_api_integration/utils';
import {
binaryToString,
createLegacyRuleAction,
Expand All @@ -44,6 +43,7 @@ import {
createRuleThroughAlertingEndpoint,
getRuleSavedObjectWithLegacyInvestigationFields,
getRuleSavedObjectWithLegacyInvestigationFieldsEmptyArray,
deleteAllExceptions,
} from '../../utils';
import { FtrProviderContext } from '../../common/ftr_provider_context';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import {
getWebHookAction,
removeServerGeneratedProperties,
ruleToNdjson,
deleteAllExceptions,
} from '../../utils';
import { deleteAllExceptions } from '../../../lists_api_integration/utils';
import { createUserAndRole, deleteUserAndRole } from '../../../common/services/security_solution';

const getImportRuleBuffer = (connectorId: string) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

// Should be deleted once all all the remaining tests in this folder get moved to the new /security_solution_api_integration folder

import type SuperTest from 'supertest';

import type { ExceptionList, NamespaceType } from '@kbn/securitysolution-io-ts-list-types';
import { EXCEPTION_LIST_URL } from '@kbn/securitysolution-list-constants';

import { ToolingLog } from '@kbn/tooling-log';
import { countDownTest } from './count_down_test';

/**
* Remove all exceptions from both the "single" and "agnostic" spaces.
* This will retry 50 times before giving up and hopefully still not interfere with other tests
* @param supertest The supertest handle
*/
export const deleteAllExceptions = async (
supertest: SuperTest.SuperTest<SuperTest.Test>,
log: ToolingLog
): Promise<void> => {
await deleteAllExceptionsByType(supertest, log, 'single');
await deleteAllExceptionsByType(supertest, log, 'agnostic');
};

/**
* Remove all exceptions by a given type such as "agnostic" or "single".
* This will retry 50 times before giving up and hopefully still not interfere with other tests
* @param supertest The supertest handle
*/
export const deleteAllExceptionsByType = async (
supertest: SuperTest.SuperTest<SuperTest.Test>,
log: ToolingLog,
type: NamespaceType
): Promise<void> => {
await countDownTest(
async () => {
const { body } = await supertest
.get(`${EXCEPTION_LIST_URL}/_find?per_page=9999&namespace_type=${type}`)
.set('kbn-xsrf', 'true')
.send();
const ids: string[] = body.data.map((exception: ExceptionList) => exception.id);
for await (const id of ids) {
await supertest
.delete(`${EXCEPTION_LIST_URL}?id=${id}&namespace_type=${type}`)
.set('kbn-xsrf', 'true')
.send();
}
const { body: finalCheck } = await supertest
.get(`${EXCEPTION_LIST_URL}/_find?namespace_type=${type}`)
.set('kbn-xsrf', 'true')
.send();
return {
passed: finalCheck.data.length === 0,
};
},
`deleteAllExceptions by type: "${type}"`,
log,
50,
1000
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ export * from './prebuilt_rules/delete_all_prebuilt_rule_assets';
export * from './prebuilt_rules/install_mock_prebuilt_rules';
export * from './prebuilt_rules/install_prebuilt_rules_and_timelines';
export * from './get_legacy_action_so';
export * from './delete_all_exceptions';
66 changes: 0 additions & 66 deletions x-pack/test/lists_api_integration/common/config.ts

This file was deleted.

12 changes: 0 additions & 12 deletions x-pack/test/lists_api_integration/common/ftr_provider_context.d.ts

This file was deleted.

8 changes: 0 additions & 8 deletions x-pack/test/lists_api_integration/common/services.ts

This file was deleted.

Loading
Loading