Skip to content

Commit ae0f091

Browse files
[9.1] [ska] relocate common services and utils to security_solution_api_integration dir (elastic#228780) (elastic#231623)
# Backport This will backport the following commits from `main` to `9.1`: - [[ska] relocate common services and utils to security_solution_api_integration dir (elastic#228780)](elastic#228780) <!--- Backport version: 10.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Dzmitry Lemechko","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-08-08T09:48:47Z","message":"[ska] relocate common services and utils to security_solution_api_integration dir (elastic#228780)\n\n## Summary\n\nIt is a preparation work before we relocate\n`x-pack/test/security_solution_api_integration` under\n`x-pack/solutions/security/test`:\n\n- moving helpers/utils inside directory to avoid updating imports after\nrelocation\n- importing from `security_solution_api_integration` inside\n`x-pack/solutions/security/test` leads to circular dependency issue, so\nI copied `common/utils/detections_response` as a temporary workaround\nuntil tests dir is relocated\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>\nCo-authored-by: Maxim Palenov <[email protected]>","sha":"0051e2c7d2c1cb10124de1385bb3fd7974173a3c","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport missing","backport:version","v9.2.0","v9.1.1","v8.19.1"],"title":"[ska] relocate common services and utils to security_solution_api_integration dir","number":228780,"url":"https://github.com/elastic/kibana/pull/228780","mergeCommit":{"message":"[ska] relocate common services and utils to security_solution_api_integration dir (elastic#228780)\n\n## Summary\n\nIt is a preparation work before we relocate\n`x-pack/test/security_solution_api_integration` under\n`x-pack/solutions/security/test`:\n\n- moving helpers/utils inside directory to avoid updating imports after\nrelocation\n- importing from `security_solution_api_integration` inside\n`x-pack/solutions/security/test` leads to circular dependency issue, so\nI copied `common/utils/detections_response` as a temporary workaround\nuntil tests dir is relocated\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>\nCo-authored-by: Maxim Palenov <[email protected]>","sha":"0051e2c7d2c1cb10124de1385bb3fd7974173a3c"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/228780","number":228780,"mergeCommit":{"message":"[ska] relocate common services and utils to security_solution_api_integration dir (elastic#228780)\n\n## Summary\n\nIt is a preparation work before we relocate\n`x-pack/test/security_solution_api_integration` under\n`x-pack/solutions/security/test`:\n\n- moving helpers/utils inside directory to avoid updating imports after\nrelocation\n- importing from `security_solution_api_integration` inside\n`x-pack/solutions/security/test` leads to circular dependency issue, so\nI copied `common/utils/detections_response` as a temporary workaround\nuntil tests dir is relocated\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>\nCo-authored-by: Maxim Palenov <[email protected]>","sha":"0051e2c7d2c1cb10124de1385bb3fd7974173a3c"}},{"branch":"9.1","label":"v9.1.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <[email protected]>
1 parent 0c4c13d commit ae0f091

File tree

291 files changed

+1921
-640
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+1921
-640
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,8 @@ x-pack/platform/plugins/shared/ml/server/models/data_recognizer/modules/security
19401940
/x-pack/platform/test/serverless/functional/services/ @elastic/appex-qa # temporarily due to SKA tests relocation
19411941
/x-pack/platform/test/serverless/functional/config* @elastic/appex-qa
19421942
/x-pack/platform/test/serverless/functional/ftr_provider_context.d.ts @elastic/appex-qa
1943+
/x-pack/test/api_integration/services/helpers.ts @elastic/appex-qa
1944+
/x-pack/solutions/security/test/common/utils/detections_response/ @elastic/appex-qa
19431945

19441946
# Core
19451947
/src/platform/test/api_integration/fixtures/kbn_archiver/management/saved_objects/relationships.json @elastic/kibana-core @elastic/kibana-data-discovery
@@ -2098,7 +2100,6 @@ x-pack/platform/plugins/private/cloud_integrations/cloud_full_story/server/confi
20982100
/x-pack/platform/test/functional/page_objects/api_keys_page.ts @elastic/kibana-security
20992101
/x-pack/platform/test/functional/page_objects/account_settings_page.ts @elastic/kibana-security
21002102
/x-pack/platform/test/functional/apps/user_profiles @elastic/kibana-security
2101-
/x-pack/test/common/services/spaces.ts @elastic/kibana-security
21022103
/x-pack/test/api_integration/config_security_*.ts @elastic/kibana-security
21032104
/x-pack/platform/test/functional/apps/api_keys @elastic/kibana-security
21042105
/x-pack/platform/test/ftr_apis/security_and_spaces @elastic/kibana-security
@@ -2234,7 +2235,6 @@ x-pack/platform/plugins/private/cloud_integrations/cloud_full_story/server/confi
22342235
# Enterprise Search
22352236
# search
22362237
/x-pack/platform/test/fixtures/es_archives/data/search_sessions @elastic/search-kibana
2237-
/x-pack/test/common/services/search_secure.ts @elastic/search-kibana
22382238
/src/platform/test/functional/fixtures/kbn_archiver/ccs @elastic/search-kibana
22392239
/src/platform/test/functional/fixtures/kbn_archiver/annotation_listing_page_search.json @elastic/search-kibana
22402240
/src/platform/test/functional/fixtures/es_archiver/search/downsampled @elastic/search-kibana
@@ -2447,7 +2447,7 @@ x-pack/test/security_solution_api_integration/test_suites/detections_response/ut
24472447
x-pack/test/security_solution_api_integration/test_suites/detections_response/telemetry @elastic/security-detections-response
24482448
x-pack/test/security_solution_api_integration/test_suites/detections_response/user_roles @elastic/security-detections-response
24492449
x-pack/test/security_solution_api_integration/test_suites/sources @elastic/security-detections-response
2450-
/x-pack/test/common/utils/security_solution/detections_response @elastic/security-detections-response
2450+
/x-pack/test/security_solution_api_integration/config/services/detections_response/ @elastic/security-detections-response
24512451
/x-pack/solutions/security/test/fixtures/es_archives/signals @elastic/security-detections-response
24522452
/x-pack/solutions/security/test/fixtures/es_archives/rule_keyword_family @elastic/security-detections-response
24532453

src/platform/packages/shared/kbn-openapi-generator/src/template_service/templates/api_client_supertest.handlebars

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99

1010
import { ELASTIC_HTTP_VERSION_HEADER, X_ELASTIC_INTERNAL_ORIGIN_REQUEST } from '@kbn/core-http-common';
1111
import { replaceParams } from '@kbn/openapi-common/shared';
12+
import { getRouteUrlForSpace } from '@kbn/spaces-plugin/common';
1213
import { FtrProviderContext } from 'x-pack/test/api_integration/ftr_provider_context';
1314

14-
import { routeWithNamespace } from 'x-pack/test/common/utils/security_solution';
15-
1615
{{#each operations}}
1716
import {
1817
{{operationId}}RequestQueryInput,
@@ -33,7 +32,7 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext)
3332
{{/if}}
3433
{{camelCase operationId}}({{#if (or requestQuery requestParams requestBody)}}props: {{operationId}}Props, {{/if}}kibanaSpace: string = 'default') {
3534
return supertest
36-
.{{method}}(routeWithNamespace({{#if requestParams}}replaceParams('{{path}}', props.params){{else}}'{{path}}'{{/if}}, kibanaSpace))
35+
.{{method}}(getRouteUrlForSpace({{#if requestParams}}replaceParams('{{path}}', props.params){{else}}'{{path}}'{{/if}}, kibanaSpace))
3736
.set('kbn-xsrf', 'true')
3837
.set(ELASTIC_HTTP_VERSION_HEADER, '{{version}}')
3938
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
/**
9+
* Wraps the provided Kibana route URL with the Kibana space ID.
10+
* "default" space is equivalent to an empty value and doesn't lead to adding any space aware path.
11+
*
12+
* @param routeUrl the route url string
13+
* @param spaceId [optional] the Kibana space to account for in the route url
14+
*
15+
* Examples:
16+
* - `getRouteUrlForSpace('/api/some_endpoint')` returns `/api/some_endpoint`
17+
* - `getRouteUrlForSpace('/api/some_endpoint', 'default')` returns `/api/some_endpoint`
18+
* - `getRouteUrlForSpace('/api/some_endpoint', 'my_space') returns `/s/my_space/api/some_endpoint`
19+
*/
20+
export function getRouteUrlForSpace(routeUrl: string, spaceId?: string): string {
21+
return spaceId ? `/s/${spaceId}${routeUrl}` : routeUrl;
22+
}

x-pack/platform/plugins/shared/spaces/common/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export {
1313
DEFAULT_SPACE_ID,
1414
API_VERSIONS,
1515
} from './constants';
16+
export { getRouteUrlForSpace } from './get_spaced_route_url';
1617
export { addSpaceIdToPath, getSpaceIdFromPath } from '@kbn/spaces-utils';
1718
export type {
1819
Space,

x-pack/solutions/security/test/cases_api_integration/common/lib/alerts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
waitForAlertsToBePresent,
1919
getAlertsByIds,
2020
getQueryAlertIds,
21-
} from '@kbn/test-suites-xpack/common/utils/security_solution';
21+
} from '../../../common/utils/detections_response';
2222

2323
export const createSecuritySolutionAlerts = async (
2424
supertest: SuperTest.Agent,

x-pack/solutions/security/test/cases_api_integration/security_and_spaces/tests/common/cases/delete_cases.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ import {
6868
createAlertsIndex,
6969
deleteAllRules,
7070
deleteAllAlerts,
71-
} from '@kbn/test-suites-xpack/common/utils/security_solution';
71+
} from '../../../../../common/utils/detections_response';
7272
import {
7373
createSecuritySolutionAlerts,
7474
getSecuritySolutionAlerts,

x-pack/solutions/security/test/cases_api_integration/security_and_spaces/tests/common/cases/patch_cases.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ import {
4141
createConfiguration,
4242
getConfigurationRequest,
4343
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/api';
44-
import {
45-
createAlertsIndex,
46-
deleteAllAlerts,
47-
deleteAllRules,
48-
getRuleForAlertTesting,
49-
waitForRuleSuccess,
50-
waitForAlertsToBePresent,
51-
getAlertsByIds,
52-
createRule,
53-
getQueryAlertIds,
54-
} from '@kbn/test-suites-xpack/common/utils/security_solution';
5544
import {
5645
globalRead,
5746
noKibanaPrivileges,
@@ -62,6 +51,17 @@ import {
6251
secOnlyRead,
6352
superUser,
6453
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/authentication/users';
54+
import {
55+
createAlertsIndex,
56+
deleteAllAlerts,
57+
deleteAllRules,
58+
getRuleForAlertTesting,
59+
waitForRuleSuccess,
60+
waitForAlertsToBePresent,
61+
getAlertsByIds,
62+
createRule,
63+
getQueryAlertIds,
64+
} from '../../../../../common/utils/detections_response';
6565
import { getSignalsWithES } from '../../../../common/lib/api';
6666

6767
export default ({ getService }: FtrProviderContext): void => {

x-pack/solutions/security/test/cases_api_integration/security_and_spaces/tests/common/comments/delete_comment.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ import {
1111
createCaseAttachAlertAndDeleteAlert,
1212
getAlertById,
1313
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/alerts';
14-
import {
15-
createAlertsIndex,
16-
deleteAllAlerts,
17-
deleteAllRules,
18-
} from '@kbn/test-suites-xpack/common/utils/security_solution';
1914
import type { FtrProviderContext } from '@kbn/test-suites-xpack-platform/cases_api_integration/common/ftr_provider_context';
2015

2116
import {
@@ -51,6 +46,11 @@ import {
5146
secSolutionOnlyReadNoIndexAlerts,
5247
superUser,
5348
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/authentication/users';
49+
import {
50+
createAlertsIndex,
51+
deleteAllAlerts,
52+
deleteAllRules,
53+
} from '../../../../../common/utils/detections_response';
5454
import {
5555
createSecuritySolutionAlerts,
5656
getSecuritySolutionAlerts,

x-pack/solutions/security/test/cases_api_integration/security_and_spaces/tests/common/comments/delete_comments.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ import {
1111
createCaseAttachAlertAndDeleteAlert,
1212
getAlertById,
1313
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/alerts';
14-
import {
15-
createAlertsIndex,
16-
deleteAllAlerts,
17-
deleteAllRules,
18-
} from '@kbn/test-suites-xpack/common/utils/security_solution';
1914
import type { FtrProviderContext } from '@kbn/test-suites-xpack-platform/cases_api_integration/common/ftr_provider_context';
2015

2116
import {
@@ -56,6 +51,11 @@ import {
5651
secSolutionOnlyReadNoIndexAlerts,
5752
superUser,
5853
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/authentication/users';
54+
import {
55+
createAlertsIndex,
56+
deleteAllAlerts,
57+
deleteAllRules,
58+
} from '../../../../../common/utils/detections_response';
5959
import {
6060
createSecuritySolutionAlerts,
6161
getSecuritySolutionAlerts,

x-pack/solutions/security/test/cases_api_integration/security_and_spaces/tests/common/comments/post_comment.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ import {
4949
bulkCreateAttachments,
5050
getCaseSavedObjectsFromES,
5151
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/api';
52-
import {
53-
createAlertsIndex,
54-
deleteAllAlerts,
55-
deleteAllRules,
56-
} from '@kbn/test-suites-xpack/common/utils/security_solution';
5752
import {
5853
globalRead,
5954
noKibanaPrivileges,
@@ -70,6 +65,11 @@ import {
7065
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/authentication/users';
7166
import { getAlertById } from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/alerts';
7267
import type { User } from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/authentication/types';
68+
import {
69+
createAlertsIndex,
70+
deleteAllAlerts,
71+
deleteAllRules,
72+
} from '../../../../../common/utils/detections_response';
7373
import {
7474
getSecuritySolutionAlerts,
7575
createSecuritySolutionAlerts,

0 commit comments

Comments
 (0)