Skip to content
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
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -1940,6 +1940,8 @@ x-pack/platform/plugins/shared/ml/server/models/data_recognizer/modules/security
/x-pack/platform/test/serverless/functional/services/ @elastic/appex-qa # temporarily due to SKA tests relocation
/x-pack/platform/test/serverless/functional/config* @elastic/appex-qa
/x-pack/platform/test/serverless/functional/ftr_provider_context.d.ts @elastic/appex-qa
/x-pack/test/api_integration/services/helpers.ts @elastic/appex-qa
/x-pack/solutions/security/test/common/utils/detections_response/ @elastic/appex-qa

# Core
/src/platform/test/api_integration/fixtures/kbn_archiver/management/saved_objects/relationships.json @elastic/kibana-core @elastic/kibana-data-discovery
Expand Down Expand Up @@ -2098,7 +2100,6 @@ x-pack/platform/plugins/private/cloud_integrations/cloud_full_story/server/confi
/x-pack/platform/test/functional/page_objects/api_keys_page.ts @elastic/kibana-security
/x-pack/platform/test/functional/page_objects/account_settings_page.ts @elastic/kibana-security
/x-pack/platform/test/functional/apps/user_profiles @elastic/kibana-security
/x-pack/test/common/services/spaces.ts @elastic/kibana-security
/x-pack/test/api_integration/config_security_*.ts @elastic/kibana-security
/x-pack/platform/test/functional/apps/api_keys @elastic/kibana-security
/x-pack/platform/test/ftr_apis/security_and_spaces @elastic/kibana-security
Expand Down Expand Up @@ -2234,7 +2235,6 @@ x-pack/platform/plugins/private/cloud_integrations/cloud_full_story/server/confi
# Enterprise Search
# search
/x-pack/platform/test/fixtures/es_archives/data/search_sessions @elastic/search-kibana
/x-pack/test/common/services/search_secure.ts @elastic/search-kibana
/src/platform/test/functional/fixtures/kbn_archiver/ccs @elastic/search-kibana
/src/platform/test/functional/fixtures/kbn_archiver/annotation_listing_page_search.json @elastic/search-kibana
/src/platform/test/functional/fixtures/es_archiver/search/downsampled @elastic/search-kibana
Expand Down Expand Up @@ -2447,7 +2447,7 @@ x-pack/test/security_solution_api_integration/test_suites/detections_response/ut
x-pack/test/security_solution_api_integration/test_suites/detections_response/telemetry @elastic/security-detections-response
x-pack/test/security_solution_api_integration/test_suites/detections_response/user_roles @elastic/security-detections-response
x-pack/test/security_solution_api_integration/test_suites/sources @elastic/security-detections-response
/x-pack/test/common/utils/security_solution/detections_response @elastic/security-detections-response
/x-pack/test/security_solution_api_integration/config/services/detections_response/ @elastic/security-detections-response
/x-pack/solutions/security/test/fixtures/es_archives/signals @elastic/security-detections-response
/x-pack/solutions/security/test/fixtures/es_archives/rule_keyword_family @elastic/security-detections-response

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

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

import { routeWithNamespace } from 'x-pack/test/common/utils/security_solution';

{{#each operations}}
import {
{{operationId}}RequestQueryInput,
Expand All @@ -33,7 +32,7 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext)
{{/if}}
{{camelCase operationId}}({{#if (or requestQuery requestParams requestBody)}}props: {{operationId}}Props, {{/if}}kibanaSpace: string = 'default') {
return supertest
.{{method}}(routeWithNamespace({{#if requestParams}}replaceParams('{{path}}', props.params){{else}}'{{path}}'{{/if}}, kibanaSpace))
.{{method}}(getRouteUrlForSpace({{#if requestParams}}replaceParams('{{path}}', props.params){{else}}'{{path}}'{{/if}}, kibanaSpace))
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '{{version}}')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
Expand Down
Original file line number Diff line number Diff line change
@@ -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
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

/**
* Wraps the provided Kibana route URL with the Kibana space ID.
* "default" space is equivalent to an empty value and doesn't lead to adding any space aware path.
*
* @param routeUrl the route url string
* @param spaceId [optional] the Kibana space to account for in the route url
*
* Examples:
* - `getRouteUrlForSpace('/api/some_endpoint')` returns `/api/some_endpoint`
* - `getRouteUrlForSpace('/api/some_endpoint', 'default')` returns `/api/some_endpoint`
* - `getRouteUrlForSpace('/api/some_endpoint', 'my_space') returns `/s/my_space/api/some_endpoint`
*/
export function getRouteUrlForSpace(routeUrl: string, spaceId?: string): string {
return spaceId ? `/s/${spaceId}${routeUrl}` : routeUrl;
}
1 change: 1 addition & 0 deletions x-pack/platform/plugins/shared/spaces/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export {
DEFAULT_SPACE_ID,
API_VERSIONS,
} from './constants';
export { getRouteUrlForSpace } from './get_spaced_route_url';
export { addSpaceIdToPath, getSpaceIdFromPath } from '@kbn/spaces-utils';
export type {
Space,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
waitForAlertsToBePresent,
getAlertsByIds,
getQueryAlertIds,
} from '@kbn/test-suites-xpack/common/utils/security_solution';
} from '../../../common/utils/detections_response';

export const createSecuritySolutionAlerts = async (
supertest: SuperTest.Agent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import {
createAlertsIndex,
deleteAllRules,
deleteAllAlerts,
} from '@kbn/test-suites-xpack/common/utils/security_solution';
} from '../../../../../common/utils/detections_response';
import {
createSecuritySolutionAlerts,
getSecuritySolutionAlerts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,6 @@ import {
createConfiguration,
getConfigurationRequest,
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/api';
import {
createAlertsIndex,
deleteAllAlerts,
deleteAllRules,
getRuleForAlertTesting,
waitForRuleSuccess,
waitForAlertsToBePresent,
getAlertsByIds,
createRule,
getQueryAlertIds,
} from '@kbn/test-suites-xpack/common/utils/security_solution';
import {
globalRead,
noKibanaPrivileges,
Expand All @@ -62,6 +51,17 @@ import {
secOnlyRead,
superUser,
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/authentication/users';
import {
createAlertsIndex,
deleteAllAlerts,
deleteAllRules,
getRuleForAlertTesting,
waitForRuleSuccess,
waitForAlertsToBePresent,
getAlertsByIds,
createRule,
getQueryAlertIds,
} from '../../../../../common/utils/detections_response';
import { getSignalsWithES } from '../../../../common/lib/api';

export default ({ getService }: FtrProviderContext): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import {
createCaseAttachAlertAndDeleteAlert,
getAlertById,
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/alerts';
import {
createAlertsIndex,
deleteAllAlerts,
deleteAllRules,
} from '@kbn/test-suites-xpack/common/utils/security_solution';
import type { FtrProviderContext } from '@kbn/test-suites-xpack-platform/cases_api_integration/common/ftr_provider_context';

import {
Expand Down Expand Up @@ -51,6 +46,11 @@ import {
secSolutionOnlyReadNoIndexAlerts,
superUser,
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/authentication/users';
import {
createAlertsIndex,
deleteAllAlerts,
deleteAllRules,
} from '../../../../../common/utils/detections_response';
import {
createSecuritySolutionAlerts,
getSecuritySolutionAlerts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import {
createCaseAttachAlertAndDeleteAlert,
getAlertById,
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/alerts';
import {
createAlertsIndex,
deleteAllAlerts,
deleteAllRules,
} from '@kbn/test-suites-xpack/common/utils/security_solution';
import type { FtrProviderContext } from '@kbn/test-suites-xpack-platform/cases_api_integration/common/ftr_provider_context';

import {
Expand Down Expand Up @@ -56,6 +51,11 @@ import {
secSolutionOnlyReadNoIndexAlerts,
superUser,
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/authentication/users';
import {
createAlertsIndex,
deleteAllAlerts,
deleteAllRules,
} from '../../../../../common/utils/detections_response';
import {
createSecuritySolutionAlerts,
getSecuritySolutionAlerts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ import {
bulkCreateAttachments,
getCaseSavedObjectsFromES,
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/api';
import {
createAlertsIndex,
deleteAllAlerts,
deleteAllRules,
} from '@kbn/test-suites-xpack/common/utils/security_solution';
import {
globalRead,
noKibanaPrivileges,
Expand All @@ -70,6 +65,11 @@ import {
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/authentication/users';
import { getAlertById } from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/alerts';
import type { User } from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/authentication/types';
import {
createAlertsIndex,
deleteAllAlerts,
deleteAllRules,
} from '../../../../../common/utils/detections_response';
import {
getSecuritySolutionAlerts,
createSecuritySolutionAlerts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ import {
createComment,
getCaseSavedObjectsFromES,
} from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/api';
import {
createAlertsIndex,
deleteAllAlerts,
deleteAllRules,
} from '@kbn/test-suites-xpack/common/utils/security_solution';
import {
globalRead,
noKibanaPrivileges,
Expand All @@ -67,6 +62,11 @@ import { getAlertById } from '@kbn/test-suites-xpack-platform/cases_api_integrat
import type { User } from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/authentication/types';
import { SECURITY_SOLUTION_FILE_KIND } from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/constants';
import { arraysToEqual } from '@kbn/test-suites-xpack-platform/cases_api_integration/common/lib/validation';
import {
createAlertsIndex,
deleteAllAlerts,
deleteAllRules,
} from '../../../../../common/utils/detections_response';
import {
getSecuritySolutionAlerts,
createSecuritySolutionAlerts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { resolve } from 'path';
import type { FtrConfigProviderContext } from '@kbn/test';
import { pageObjects } from '../page_objects';
import { services } from '../services';

export default async function ({ readConfigFile }: FtrConfigProviderContext) {
const xpackFunctionalConfig = await readConfigFile(
Expand All @@ -17,6 +18,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
return {
...xpackFunctionalConfig.getAll(),
pageObjects,
services,
testFiles: [resolve(__dirname, './data_views')],
junit: {
reportName: 'X-Pack Cloud Security Posture Functional Tests',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { GenericFtrProviderContext } from '@kbn/test';

import { services } from '@kbn/test-suites-xpack/functional/services';
import { services } from './services';
import { pageObjects } from './page_objects';

export type FtrProviderContext = GenericFtrProviderContext<typeof services, typeof pageObjects>;
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
* 2.0.
*/

import { services as platformServices } from '@kbn/test-suites-xpack-platform/functional/services';
import { QueryBarProvider } from './query_bar_provider';

export const services = {
...platformServices,
queryBarProvider: QueryBarProvider,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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.
*/

import type { ToolingLog } from '@kbn/tooling-log';
import type SuperTest from 'supertest';

import {
DETECTION_ENGINE_RULES_BULK_ACTION,
DETECTION_ENGINE_RULES_URL,
} from '@kbn/security-solution-plugin/common/constants';
import { countDownTest } from '../count_down_test';

/**
* Removes all rules by looping over any found and removing them from REST.
* @param supertest The supertest agent.
*/
export const deleteAllRules = async (
supertest: SuperTest.Agent,
log: ToolingLog
): Promise<void> => {
await countDownTest(
async () => {
await supertest
.post(DETECTION_ENGINE_RULES_BULK_ACTION)
.send({ action: 'delete', query: '' })
.set('kbn-xsrf', 'true')
.set('elastic-api-version', '2023-10-31');

const { body: finalCheck } = await supertest
.get(`${DETECTION_ENGINE_RULES_URL}/_find`)
.set('kbn-xsrf', 'true')
.set('elastic-api-version', '2023-10-31')
.send();
return {
passed: finalCheck.data.length === 0,
};
},
'deleteAllRules',
log,
50,
1000
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* 2.0.
*/

import type { QueryRuleCreateProps } from '@kbn/security-solution-plugin/common/api/detection_engine';
import {
DETECTION_ENGINE_RULES_BULK_ACTION,
DETECTION_ENGINE_RULES_URL,
} from '@kbn/security-solution-plugin/common/constants';
import type { QueryRuleCreateProps } from '@kbn/security-solution-plugin/common/api/detection_engine';

import { APIRequestContext } from '@playwright/test';
import { getCommonHeadersWithApiVersion } from './headers';
Expand Down
5 changes: 3 additions & 2 deletions x-pack/solutions/security/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"@kbn/ambient-ui-types",
"@kbn/ambient-ftr-types"
],
"resolveJsonModule": true,
"resolveJsonModule": true
},
"include": [
"**/*",
"../../../../typings/**/*",
"../../../../src/platform/packages/shared/kbn-test/types/ftr_globals/**/*",
"../../../../src/platform/packages/shared/kbn-test/types/ftr_globals/**/*"
],
"exclude": ["target/**/*", "*/plugins/**/*", "plugins/**/*"],
"kbn_references": [
Expand Down Expand Up @@ -49,5 +49,6 @@
"@kbn/session-view-plugin",
"@kbn/repo-info",
"@kbn/es-archiver",
"@kbn/task-manager-plugin"
]
}
Loading