diff --git a/package.json b/package.json index a4ad1dd7e5e81..696e5aa63a5d5 100644 --- a/package.json +++ b/package.json @@ -1523,7 +1523,7 @@ "@types/source-map-support": "^0.5.3", "@types/stats-lite": "^2.2.0", "@types/styled-components": "^5.1.0", - "@types/supertest": "^2.0.12", + "@types/supertest": "^6.0.2", "@types/tapable": "^1.0.6", "@types/tar": "^6.1.11", "@types/testing-library__jest-dom": "^5.14.7", @@ -1697,8 +1697,8 @@ "style-loader": "^1.1.3", "stylelint": "^14.9.1", "stylelint-scss": "^4.3.0", - "superagent": "^8.1.2", - "supertest": "^6.3.3", + "superagent": "^9.0.2", + "supertest": "^7.0.0", "svgo": "^2.8.0", "table": "^6.8.1", "tape": "^5.0.1", diff --git a/packages/core/http/core-http-server-internal/src/http_server.test.ts b/packages/core/http/core-http-server-internal/src/http_server.test.ts index 129efea82cc8c..235fab185e12d 100644 --- a/packages/core/http/core-http-server-internal/src/http_server.test.ts +++ b/packages/core/http/core-http-server-internal/src/http_server.test.ts @@ -1622,7 +1622,7 @@ describe('setup contract', () => { .get('/static/some_json.json') .expect(200); - const etag = response.get('etag'); + const etag = response.get('etag')!; expect(etag).not.toBeUndefined(); await supertest(innerServer.listener) diff --git a/packages/kbn-cli-dev-mode/src/integration_tests/base_path_proxy_server.test.ts b/packages/kbn-cli-dev-mode/src/integration_tests/base_path_proxy_server.test.ts index 5e8a7a50a7b32..0f0a69638cfa2 100644 --- a/packages/kbn-cli-dev-mode/src/integration_tests/base_path_proxy_server.test.ts +++ b/packages/kbn-cli-dev-mode/src/integration_tests/base_path_proxy_server.test.ts @@ -28,7 +28,7 @@ describe('BasePathProxyServer', () => { let logger: TestLog; let config: IHttpConfig; let basePath: string; - let proxySupertest: supertest.SuperTest; + let proxySupertest: supertest.Agent; beforeEach(async () => { logger = new TestLog(); @@ -330,7 +330,7 @@ describe('BasePathProxyServer', () => { describe('shouldRedirect', () => { let proxyServerWithoutShouldRedirect: BasePathProxyServer; - let proxyWithoutShouldRedirectSupertest: supertest.SuperTest; + let proxyWithoutShouldRedirectSupertest: supertest.Agent; beforeEach(async () => { // setup and start a proxy server which does not use "shouldRedirectFromOldBasePath" @@ -373,7 +373,7 @@ describe('BasePathProxyServer', () => { describe('constructor option for sending in a custom basePath', () => { let proxyServerWithFooBasePath: BasePathProxyServer; - let proxyWithFooBasePath: supertest.SuperTest; + let proxyWithFooBasePath: supertest.Agent; beforeEach(async () => { // setup and start a proxy server which uses a basePath of "foo" diff --git a/src/core/server/integration_tests/http/cookie_session_storage.test.ts b/src/core/server/integration_tests/http/cookie_session_storage.test.ts index 4a71502db0ccb..192a3daf8fd2d 100644 --- a/src/core/server/integration_tests/http/cookie_session_storage.test.ts +++ b/src/core/server/integration_tests/http/cookie_session_storage.test.ts @@ -134,7 +134,7 @@ describe('Cookie based SessionStorage', () => { const response = await supertest(innerServer.listener).get('/').expect(200); - const cookies = response.get('set-cookie'); + const cookies = response.get('set-cookie')!; expect(cookies).toBeDefined(); expect(cookies).toHaveLength(1); @@ -172,7 +172,7 @@ describe('Cookie based SessionStorage', () => { const response = await supertest(innerServer.listener).get('/').expect(200); - const cookies = response.get('set-cookie'); + const cookies = response.get('set-cookie')!; expect(cookies).toBeDefined(); expect(cookies).toHaveLength(1); @@ -204,7 +204,7 @@ describe('Cookie based SessionStorage', () => { const response = await supertest(innerServer.listener).get('/').expect(200, { value: null }); - const cookies = response.get('set-cookie'); + const cookies = response.get('set-cookie')!; expect(cookies).not.toBeDefined(); }); @@ -237,7 +237,7 @@ describe('Cookie based SessionStorage', () => { .get('/') .expect(200, { value: userData }); - const cookies = response.get('set-cookie'); + const cookies = response.get('set-cookie')!; expect(cookies).toBeDefined(); await delay(sessionDurationMs); @@ -283,7 +283,7 @@ describe('Cookie based SessionStorage', () => { .get('/') .expect(200, { value: userData }); - const cookies = response.get('set-cookie'); + const cookies = response.get('set-cookie')!; expect(cookies).toBeDefined(); const sessionCookie = retrieveSessionCookie(cookies[0]); @@ -418,7 +418,7 @@ describe('Cookie based SessionStorage', () => { const response = await supertest(innerServer.listener).get('/').expect(200); - const cookies = response.get('set-cookie'); + const cookies = response.get('set-cookie')!; const sessionCookie = retrieveSessionCookie(cookies[0]); const response2 = await supertest(innerServer.listener) @@ -475,7 +475,7 @@ describe('Cookie based SessionStorage', () => { const response = await supertest(innerServer.listener).get('/').expect(200); - const cookies = response.get('set-cookie'); + const cookies = response.get('set-cookie')!; expect(cookies).toBeDefined(); expect(cookies).toHaveLength(1); diff --git a/src/core/server/integration_tests/http/versioned_router.test.ts b/src/core/server/integration_tests/http/versioned_router.test.ts index 86427a2488e2d..72daedb990dff 100644 --- a/src/core/server/integration_tests/http/versioned_router.test.ts +++ b/src/core/server/integration_tests/http/versioned_router.test.ts @@ -29,7 +29,7 @@ interface AdditionalOptions { describe('Routing versioned requests', () => { let router: IRouter; - let supertest: Supertest.SuperTest; + let supertest: Supertest.Agent; async function setupServer(cliArgs: Partial = {}, options: AdditionalOptions = {}) { logger = loggingSystemMock.create(); diff --git a/src/core/server/integration_tests/metrics/server_collector.test.ts b/src/core/server/integration_tests/metrics/server_collector.test.ts index 6151cd1ebe6bf..481447f599b21 100644 --- a/src/core/server/integration_tests/metrics/server_collector.test.ts +++ b/src/core/server/integration_tests/metrics/server_collector.test.ts @@ -116,7 +116,7 @@ describe('ServerMetricsCollector', () => { // Subscribe to the aborted$ event const waitFor1stAbort = disconnectAborted$.pipe(take(1)).toPromise(); - discoReq1.abort(); + void discoReq1.abort(); // Wait for the aborted$ event await waitFor1stAbort; @@ -132,7 +132,7 @@ describe('ServerMetricsCollector', () => { // Subscribe to the aborted$ event const waitFor2ndAbort = disconnectAborted$.pipe(take(1)).toPromise(); - discoReq2.abort(); + void discoReq2.abort(); // Wait for the aborted$ event await waitFor2ndAbort; diff --git a/test/api_integration/apis/data_views/fields_route/cache.ts b/test/api_integration/apis/data_views/fields_route/cache.ts index c97be4b7411f3..dea14dec6bdcd 100644 --- a/test/api_integration/apis/data_views/fields_route/cache.ts +++ b/test/api_integration/apis/data_views/fields_route/cache.ts @@ -70,7 +70,7 @@ export default function ({ getService }: FtrProviderContext) { await supertest .get(FIELDS_PATH) - .set('If-None-Match', response.get('etag')) + .set('If-None-Match', response.get('etag')!) .query({ pattern: '*', include_unmapped: true, diff --git a/test/api_integration/apis/saved_objects_management/scroll_count.ts b/test/api_integration/apis/saved_objects_management/scroll_count.ts index 94e301a085d70..26f4f4e1a626e 100644 --- a/test/api_integration/apis/saved_objects_management/scroll_count.ts +++ b/test/api_integration/apis/saved_objects_management/scroll_count.ts @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -import { SuperTest, Test } from 'supertest'; import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; @@ -14,7 +13,7 @@ const apiUrl = '/api/kibana/management/saved_objects/scroll/counts'; const defaultTypes = ['visualization', 'index-pattern', 'search', 'dashboard']; export default function ({ getService }: FtrProviderContext) { - const supertest = getService('supertest') as SuperTest; + const supertest = getService('supertest'); const kibanaServer = getService('kibanaServer'); const esArchiver = getService('esArchiver'); diff --git a/test/api_integration/apis/telemetry/opt_in.ts b/test/api_integration/apis/telemetry/opt_in.ts index c7d8a42c6e392..a9fc5861368ca 100644 --- a/test/api_integration/apis/telemetry/opt_in.ts +++ b/test/api_integration/apis/telemetry/opt_in.ts @@ -87,7 +87,7 @@ export default function optInTest({ getService }: FtrProviderContext) { } async function postTelemetryV2OptIn( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, value: unknown, statusCode: number ): Promise { diff --git a/test/api_integration/services/supertest.ts b/test/api_integration/services/supertest.ts index baf42703c64a0..d8ce0d918c45a 100644 --- a/test/api_integration/services/supertest.ts +++ b/test/api_integration/services/supertest.ts @@ -13,13 +13,15 @@ import { format as formatUrl } from 'url'; import supertest from 'supertest'; import { FtrProviderContext } from '../../functional/ftr_provider_context'; -export function KibanaSupertestProvider({ getService }: FtrProviderContext) { +export function KibanaSupertestProvider({ getService }: FtrProviderContext): supertest.Agent { const config = getService('config'); const kibanaServerUrl = formatUrl(config.get('servers.kibana')); return supertest(kibanaServerUrl); } -export function ElasticsearchSupertestProvider({ getService }: FtrProviderContext) { +export function ElasticsearchSupertestProvider({ + getService, +}: FtrProviderContext): supertest.Agent { const config = getService('config'); const esServerConfig = config.get('servers.elasticsearch'); diff --git a/test/common/services/bsearch.ts b/test/common/services/bsearch.ts index fd79a9b9a75e8..fd9ef7f703a0b 100644 --- a/test/common/services/bsearch.ts +++ b/test/common/services/bsearch.ts @@ -40,7 +40,7 @@ const getSpaceUrlPrefix = (spaceId?: string): string => { * Options for the send method */ interface SendOptions { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; options: object; strategy: string; space?: string; diff --git a/x-pack/plugins/observability_solution/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.test.ts b/x-pack/plugins/observability_solution/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.test.ts index 43b31c588f422..9cab31e30af64 100644 --- a/x-pack/plugins/observability_solution/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.test.ts +++ b/x-pack/plugins/observability_solution/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.test.ts @@ -74,7 +74,7 @@ describe('APMEventClient', () => { resolve(undefined); }, 100); }); - incomingRequest.abort(); + void incomingRequest.abort(); }, 100); }); diff --git a/x-pack/test/alerting_api_integration/common/lib/wait_for_execution_count.ts b/x-pack/test/alerting_api_integration/common/lib/wait_for_execution_count.ts index 6ad0dab431d81..3cd95484e1d5c 100644 --- a/x-pack/test/alerting_api_integration/common/lib/wait_for_execution_count.ts +++ b/x-pack/test/alerting_api_integration/common/lib/wait_for_execution_count.ts @@ -13,7 +13,7 @@ async function delay(millis: number): Promise { } export function createWaitForExecutionCount( - st: supertest.SuperTest, + st: supertest.Agent, spaceId?: string, delayMs: number = 3000 ) { diff --git a/x-pack/test/alerting_api_integration/observability/helpers/alerting_api_helper.ts b/x-pack/test/alerting_api_integration/observability/helpers/alerting_api_helper.ts index bd6c7761a5fcd..1a66aa2fcd9ed 100644 --- a/x-pack/test/alerting_api_integration/observability/helpers/alerting_api_helper.ts +++ b/x-pack/test/alerting_api_integration/observability/helpers/alerting_api_helper.ts @@ -6,7 +6,7 @@ */ import type { Client } from '@elastic/elasticsearch'; -import type { SuperTest, Test } from 'supertest'; +import type { Agent as SuperTestAgent } from 'supertest'; import { ToolingLog } from '@kbn/tooling-log'; import { ThresholdParams } from '@kbn/observability-plugin/common/custom_threshold_rule/types'; import { refreshSavedObjectIndices } from './refresh_index'; @@ -17,7 +17,7 @@ export async function createIndexConnector({ indexName, logger, }: { - supertest: SuperTest; + supertest: SuperTestAgent; name: string; indexName: string; logger: ToolingLog; @@ -51,7 +51,7 @@ export async function createRule({ logger, esClient, }: { - supertest: SuperTest; + supertest: SuperTestAgent; ruleTypeId: string; name: string; params: Params; diff --git a/x-pack/test/alerting_api_integration/observability/helpers/alerting_wait_for_helpers.ts b/x-pack/test/alerting_api_integration/observability/helpers/alerting_wait_for_helpers.ts index 63960b222cede..032435a03e007 100644 --- a/x-pack/test/alerting_api_integration/observability/helpers/alerting_wait_for_helpers.ts +++ b/x-pack/test/alerting_api_integration/observability/helpers/alerting_wait_for_helpers.ts @@ -29,7 +29,7 @@ export async function waitForRuleStatus({ }: { id: string; expectedStatus: string; - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; retryService: RetryService; logger: ToolingLog; }): Promise> { diff --git a/x-pack/test/alerting_api_integration/observability/helpers/data_view.ts b/x-pack/test/alerting_api_integration/observability/helpers/data_view.ts index 1f84b2556ab70..3fdceed845856 100644 --- a/x-pack/test/alerting_api_integration/observability/helpers/data_view.ts +++ b/x-pack/test/alerting_api_integration/observability/helpers/data_view.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SuperTest, Test } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { ToolingLog } from '@kbn/tooling-log'; export const createDataView = async ({ @@ -15,7 +15,7 @@ export const createDataView = async ({ title, logger, }: { - supertest: SuperTest; + supertest: SuperTestAgent; id: string; name: string; title: string; @@ -50,7 +50,7 @@ export const deleteDataView = async ({ id, logger, }: { - supertest: SuperTest; + supertest: SuperTestAgent; id: string; logger: ToolingLog; }) => { diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find.ts b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find.ts index 9816059995142..7abc1b134f01d 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { SuperTest, Test } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { chunk, omit } from 'lodash'; import { v4 as uuidv4 } from 'uuid'; import { SuperuserAtSpace1, UserAtSpaceScenarios } from '../../../scenarios'; @@ -16,7 +16,7 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context'; const findTestUtils = ( describeType: 'internal' | 'public', objectRemover: ObjectRemover, - supertest: SuperTest, + supertest: SuperTestAgent, supertestWithoutAuth: any ) => { describe.skip(describeType, () => { diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find_with_post.ts b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find_with_post.ts index 7b60595c4d66e..82956536c6d1a 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find_with_post.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find_with_post.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { SuperTest, Test } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { chunk, omit } from 'lodash'; import { v4 as uuidv4 } from 'uuid'; import { UserAtSpaceScenarios } from '../../../scenarios'; @@ -16,7 +16,7 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context'; const findTestUtils = ( describeType: 'internal' | 'public', objectRemover: ObjectRemover, - supertest: SuperTest, + supertest: SuperTestAgent, supertestWithoutAuth: any ) => { // FLAKY: https://github.com/elastic/kibana/issues/182314 diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/get.ts b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/get.ts index 6d245ed28cc00..fa362249229e3 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/get.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/get.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { SuperTest, Test } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { SuperuserAtSpace1, UserAtSpaceScenarios } from '../../../scenarios'; import { getUrlPrefix, @@ -19,7 +19,7 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context'; const getTestUtils = ( describeType: 'internal' | 'public', objectRemover: ObjectRemover, - supertest: SuperTest, + supertest: SuperTestAgent, supertestWithoutAuth: any ) => { describe(describeType, () => { diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/connector_types/crowdstrike.ts b/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/connector_types/crowdstrike.ts index 7b4d064eb6b6e..c9d1ca8814592 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/connector_types/crowdstrike.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/connector_types/crowdstrike.ts @@ -131,7 +131,7 @@ export default function createCrowdstrikeTests({ getService }: FtrProviderContex password = 'changeme', errorLogger = logErrorDetails, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; subAction: string; subActionParams: Record; expectedHttpCode?: number; diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/connector_types/sentinelone.ts b/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/connector_types/sentinelone.ts index 4b184ccb7a595..bf6f88be08fdf 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/connector_types/sentinelone.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/connector_types/sentinelone.ts @@ -140,7 +140,7 @@ export default function createSentinelOneTests({ getService }: FtrProviderContex password = 'changeme', errorLogger = logErrorDetails, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; subAction: string; subActionParams: Record; expectedHttpCode?: number; diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/sub_action_framework/index.ts b/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/sub_action_framework/index.ts index 0a363e001535b..85e3b8405257f 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/sub_action_framework/index.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/sub_action_framework/index.ts @@ -22,7 +22,7 @@ const createSubActionConnector = async ({ connectorTypeId = 'test.sub-action-connector', expectedHttpCode = 200, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; config?: Record; secrets?: Record; connectorTypeId?: string; @@ -56,7 +56,7 @@ const executeSubAction = async ({ subActionParams, expectedHttpCode = 200, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; connectorId: string; subAction: string; subActionParams: Record; diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/connector_types/stack/webhook.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/connector_types/stack/webhook.ts index f3b3a4e7076ef..ad6a8d12baed3 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/connector_types/stack/webhook.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/connector_types/stack/webhook.ts @@ -8,7 +8,7 @@ import http from 'http'; import https from 'https'; import getPort from 'get-port'; -import { SuperTest, Test } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import expect from '@kbn/expect'; import { URL, format as formatUrl } from 'url'; import { @@ -177,7 +177,7 @@ export default function webhookTest({ getService }: FtrProviderContext) { } export async function createWebhookAction( - supertest: SuperTest, + supertest: SuperTestAgent, webhookSimulatorURL: string, config: Record> = {} ): Promise { diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group1/find.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group1/find.ts index a83ec1e70a0a1..d38bb2f40a275 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group1/find.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group1/find.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { SuperTest, Test } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { fromKueryExpression } from '@kbn/es-query'; import { Spaces } from '../../../scenarios'; import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../../common/lib'; @@ -14,7 +14,7 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context'; async function createAlert( objectRemover: ObjectRemover, - supertest: SuperTest, + supertest: SuperTestAgent, overwrites = {} ) { const { body: createdAlert } = await supertest @@ -28,7 +28,7 @@ async function createAlert( const findTestUtils = ( describeType: 'internal' | 'public', - supertest: SuperTest, + supertest: SuperTestAgent, objectRemover: ObjectRemover ) => { describe(describeType, () => { diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group1/get.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group1/get.ts index 51f246e2c5609..c22e8233f2d73 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group1/get.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group1/get.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { SuperTest, Test } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { Spaces } from '../../../scenarios'; import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../../common/lib'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; @@ -14,7 +14,7 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context'; const getTestUtils = ( describeType: 'internal' | 'public', objectRemover: ObjectRemover, - supertest: SuperTest + supertest: SuperTestAgent ) => { describe(describeType, () => { afterEach(() => objectRemover.removeAll()); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group3/test_helpers.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group3/test_helpers.ts index a898cc14b9104..b2196d9ea3724 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group3/test_helpers.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group3/test_helpers.ts @@ -8,7 +8,7 @@ import moment from 'moment'; import type { RetryService } from '@kbn/ftr-common-functional-services'; import type { IValidatedEvent } from '@kbn/event-log-plugin/server'; -import type { SuperTest, Test } from 'supertest'; +import type { Agent as SuperTestAgent } from 'supertest'; import expect from '@kbn/expect'; import type { FtrProviderContext } from '../../../../common/ftr_provider_context'; import { getUrlPrefix, getTestRuleData, ObjectRemover, getEventLog } from '../../../../common/lib'; @@ -23,7 +23,7 @@ export const createRule = async ({ }: { actionId: string; pattern: { instance: boolean[] }; - supertest: SuperTest; + supertest: SuperTestAgent; objectRemover: ObjectRemover; overwrites?: any; }) => { @@ -65,7 +65,7 @@ export const createAction = async ({ supertest, objectRemover, }: { - supertest: SuperTest; + supertest: SuperTestAgent; objectRemover: ObjectRemover; }) => { const { body: createdAction } = await supertest @@ -89,7 +89,7 @@ export const createMaintenanceWindow = async ({ objectRemover, }: { overwrites?: any; - supertest: SuperTest; + supertest: SuperTestAgent; objectRemover: ObjectRemover; }) => { const { body: window } = await supertest @@ -112,11 +112,7 @@ export const createMaintenanceWindow = async ({ return window; }; -export const getActiveMaintenanceWindows = async ({ - supertest, -}: { - supertest: SuperTest; -}) => { +export const getActiveMaintenanceWindows = async ({ supertest }: { supertest: SuperTestAgent }) => { const { body: activeMaintenanceWindows } = await supertest .get(`${getUrlPrefix(Spaces.space1.id)}/internal/alerting/rules/maintenance_window/_active`) .set('kbn-xsrf', 'foo') @@ -130,7 +126,7 @@ export const finishMaintenanceWindow = async ({ supertest, }: { id: string; - supertest: SuperTest; + supertest: SuperTestAgent; }) => { return supertest .post( @@ -188,7 +184,7 @@ export const expectNoActionsFired = async ({ retry, }: { id: string; - supertest: SuperTest; + supertest: SuperTestAgent; retry: RetryService; }) => { const events = await retry.try(async () => { @@ -215,7 +211,7 @@ export const runSoon = async ({ retry, }: { id: string; - supertest: SuperTest; + supertest: SuperTestAgent; retry: RetryService; }) => { return retry.try(async () => { diff --git a/x-pack/test/api_integration/apis/asset_manager/tests/helpers.ts b/x-pack/test/api_integration/apis/asset_manager/tests/helpers.ts index 3d1086ca8b8e4..94ab2f5b99ffe 100644 --- a/x-pack/test/api_integration/apis/asset_manager/tests/helpers.ts +++ b/x-pack/test/api_integration/apis/asset_manager/tests/helpers.ts @@ -9,11 +9,11 @@ import type { AssetWithoutTimestamp } from '@kbn/assetManager-plugin/common/type import type { WriteSamplesPostBody } from '@kbn/assetManager-plugin/server'; import { apm, infra, timerange } from '@kbn/apm-synthtrace-client'; import expect from '@kbn/expect'; -import { SuperTest, Test } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; const SAMPLE_ASSETS_ENDPOINT = '/api/asset-manager/assets/sample'; -export type KibanaSupertest = SuperTest; +export type KibanaSupertest = SuperTestAgent; // NOTE: In almost every case in tests, you want { refresh: true } // in the options of this function, so it is defaulted to that value. diff --git a/x-pack/test/api_integration/apis/cloud_security_posture/helper.ts b/x-pack/test/api_integration/apis/cloud_security_posture/helper.ts index 03a61807f1b31..5565e7a6e096b 100644 --- a/x-pack/test/api_integration/apis/cloud_security_posture/helper.ts +++ b/x-pack/test/api_integration/apis/cloud_security_posture/helper.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { SuperTest, Test } from 'supertest'; +import type { Agent as SuperTestAgent } from 'supertest'; import { Client } from '@elastic/elasticsearch'; import expect from '@kbn/expect'; import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; @@ -43,7 +43,7 @@ export const addIndex = async (es: Client, findingsMock: T[], indexName: stri }; export async function createPackagePolicy( - supertest: SuperTest, + supertest: SuperTestAgent, agentPolicyId: string, policyTemplate: string, input: string, diff --git a/x-pack/test/api_integration/apis/management/index_management/lib/templates.api.ts b/x-pack/test/api_integration/apis/management/index_management/lib/templates.api.ts index e929cbff2f188..bae578e6c0490 100644 --- a/x-pack/test/api_integration/apis/management/index_management/lib/templates.api.ts +++ b/x-pack/test/api_integration/apis/management/index_management/lib/templates.api.ts @@ -36,7 +36,9 @@ export function templatesApi(getService: FtrProviderContext['getService']) { .send(payload); // Delete all templates created during tests - const cleanUpTemplates = async (additionalRequestHeaders: object = {}) => { + const cleanUpTemplates = async ( + additionalRequestHeaders: Record = {} + ) => { try { await deleteTemplates(templatesCreated).set(additionalRequestHeaders); templatesCreated = []; diff --git a/x-pack/test/api_integration/apis/metrics_ui/helpers.ts b/x-pack/test/api_integration/apis/metrics_ui/helpers.ts index b5375b8d70cab..427909e10ac94 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/helpers.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/helpers.ts @@ -6,9 +6,6 @@ */ import { apm, timerange } from '@kbn/apm-synthtrace-client'; -import { SuperTest, Test } from 'supertest'; - -export type KibanaSupertest = SuperTest; // generates traces, metrics for services export function generateServicesData({ diff --git a/x-pack/test/api_integration/apis/telemetry/telemetry.ts b/x-pack/test/api_integration/apis/telemetry/telemetry.ts index 3652b32d9a372..203189906f812 100644 --- a/x-pack/test/api_integration/apis/telemetry/telemetry.ts +++ b/x-pack/test/api_integration/apis/telemetry/telemetry.ts @@ -50,7 +50,7 @@ function getCacheDetails(body: UnencryptedTelemetryPayload): CacheDetails[] { * @param timestamp The new timestamp to be set */ function updateMonitoringDates( - esSupertest: SuperTest.SuperTest, + esSupertest: SuperTest.Agent, fromTimestamp: string, toTimestamp: string, timestamp: string diff --git a/x-pack/test/apm_api_integration/common/apm_api_supertest.ts b/x-pack/test/apm_api_integration/common/apm_api_supertest.ts index 9e4f25a7c7c7b..330de33dc7ab6 100644 --- a/x-pack/test/apm_api_integration/common/apm_api_supertest.ts +++ b/x-pack/test/apm_api_integration/common/apm_api_supertest.ts @@ -15,7 +15,7 @@ import type { import type { APIEndpoint } from '@kbn/apm-plugin/server'; import { formatRequest } from '@kbn/server-route-repository'; -export function createApmApiClient(st: supertest.SuperTest) { +export function createApmApiClient(st: supertest.Agent) { return async ( options: { type?: 'form-data'; diff --git a/x-pack/test/apm_api_integration/common/bettertest.ts b/x-pack/test/apm_api_integration/common/bettertest.ts index e1132be3f9a77..8665d200fd15f 100644 --- a/x-pack/test/apm_api_integration/common/bettertest.ts +++ b/x-pack/test/apm_api_integration/common/bettertest.ts @@ -30,7 +30,7 @@ export interface BetterTestResponse { * This is useful for tests that expect a 200 response * It also makes it easier to debug tests that fail because of a 500 response. */ -export function getBettertest(st: supertest.SuperTest) { +export function getBettertest(st: supertest.Agent) { return async ({ pathname, method = 'get', diff --git a/x-pack/test/apm_api_integration/tests/alerts/helpers/alerting_api_helper.ts b/x-pack/test/apm_api_integration/tests/alerts/helpers/alerting_api_helper.ts index e4cc8d302ba4a..5da6ee4f860d0 100644 --- a/x-pack/test/apm_api_integration/tests/alerts/helpers/alerting_api_helper.ts +++ b/x-pack/test/apm_api_integration/tests/alerts/helpers/alerting_api_helper.ts @@ -8,7 +8,7 @@ import { Client, errors } from '@elastic/elasticsearch'; import { ParsedTechnicalFields } from '@kbn/rule-registry-plugin/common'; import pRetry from 'p-retry'; -import type { SuperTest, Test } from 'supertest'; +import type { Agent as SuperTestAgent } from 'supertest'; import { ApmRuleType } from '@kbn/rule-data-utils'; import { ApmRuleParamsType } from '@kbn/apm-plugin/common/rules/schema'; import { ApmDocumentType } from '@kbn/apm-plugin/common/document_type'; @@ -26,7 +26,7 @@ export async function createApmRule({ params, actions = [], }: { - supertest: SuperTest; + supertest: SuperTestAgent; ruleTypeId: T; name: string; params: ApmRuleParamsType[T]; @@ -111,7 +111,7 @@ export async function runRuleSoon({ supertest, }: { ruleId: string; - supertest: SuperTest; + supertest: SuperTestAgent; }): Promise> { return pRetry( async () => { @@ -143,13 +143,13 @@ export async function deleteRuleById({ supertest, ruleId, }: { - supertest: SuperTest; + supertest: SuperTestAgent; ruleId: string; }) { await supertest.delete(`/api/alerting/rule/${ruleId}`).set('kbn-xsrf', 'foo'); } -export async function deleteApmRules(supertest: SuperTest) { +export async function deleteApmRules(supertest: SuperTestAgent) { const res = await supertest.get( `/api/alerting/rules/_find?filter=alert.attributes.consumer:apm&per_page=10000` ); @@ -180,7 +180,7 @@ export async function createIndexConnector({ supertest, name, }: { - supertest: SuperTest; + supertest: SuperTestAgent; name: string; }) { const { body } = await supertest @@ -228,7 +228,7 @@ export async function deleteAllActionConnectors({ supertest, es, }: { - supertest: SuperTest; + supertest: SuperTestAgent; es: Client; }): Promise { const res = await supertest.get(`/api/actions/connectors`); @@ -245,7 +245,7 @@ async function deleteActionConnector({ supertest, actionId, }: { - supertest: SuperTest; + supertest: SuperTestAgent; actionId: string; }) { return supertest.delete(`/api/actions/connector/${actionId}`).set('kbn-xsrf', 'foo'); diff --git a/x-pack/test/apm_api_integration/tests/alerts/helpers/cleanup_rule_and_alert_state.ts b/x-pack/test/apm_api_integration/tests/alerts/helpers/cleanup_rule_and_alert_state.ts index ae97266ee084c..2fae6c9643ff7 100644 --- a/x-pack/test/apm_api_integration/tests/alerts/helpers/cleanup_rule_and_alert_state.ts +++ b/x-pack/test/apm_api_integration/tests/alerts/helpers/cleanup_rule_and_alert_state.ts @@ -7,7 +7,7 @@ import { Client } from '@elastic/elasticsearch'; import { ToolingLog } from '@kbn/tooling-log'; -import type { SuperTest, Test } from 'supertest'; +import type { Agent as SuperTestAgent } from 'supertest'; import { clearKibanaApmEventLog, deleteApmRules, @@ -22,7 +22,7 @@ export async function cleanupRuleAndAlertState({ logger, }: { es: Client; - supertest: SuperTest; + supertest: SuperTestAgent; logger: ToolingLog; }) { try { diff --git a/x-pack/test/apm_api_integration/tests/alerts/helpers/wait_for_active_rule.ts b/x-pack/test/apm_api_integration/tests/alerts/helpers/wait_for_active_rule.ts index 29dc20840cec5..a2ee7253e9b8c 100644 --- a/x-pack/test/apm_api_integration/tests/alerts/helpers/wait_for_active_rule.ts +++ b/x-pack/test/apm_api_integration/tests/alerts/helpers/wait_for_active_rule.ts @@ -17,7 +17,7 @@ export async function waitForActiveRule({ logger, }: { ruleId: string; - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; logger?: ToolingLog; }): Promise> { return pRetry( diff --git a/x-pack/test/cases_api_integration/common/lib/alerts.ts b/x-pack/test/cases_api_integration/common/lib/alerts.ts index a74524c448493..8df074b0d3474 100644 --- a/x-pack/test/cases_api_integration/common/lib/alerts.ts +++ b/x-pack/test/cases_api_integration/common/lib/alerts.ts @@ -30,7 +30,7 @@ import { createComment, deleteAllComments } from './api'; import { postCaseReq } from './mock'; export const createSecuritySolutionAlerts = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, numberOfSignals: number = 1 ): Promise> => { @@ -47,7 +47,7 @@ export const createSecuritySolutionAlerts = async ( }; export const getSecuritySolutionAlerts = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, alertIds: string[] ): Promise> => { const { body: updatedAlert } = await supertest @@ -70,7 +70,7 @@ export const getAlertById = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; id: string; index: string; expectedHttpCode?: number; @@ -97,7 +97,7 @@ export const createCaseAttachAlertAndDeleteAlert = async ({ alerts, getAlerts, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; totalCases: number; indexOfCaseToDelete: number; owner: string; @@ -145,7 +145,7 @@ export const createCaseAttachAlertAndDeleteCase = async ({ alerts, getAlerts, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; totalCases: number; indicesOfCaseToDelete: number[]; owner: string; @@ -194,7 +194,7 @@ export const createCaseAndAttachAlert = async ({ alerts, getAlerts, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; totalCases: number; owner: string; alerts: Alerts; diff --git a/x-pack/test/cases_api_integration/common/lib/api/attachments.ts b/x-pack/test/cases_api_integration/common/lib/api/attachments.ts index 1dbee9fbd4616..2f598f5a23b11 100644 --- a/x-pack/test/cases_api_integration/common/lib/api/attachments.ts +++ b/x-pack/test/cases_api_integration/common/lib/api/attachments.ts @@ -33,7 +33,7 @@ export const bulkGetAttachments = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; attachmentIds: string[]; caseId: string; auth?: { user: User; space: string | null }; @@ -57,12 +57,12 @@ export const createComment = async ({ expectedHttpCode = 200, headers = {}, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; params: AttachmentRequest; auth?: { user: User; space: string | null } | null; expectedHttpCode?: number; - headers?: Record; + headers?: Record; }): Promise => { const apiCall = supertest.post( `${getSpaceUrlPrefix(auth?.space)}${CASES_URL}/${caseId}/comments` @@ -86,7 +86,7 @@ export const bulkCreateAttachments = async ({ auth = { user: superUser, space: null }, expectedHttpCode = 200, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; params: BulkCreateAttachmentsRequest; auth?: { user: User; space: string | null }; @@ -110,7 +110,7 @@ export const createCaseAndBulkCreateAttachments = async ({ auth = { user: superUser, space: null }, expectedHttpCode = 200, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; numberOfAttachments?: number; auth?: { user: User; space: string | null }; expectedHttpCode?: number; @@ -156,7 +156,7 @@ export const deleteComment = async ({ expectedHttpCode = 204, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; commentId: string; expectedHttpCode?: number; @@ -178,7 +178,7 @@ export const deleteAllComments = async ({ expectedHttpCode = 204, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -199,7 +199,7 @@ export const getAllComments = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; auth?: { user: User; space: string | null }; expectedHttpCode?: number; @@ -219,7 +219,7 @@ export const getComment = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; commentId: string; expectedHttpCode?: number; @@ -241,12 +241,12 @@ export const updateComment = async ({ auth = { user: superUser, space: null }, headers = {}, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; req: AttachmentPatchRequest; expectedHttpCode?: number; auth?: { user: User; space: string | null } | null; - headers?: Record; + headers?: Record; }): Promise => { const apiCall = supertest.patch( `${getSpaceUrlPrefix(auth?.space)}${CASES_URL}/${caseId}/comments` @@ -269,7 +269,7 @@ export const bulkDeleteFileAttachments = async ({ expectedHttpCode = 204, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; fileIds: string[]; expectedHttpCode?: number; @@ -290,7 +290,7 @@ export const findAttachments = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; query?: Record; expectedHttpCode?: number; diff --git a/x-pack/test/cases_api_integration/common/lib/api/case.ts b/x-pack/test/cases_api_integration/common/lib/api/case.ts index a6605d8e83aab..dd1b668b429cf 100644 --- a/x-pack/test/cases_api_integration/common/lib/api/case.ts +++ b/x-pack/test/cases_api_integration/common/lib/api/case.ts @@ -15,11 +15,11 @@ import { superUser } from '../authentication/users'; import { getSpaceUrlPrefix, setupAuth } from './helpers'; export const createCase = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, params: CasePostRequest, expectedHttpCode: number = 200, auth: { user: User; space: string | null } | null = { user: superUser, space: null }, - headers: Record = {} + headers: Record = {} ): Promise => { const apiCall = supertest.post(`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}`); @@ -44,7 +44,7 @@ export const deleteCases = async ({ expectedHttpCode = 204, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseIDs: string[]; expectedHttpCode?: number; auth?: { user: User; space: string | null }; diff --git a/x-pack/test/cases_api_integration/common/lib/api/configuration.ts b/x-pack/test/cases_api_integration/common/lib/api/configuration.ts index cfaa18b430c11..c74c6be78da82 100644 --- a/x-pack/test/cases_api_integration/common/lib/api/configuration.ts +++ b/x-pack/test/cases_api_integration/common/lib/api/configuration.ts @@ -60,11 +60,11 @@ export const getConfigurationOutput = (update = false, overwrite = {}): Partial< }; export const createConfiguration = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, req: ConfigurationRequest = getConfigurationRequest(), expectedHttpCode: number = 200, auth: { user: User; space: string | null } | null = { user: superUser, space: null }, - headers: Record = {} + headers: Record = {} ): Promise => { const apiCall = supertest.post(`${getSpaceUrlPrefix(auth?.space)}${CASE_CONFIGURE_URL}`); @@ -86,7 +86,7 @@ export const getConfiguration = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; query?: Record; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -102,12 +102,12 @@ export const getConfiguration = async ({ }; export const updateConfiguration = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, id: string, req: ConfigurationPatchRequest, expectedHttpCode: number = 200, auth: { user: User; space: string | null } | null = { user: superUser, space: null }, - headers: Record = {} + headers: Record = {} ): Promise => { const apiCall = supertest.patch(`${getSpaceUrlPrefix(auth?.space)}${CASE_CONFIGURE_URL}/${id}`); diff --git a/x-pack/test/cases_api_integration/common/lib/api/connectors.ts b/x-pack/test/cases_api_integration/common/lib/api/connectors.ts index 0eb6854cb735d..3bd959b031ae5 100644 --- a/x-pack/test/cases_api_integration/common/lib/api/connectors.ts +++ b/x-pack/test/cases_api_integration/common/lib/api/connectors.ts @@ -194,7 +194,7 @@ export const getCaseConnectors = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; expectedHttpCode?: number; auth?: { user: User; space: string | null }; }): Promise => { @@ -215,13 +215,13 @@ export const createCaseWithConnector = async ({ createCaseReq = getPostCaseRequest(), headers = {}, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; serviceNowSimulatorURL: string; actionsRemover: ActionsRemover; configureReq?: Record; auth?: { user: User; space: string | null } | null; createCaseReq?: CasePostRequest; - headers?: Record; + headers?: Record; }): Promise<{ postedCase: Case; connector: CreateConnectorResponse; @@ -288,7 +288,7 @@ export const createConnector = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; req: Record; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -309,7 +309,7 @@ export const getConnectors = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -329,7 +329,7 @@ export const executeConnector = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; connectorId: string; req: Record; expectedHttpCode?: number; @@ -352,7 +352,7 @@ export const executeSystemConnector = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; connectorId: string; req: Record; expectedHttpCode?: number; diff --git a/x-pack/test/cases_api_integration/common/lib/api/files.ts b/x-pack/test/cases_api_integration/common/lib/api/files.ts index 71951564c6a28..8e2710603020f 100644 --- a/x-pack/test/cases_api_integration/common/lib/api/files.ts +++ b/x-pack/test/cases_api_integration/common/lib/api/files.ts @@ -23,7 +23,7 @@ export const downloadFile = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; fileId: string; kind: string; mimeType: string; @@ -49,7 +49,7 @@ export const deleteFileForFileKind = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; fileKind: string; id: string; expectedHttpCode?: number; @@ -72,7 +72,7 @@ export const deleteFiles = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; files: string[]; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -91,7 +91,7 @@ export const deleteAllFilesForKind = async ({ auth = { user: superUser, space: null }, expectedHttpCode = 200, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; kind: string; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -124,7 +124,7 @@ export const deleteAllFiles = async ({ expectedHttpCode = 200, ignoreErrors = true, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; expectedHttpCode?: number; auth?: { user: User; space: string | null }; ignoreErrors?: boolean; @@ -165,7 +165,7 @@ export const getFileById = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; id: string; kind: string; expectedHttpCode?: number; @@ -185,7 +185,7 @@ export const listFiles = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; params: Parameters[0]; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -213,7 +213,7 @@ export const createFile = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; params: CreateFileSchema; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -238,7 +238,7 @@ export const uploadFile = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; data: string | object; kind: string; fileId: string; @@ -264,7 +264,7 @@ export const createAndUploadFile = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; data: string | object; createFileParams: CreateFileSchema; expectedHttpCode?: number; diff --git a/x-pack/test/cases_api_integration/common/lib/api/index.ts b/x-pack/test/cases_api_integration/common/lib/api/index.ts index 0b7f9c542a6d0..6582601f0f1a9 100644 --- a/x-pack/test/cases_api_integration/common/lib/api/index.ts +++ b/x-pack/test/cases_api_integration/common/lib/api/index.ts @@ -129,7 +129,7 @@ export const setStatus = async ({ supertest, cases, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; cases: SetStatusCasesParams[]; }): Promise => { const { body }: { body: Cases } = await supertest @@ -143,7 +143,7 @@ export const setStatus = async ({ /** * Add case as a connector */ -export const createCaseAction = async (supertest: SuperTest.SuperTest) => { +export const createCaseAction = async (supertest: SuperTest.Agent) => { const { body: createdAction } = await supertest .post('/api/actions/connector') .set('kbn-xsrf', 'foo') @@ -159,10 +159,7 @@ export const createCaseAction = async (supertest: SuperTest.SuperTest, - id: string -) => { +export const deleteCaseAction = async (supertest: SuperTest.Agent, id: string) => { await supertest.delete(`/api/actions/connector/${id}`).set('kbn-xsrf', 'foo'); }; @@ -418,11 +415,11 @@ export const updateCase = async ({ auth = { user: superUser, space: null }, headers = {}, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; params: CasesPatchRequest; expectedHttpCode?: number; auth?: { user: User; space: string | null } | null; - headers?: Record; + headers?: Record; }): Promise => { const apiCall = supertest.patch(`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}`); @@ -444,7 +441,7 @@ export const getAllCasesStatuses = async ({ auth = { user: superUser, space: null }, query = {}, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; expectedHttpCode?: number; auth?: { user: User; space: string | null }; query?: Record; @@ -465,7 +462,7 @@ export const getCase = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; includeComments?: boolean; expectedHttpCode?: number; @@ -490,7 +487,7 @@ export const getCaseMetrics = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; features: CaseMetricsFeature[] | CaseMetricsFeature; expectedHttpCode?: number; @@ -512,7 +509,7 @@ export const resolveCase = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; includeComments?: boolean; expectedHttpCode?: number; @@ -537,7 +534,7 @@ export const findCases = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; query?: Record; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -560,7 +557,7 @@ export const getCasesByAlert = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; alertID: string; query?: Record; expectedHttpCode?: number; @@ -581,7 +578,7 @@ export const getTags = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; query?: Record; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -602,7 +599,7 @@ export const getReporters = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; query?: Record; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -623,7 +620,7 @@ export const getCategories = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; query?: Record; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -646,12 +643,12 @@ export const pushCase = async ({ auth = { user: superUser, space: null }, headers = {}, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; connectorId: string; expectedHttpCode?: number; auth?: { user: User; space: string | null } | null; - headers?: Record; + headers?: Record; }): Promise => { const apiCall = supertest.post( `${getSpaceUrlPrefix(auth?.space)}${CASES_URL}/${caseId}/connector/${connectorId}/_push` @@ -674,7 +671,7 @@ export const getAlertsAttachedToCase = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -727,7 +724,7 @@ export const getCasesMetrics = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; features: string[] | string; query?: Record; expectedHttpCode?: number; @@ -774,7 +771,7 @@ export const bulkGetCases = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; ids: string[]; fields?: string[]; expectedHttpCode?: number; @@ -796,7 +793,7 @@ export const searchCases = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; body?: Record; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -820,13 +817,13 @@ export const replaceCustomField = async ({ auth = { user: superUser, space: null }, headers = {}, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; customFieldId: string; params: CustomFieldPutRequest; expectedHttpCode?: number; auth?: { user: User; space: string | null } | null; - headers?: Record; + headers?: Record; }): Promise => { const apiCall = supertest.put( `${getSpaceUrlPrefix( diff --git a/x-pack/test/cases_api_integration/common/lib/api/user_actions.ts b/x-pack/test/cases_api_integration/common/lib/api/user_actions.ts index fc4f8382d3508..4a0f38b5dcc90 100644 --- a/x-pack/test/cases_api_integration/common/lib/api/user_actions.ts +++ b/x-pack/test/cases_api_integration/common/lib/api/user_actions.ts @@ -42,7 +42,7 @@ export const getCaseUserActions = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseID: string; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -61,7 +61,7 @@ export const findCaseUserActions = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseID: string; options?: UserActionFindRequest; expectedHttpCode?: number; @@ -82,7 +82,7 @@ export const getCaseUserActionStats = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseID: string; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -101,7 +101,7 @@ export const getCaseUsers = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; caseId: string; expectedHttpCode?: number; auth?: { user: User; space: string | null }; diff --git a/x-pack/test/cases_api_integration/common/lib/api/user_profiles.ts b/x-pack/test/cases_api_integration/common/lib/api/user_profiles.ts index bc78feab4070c..f9a66fe0f7962 100644 --- a/x-pack/test/cases_api_integration/common/lib/api/user_profiles.ts +++ b/x-pack/test/cases_api_integration/common/lib/api/user_profiles.ts @@ -38,7 +38,7 @@ export const bulkGetUserProfiles = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; req: BulkGetUserProfilesParams; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -62,7 +62,7 @@ export const suggestUserProfiles = async ({ expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; req: SuggestUserProfilesRequest; expectedHttpCode?: number; auth?: { user: User; space: string | null }; @@ -89,10 +89,10 @@ export const updateUserProfileAvatar = async ({ expectedHttpCode = 200, headers = {}, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; req: UserProfileAvatarData; expectedHttpCode?: number; - headers?: Record; + headers?: Record; }): Promise => { await supertest .post('/internal/security/user_profile/_data') @@ -106,7 +106,7 @@ export const loginUsers = async ({ supertest, users = [superUser], }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; users?: User[]; }) => { const cookies: Cookie[] = []; diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/bulk_create_cases.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/bulk_create_cases.ts index 8177649f22ab3..c07d858e4b389 100644 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/bulk_create_cases.ts +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/bulk_create_cases.ts @@ -52,7 +52,7 @@ export default ({ getService }: FtrProviderContext): void => { expectedHttpCode = 200, auth = { user: superUser, space: null }, }: { - superTestService?: SuperTest.SuperTest; + superTestService?: SuperTest.Agent; data: object; expectedHttpCode?: number; auth?: { user: User; space: string | null }; diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/delete_cases.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/delete_cases.ts index 4c3239fe0d126..ef0e09f1a477d 100644 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/delete_cases.ts +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/delete_cases.ts @@ -700,7 +700,7 @@ const createCaseWithFiles = async ({ owner, auth = { user: superUser, space: null }, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; fileKind: string; owner: string; auth?: { user: User; space: string | null }; diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/import_export.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/import_export.ts index 060b6463c0451..3aa11c83947ad 100644 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/import_export.ts +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/import_export.ts @@ -161,7 +161,7 @@ export default ({ getService }: FtrProviderContext): void => { }); }; -const expectImportToHaveOneCase = async (supertestService: supertest.SuperTest) => { +const expectImportToHaveOneCase = async (supertestService: supertest.Agent) => { const findResponse = await findCases({ supertest: supertestService, query: {} }); expect(findResponse.total).to.eql(1); expect(findResponse.cases[0].title).to.eql('A case with a connector'); diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/trial/connectors/cases/cases_connector.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/trial/connectors/cases/cases_connector.ts index b0fcd30fa5a42..060222473c15b 100644 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/trial/connectors/cases/cases_connector.ts +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/trial/connectors/cases/cases_connector.ts @@ -1352,7 +1352,7 @@ const executeConnectorAndVerifyCorrectness = async ({ connectorId, req, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; connectorId: string; req: Record; }) => { diff --git a/x-pack/test/common/services/bsearch_secure.ts b/x-pack/test/common/services/bsearch_secure.ts index 0ab967462767f..01050d1bb60c0 100644 --- a/x-pack/test/common/services/bsearch_secure.ts +++ b/x-pack/test/common/services/bsearch_secure.ts @@ -28,7 +28,7 @@ const getSpaceUrlPrefix = (spaceId?: string): string => { }; interface SendOptions { - supertestWithoutAuth: SuperTest.SuperTest; + supertestWithoutAuth: SuperTest.Agent; auth: { username: string; password: string }; referer?: string; kibanaVersion?: string; diff --git a/x-pack/test/common/utils/security_solution/detections_response/alerts/create_alerts_index.ts b/x-pack/test/common/utils/security_solution/detections_response/alerts/create_alerts_index.ts index 932db176942d9..da7f7b2cf36a6 100644 --- a/x-pack/test/common/utils/security_solution/detections_response/alerts/create_alerts_index.ts +++ b/x-pack/test/common/utils/security_solution/detections_response/alerts/create_alerts_index.ts @@ -17,7 +17,7 @@ import { countDownTest } from '../count_down_test'; * @param supertest The supertest client library */ export const createAlertsIndex = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog ): Promise => { await countDownTest( diff --git a/x-pack/test/common/utils/security_solution/detections_response/alerts/delete_all_alerts.ts b/x-pack/test/common/utils/security_solution/detections_response/alerts/delete_all_alerts.ts index e15aa4453282a..f29237b237694 100644 --- a/x-pack/test/common/utils/security_solution/detections_response/alerts/delete_all_alerts.ts +++ b/x-pack/test/common/utils/security_solution/detections_response/alerts/delete_all_alerts.ts @@ -16,7 +16,7 @@ import { countDownTest } from '../count_down_test'; * For use inside of afterEach blocks of tests */ export const deleteAllAlerts = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, es: Client, index: Array<'.alerts-security.alerts-*' | '.preview.alerts-security.alerts-*'> = [ diff --git a/x-pack/test/common/utils/security_solution/detections_response/alerts/get_alerts_by_id.ts b/x-pack/test/common/utils/security_solution/detections_response/alerts/get_alerts_by_id.ts index 1a3f7e29c26c6..92791edd5ea7e 100644 --- a/x-pack/test/common/utils/security_solution/detections_response/alerts/get_alerts_by_id.ts +++ b/x-pack/test/common/utils/security_solution/detections_response/alerts/get_alerts_by_id.ts @@ -20,7 +20,7 @@ import { getQueryAlertsId } from './get_query_alerts_ids'; * @param ids Rule id */ export const getAlertsById = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, id: string ): Promise> => { diff --git a/x-pack/test/common/utils/security_solution/detections_response/alerts/get_alerts_by_ids.ts b/x-pack/test/common/utils/security_solution/detections_response/alerts/get_alerts_by_ids.ts index 1cfc922d76677..d090a39ff3779 100644 --- a/x-pack/test/common/utils/security_solution/detections_response/alerts/get_alerts_by_ids.ts +++ b/x-pack/test/common/utils/security_solution/detections_response/alerts/get_alerts_by_ids.ts @@ -23,7 +23,7 @@ import { routeWithNamespace } from '../route_with_namespace'; * @param ids Array of the rule ids */ export const getAlertsByIds = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, ids: string[], size?: number, diff --git a/x-pack/test/common/utils/security_solution/detections_response/alerts/wait_for_alerts_to_be_present.ts b/x-pack/test/common/utils/security_solution/detections_response/alerts/wait_for_alerts_to_be_present.ts index f7e873f98d4c7..5772861f6e636 100644 --- a/x-pack/test/common/utils/security_solution/detections_response/alerts/wait_for_alerts_to_be_present.ts +++ b/x-pack/test/common/utils/security_solution/detections_response/alerts/wait_for_alerts_to_be_present.ts @@ -18,7 +18,7 @@ import { waitFor } from '../wait_for'; * @param numberOfAlerts The number of alerts to wait for, default is 1 */ export const waitForAlertsToBePresent = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, numberOfAlerts = 1, alertIds: string[], diff --git a/x-pack/test/common/utils/security_solution/detections_response/rules/create_rule.ts b/x-pack/test/common/utils/security_solution/detections_response/rules/create_rule.ts index ac6e44b2aab83..b1fe58770abfd 100644 --- a/x-pack/test/common/utils/security_solution/detections_response/rules/create_rule.ts +++ b/x-pack/test/common/utils/security_solution/detections_response/rules/create_rule.ts @@ -27,7 +27,7 @@ import { routeWithNamespace } from '../route_with_namespace'; * @param rule The rule to create */ export const createRule = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, rule: RuleCreateProps, namespace?: string diff --git a/x-pack/test/common/utils/security_solution/detections_response/rules/delete_all_rules.ts b/x-pack/test/common/utils/security_solution/detections_response/rules/delete_all_rules.ts index 8fe87827e4e25..66bf65ccfbc20 100644 --- a/x-pack/test/common/utils/security_solution/detections_response/rules/delete_all_rules.ts +++ b/x-pack/test/common/utils/security_solution/detections_response/rules/delete_all_rules.ts @@ -19,7 +19,7 @@ import { countDownTest } from '../count_down_test'; * @param supertest The supertest agent. */ export const deleteAllRules = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog ): Promise => { await countDownTest( diff --git a/x-pack/test/common/utils/security_solution/detections_response/rules/delete_rule.ts b/x-pack/test/common/utils/security_solution/detections_response/rules/delete_rule.ts index f4eff397aba0b..5b3e28f05e093 100644 --- a/x-pack/test/common/utils/security_solution/detections_response/rules/delete_rule.ts +++ b/x-pack/test/common/utils/security_solution/detections_response/rules/delete_rule.ts @@ -17,7 +17,7 @@ import { DETECTION_ENGINE_RULES_URL } from '@kbn/security-solution-plugin/common * @param ruleId The rule id to delete */ export const deleteRule = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, ruleId: string ): Promise => { const response = await supertest diff --git a/x-pack/test/common/utils/security_solution/detections_response/rules/wait_for_rule_status.ts b/x-pack/test/common/utils/security_solution/detections_response/rules/wait_for_rule_status.ts index af0838b29613d..975b8dbef3b72 100644 --- a/x-pack/test/common/utils/security_solution/detections_response/rules/wait_for_rule_status.ts +++ b/x-pack/test/common/utils/security_solution/detections_response/rules/wait_for_rule_status.ts @@ -16,7 +16,7 @@ import { waitFor } from '../wait_for'; import { routeWithNamespace } from '../route_with_namespace'; interface WaitForRuleStatusBaseParams { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; log: ToolingLog; afterDate?: Date; namespace?: string; diff --git a/x-pack/test/dataset_quality_api_integration/common/dataset_quality_api_supertest.ts b/x-pack/test/dataset_quality_api_integration/common/dataset_quality_api_supertest.ts index 79818e970a2ab..66823c794b017 100644 --- a/x-pack/test/dataset_quality_api_integration/common/dataset_quality_api_supertest.ts +++ b/x-pack/test/dataset_quality_api_integration/common/dataset_quality_api_supertest.ts @@ -12,7 +12,7 @@ import type { APIEndpoint } from '@kbn/dataset-quality-plugin/server/routes'; import { formatRequest } from '@kbn/server-route-repository'; import type { APIClientRequestParamsOf, APIReturnType } from '@kbn/dataset-quality-plugin/common'; -export function createDatasetQualityApiClient(st: supertest.SuperTest) { +export function createDatasetQualityApiClient(st: supertest.Agent) { return async ( options: { type?: 'form-data'; diff --git a/x-pack/test/dataset_quality_api_integration/tests/integrations/package_utils.ts b/x-pack/test/dataset_quality_api_integration/tests/integrations/package_utils.ts index 4aa403ee6d62a..ae2b9a01fa475 100644 --- a/x-pack/test/dataset_quality_api_integration/tests/integrations/package_utils.ts +++ b/x-pack/test/dataset_quality_api_integration/tests/integrations/package_utils.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SuperTest, Test } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; export interface IntegrationPackage { name: string; @@ -26,7 +26,7 @@ export async function installCustomIntegration({ supertest, customIntegration, }: { - supertest: SuperTest; + supertest: SuperTestAgent; customIntegration: CustomIntegration; }) { const { integrationName, datasets } = customIntegration; @@ -41,7 +41,7 @@ export async function installPackage({ supertest, pkg, }: { - supertest: SuperTest; + supertest: SuperTestAgent; pkg: IntegrationPackage; }) { const { name, version } = pkg; @@ -56,7 +56,7 @@ export async function uninstallPackage({ supertest, pkg, }: { - supertest: SuperTest; + supertest: SuperTestAgent; pkg: IntegrationPackage; }) { const { name, version } = pkg; diff --git a/x-pack/test/fleet_api_integration/apis/epm/install_by_upload.ts b/x-pack/test/fleet_api_integration/apis/epm/install_by_upload.ts index f086ad8785d8d..6fe31c67c65a2 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/install_by_upload.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/install_by_upload.ts @@ -9,6 +9,7 @@ import fs from 'fs'; import path from 'path'; import expect from '@kbn/expect'; import { INGEST_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server'; +import { HTTPError } from 'superagent'; import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; import { skipIfNoDockerRegistry } from '../../helpers'; @@ -167,7 +168,7 @@ export default function (providerContext: FtrProviderContext) { .type('application/gzip') .send(buf) .expect(400); - expect(res.error.text).to.equal( + expect((res.error as HTTPError).text).to.equal( '{"statusCode":400,"error":"Bad Request","message":"Archive seems empty. Assumed content type was application/gzip, check if this matches the archive type."}' ); }); @@ -180,7 +181,7 @@ export default function (providerContext: FtrProviderContext) { .type('application/zip') .send(buf) .expect(400); - expect(res.error.text).to.equal( + expect((res.error as HTTPError).text).to.equal( '{"statusCode":400,"error":"Bad Request","message":"Error during extraction of package: Error: end of central directory record signature not found. Assumed content type was application/zip, check if this matches the archive type."}' ); }); @@ -193,7 +194,7 @@ export default function (providerContext: FtrProviderContext) { .type('application/zip') .send(buf) .expect(400); - expect(res.error.text).to.equal( + expect((res.error as HTTPError).text).to.equal( '{"statusCode":400,"error":"Bad Request","message":"Package contains more than one top-level directory; top-level directory found: apache-0.1.4; filePath: apache-0.1.3/manifest.yml"}' ); }); @@ -206,7 +207,7 @@ export default function (providerContext: FtrProviderContext) { .type('application/zip') .send(buf) .expect(400); - expect(res.error.text).to.equal( + expect((res.error as HTTPError).text).to.equal( '{"statusCode":400,"error":"Bad Request","message":"Manifest file apache-0.1.4/manifest.yml not found in paths."}' ); }); @@ -219,7 +220,7 @@ export default function (providerContext: FtrProviderContext) { .type('application/zip') .send(buf) .expect(400); - expect(res.error.text).to.equal( + expect((res.error as HTTPError).text).to.equal( '{"statusCode":400,"error":"Bad Request","message":"Could not parse top-level package manifest at top-level directory apache-0.1.4: YAMLException: bad indentation of a mapping entry at line 2, column 7:\\n name: apache\\n ^."}' ); }); @@ -232,7 +233,7 @@ export default function (providerContext: FtrProviderContext) { .type('application/zip') .send(buf) .expect(400); - expect(res.error.text).to.equal( + expect((res.error as HTTPError).text).to.equal( '{"statusCode":400,"error":"Bad Request","message":"Invalid top-level package manifest at top-level directory apache-0.1.4 (package name: apache): one or more fields missing of name, version, description, title, format_version, owner."}' ); }); @@ -245,7 +246,7 @@ export default function (providerContext: FtrProviderContext) { .type('application/zip') .send(buf) .expect(400); - expect(res.error.text).to.equal( + expect((res.error as HTTPError).text).to.equal( '{"statusCode":400,"error":"Bad Request","message":"Name thisIsATypo and version 0.1.4 do not match top-level directory apache-0.1.4"}' ); }); diff --git a/x-pack/test/fleet_api_integration/helpers.ts b/x-pack/test/fleet_api_integration/helpers.ts index bf8729dba368b..2d9febe190892 100644 --- a/x-pack/test/fleet_api_integration/helpers.ts +++ b/x-pack/test/fleet_api_integration/helpers.ts @@ -15,7 +15,7 @@ import { } from '@kbn/fleet-plugin/common'; import { KbnClient } from '@kbn/test'; import { UNINSTALL_TOKENS_SAVED_OBJECT_TYPE } from '@kbn/fleet-plugin/common'; -import { SuperTest, Test } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { FtrProviderContext } from '../api_integration/ftr_provider_context'; export function warnAndSkipTest(mochaContext: Mocha.Context, log: ToolingLog) { @@ -109,7 +109,7 @@ export async function generateAgent( }); } -export function setPrereleaseSetting(supertest: SuperTest) { +export function setPrereleaseSetting(supertest: SuperTestAgent) { before(async () => { await supertest .put('/api/fleet/settings') @@ -126,7 +126,7 @@ export function setPrereleaseSetting(supertest: SuperTest) { } export const generateNAgentPolicies = async ( - supertest: SuperTest, + supertest: SuperTestAgent, number: number, overwrite?: Partial ): Promise => { @@ -142,7 +142,7 @@ export const generateNAgentPolicies = async ( }; export const generateAgentPolicy = async ( - supertest: SuperTest, + supertest: SuperTestAgent, overwrite?: Partial ): Promise => { const response = await supertest diff --git a/x-pack/test/functional/services/transform/api.ts b/x-pack/test/functional/services/transform/api.ts index 5aad29fff8942..15751c91253ec 100644 --- a/x-pack/test/functional/services/transform/api.ts +++ b/x-pack/test/functional/services/transform/api.ts @@ -237,7 +237,7 @@ export function TransformAPIProvider({ getService }: FtrProviderContext) { ); const { body, status } = await esSupertest .put(`/_transform/${transformId}${deferValidation ? '?defer_validation=true' : ''}`) - .set(headers) + .set(headers as Record) .send(transformConfig); this.assertResponseStatusCode(200, status, body); } else { diff --git a/x-pack/test/functional_with_es_ssl/apps/cases/group2/attachment_framework.ts b/x-pack/test/functional_with_es_ssl/apps/cases/group2/attachment_framework.ts index c45df81316e81..876e4d2123019 100644 --- a/x-pack/test/functional_with_es_ssl/apps/cases/group2/attachment_framework.ts +++ b/x-pack/test/functional_with_es_ssl/apps/cases/group2/attachment_framework.ts @@ -24,7 +24,7 @@ import { import { FtrProviderContext } from '../../../ftr_provider_context'; const createLogStashDataView = async ( - supertest: SuperTest.SuperTest + supertest: SuperTest.Agent ): Promise<{ data_view: { id: string } }> => { const { body } = await supertest .post(`/api/data_views/data_view`) @@ -36,7 +36,7 @@ const createLogStashDataView = async ( }; const deleteLogStashDataView = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, dataViewId: string ): Promise => { await supertest diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/utils.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/utils.ts index 09dffef846cd5..e96ec17eb9c2e 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/utils.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/utils.ts @@ -48,10 +48,7 @@ export const createSlackConnector = async ({ return connector; }; -export const getConnectorByName = async ( - name: string, - supertest: SuperTest.SuperTest -) => { +export const getConnectorByName = async (name: string, supertest: SuperTest.Agent) => { const { body } = await supertest .get(`/api/actions/connectors`) .set('kbn-xsrf', 'foo') @@ -65,7 +62,7 @@ export async function createRuleWithActionsAndParams( testRunUuid: string, params: Record = {}, overwrites: Record = {}, - supertest: SuperTest.SuperTest + supertest: SuperTest.Agent ) { return await createAlwaysFiringRule( { @@ -94,7 +91,7 @@ export async function createRuleWithActionsAndParams( async function createAlwaysFiringRule( overwrites: Record = {}, - supertest: SuperTest.SuperTest + supertest: SuperTest.Agent ) { const { body: createdRule } = await supertest .post(`/api/alerting/rule`) @@ -109,10 +106,7 @@ async function createAlwaysFiringRule( return createdRule; } -export async function getAlertSummary( - ruleId: string, - supertest: SuperTest.SuperTest -) { +export async function getAlertSummary(ruleId: string, supertest: SuperTest.Agent) { const { body: summary } = await supertest .get(`/internal/alerting/rule/${encodeURIComponent(ruleId)}/_alert_summary`) .expect(200); diff --git a/x-pack/test/monitoring_api_integration/packages.ts b/x-pack/test/monitoring_api_integration/packages.ts index 284bba089a55c..981845eb460dc 100644 --- a/x-pack/test/monitoring_api_integration/packages.ts +++ b/x-pack/test/monitoring_api_integration/packages.ts @@ -30,10 +30,7 @@ export const getPackagesArgs = (): string[] => { export const bundledPackagesLocation = path.join(path.dirname(__filename), '/fixtures/packages'); -export function installPackage( - supertest: SuperTest.SuperTest, - packageName: SupportedPackage -) { +export function installPackage(supertest: SuperTest.Agent, packageName: SupportedPackage) { const pkg = PACKAGES.find(({ name }) => name === packageName); const request = supertest .post('/api/fleet/epm/packages') diff --git a/x-pack/test/observability_ai_assistant_api_integration/common/observability_ai_assistant_api_client.ts b/x-pack/test/observability_ai_assistant_api_integration/common/observability_ai_assistant_api_client.ts index cb59adca9a86a..865620a2d028a 100644 --- a/x-pack/test/observability_ai_assistant_api_integration/common/observability_ai_assistant_api_client.ts +++ b/x-pack/test/observability_ai_assistant_api_integration/common/observability_ai_assistant_api_client.ts @@ -15,7 +15,7 @@ import supertest from 'supertest'; import { format } from 'url'; import { Subtract } from 'utility-types'; -export function createObservabilityAIAssistantApiClient(st: supertest.SuperTest) { +export function createObservabilityAIAssistantApiClient(st: supertest.Agent) { return ( options: { type?: 'form-data'; @@ -70,17 +70,62 @@ type WithoutPromise> = Subtract>; // end(one:string) // end(one:string, two:string) // } -// would lose the first signature. This keeps up to four signatures. +// would lose the first signature. This keeps up to eight signatures. type OverloadedParameters = T extends { (...args: infer A1): any; (...args: infer A2): any; (...args: infer A3): any; (...args: infer A4): any; + (...args: infer A5): any; + (...args: infer A6): any; + (...args: infer A7): any; + (...args: infer A8): any; } + ? A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 + : T extends { + (...args: infer A1): any; + (...args: infer A2): any; + (...args: infer A3): any; + (...args: infer A4): any; + (...args: infer A5): any; + (...args: infer A6): any; + (...args: infer A7): any; + } + ? A1 | A2 | A3 | A4 | A5 | A6 | A7 + : T extends { + (...args: infer A1): any; + (...args: infer A2): any; + (...args: infer A3): any; + (...args: infer A4): any; + (...args: infer A5): any; + (...args: infer A6): any; + } + ? A1 | A2 | A3 | A4 | A5 | A6 + : T extends { + (...args: infer A1): any; + (...args: infer A2): any; + (...args: infer A3): any; + (...args: infer A4): any; + (...args: infer A5): any; + } + ? A1 | A2 | A3 | A4 | A5 + : T extends { + (...args: infer A1): any; + (...args: infer A2): any; + (...args: infer A3): any; + (...args: infer A4): any; + } ? A1 | A2 | A3 | A4 - : T extends { (...args: infer A1): any; (...args: infer A2): any; (...args: infer A3): any } + : T extends { + (...args: infer A1): any; + (...args: infer A2): any; + (...args: infer A3): any; + } ? A1 | A2 | A3 - : T extends { (...args: infer A1): any; (...args: infer A2): any } + : T extends { + (...args: infer A1): any; + (...args: infer A2): any; + } ? A1 | A2 : T extends (...args: infer A) => any ? A diff --git a/x-pack/test/observability_ai_assistant_api_integration/tests/connectors/connectors.spec.ts b/x-pack/test/observability_ai_assistant_api_integration/tests/connectors/connectors.spec.ts index d5e726012c869..d51edffc9a1a8 100644 --- a/x-pack/test/observability_ai_assistant_api_integration/tests/connectors/connectors.spec.ts +++ b/x-pack/test/observability_ai_assistant_api_integration/tests/connectors/connectors.spec.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { SuperTest, Test } from 'supertest'; +import type { Agent as SuperTestAgent } from 'supertest'; import { FtrProviderContext } from '../../common/ftr_provider_context'; export default function ApiTest({ getService }: FtrProviderContext) { @@ -71,7 +71,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { }); } -export async function deleteAllActionConnectors(supertest: SuperTest): Promise { +export async function deleteAllActionConnectors(supertest: SuperTestAgent): Promise { const res = await supertest.get(`/api/actions/connectors`); const body = res.body as Array<{ id: string; connector_type_id: string; name: string }>; diff --git a/x-pack/test/observability_api_integration/common/obs_api_supertest.ts b/x-pack/test/observability_api_integration/common/obs_api_supertest.ts index e0788dcd6785d..69d7083f838e4 100644 --- a/x-pack/test/observability_api_integration/common/obs_api_supertest.ts +++ b/x-pack/test/observability_api_integration/common/obs_api_supertest.ts @@ -24,7 +24,7 @@ export type APIClientRequestParamsOf = ClientRequ TEndpoint >; -export function createObsApiClient(st: supertest.SuperTest) { +export function createObsApiClient(st: supertest.Agent) { return async ( options: { type?: 'form-data'; diff --git a/x-pack/test/observability_onboarding_api_integration/common/observability_onboarding_api_supertest.ts b/x-pack/test/observability_onboarding_api_integration/common/observability_onboarding_api_supertest.ts index c679c91e96525..199230e92c4ae 100644 --- a/x-pack/test/observability_onboarding_api_integration/common/observability_onboarding_api_supertest.ts +++ b/x-pack/test/observability_onboarding_api_integration/common/observability_onboarding_api_supertest.ts @@ -15,7 +15,7 @@ import type { import type { APIEndpoint } from '@kbn/observability-onboarding-plugin/server/routes'; import { formatRequest } from '@kbn/server-route-repository'; -export function createObservabilityOnboardingApiClient(st: supertest.SuperTest) { +export function createObservabilityOnboardingApiClient(st: supertest.Agent) { return async ( options: { type?: 'form-data'; diff --git a/x-pack/test/profiling_api_integration/common/api_supertest.ts b/x-pack/test/profiling_api_integration/common/api_supertest.ts index 11d7564248caf..dcd5c892d3b77 100644 --- a/x-pack/test/profiling_api_integration/common/api_supertest.ts +++ b/x-pack/test/profiling_api_integration/common/api_supertest.ts @@ -10,7 +10,7 @@ import request from 'superagent'; import supertest from 'supertest'; import { format } from 'url'; -export function createProfilingApiClient(st: supertest.SuperTest) { +export function createProfilingApiClient(st: supertest.Agent) { return async (options: { endpoint: string; params?: { diff --git a/x-pack/test/profiling_api_integration/common/bettertest.ts b/x-pack/test/profiling_api_integration/common/bettertest.ts index ca679a24539ac..ec2fd13763853 100644 --- a/x-pack/test/profiling_api_integration/common/bettertest.ts +++ b/x-pack/test/profiling_api_integration/common/bettertest.ts @@ -23,7 +23,7 @@ export type BetterTest = (options: { * This is useful for tests that expect a 200 response * It also makes it easier to debug tests that fail because of a 500 response. */ -export function getBettertest(st: supertest.SuperTest): BetterTest { +export function getBettertest(st: supertest.Agent): BetterTest { return async ({ pathname, method = 'get', query, body }) => { const url = format({ pathname, query }); @@ -60,7 +60,7 @@ export class BetterTestError extends Error { const req = res.req as any; super( `Unhandled BetterTestError: -Status: "${res.status}" +Status: "${res.status}" Path: "${req.method} ${req.path}" Body: ${JSON.stringify(res.body)}` ); diff --git a/x-pack/test/saved_object_api_integration/common/lib/create_users_and_roles.ts b/x-pack/test/saved_object_api_integration/common/lib/create_users_and_roles.ts index e0fed03efb94d..eb7a729ff5c96 100644 --- a/x-pack/test/saved_object_api_integration/common/lib/create_users_and_roles.ts +++ b/x-pack/test/saved_object_api_integration/common/lib/create_users_and_roles.ts @@ -5,11 +5,11 @@ * 2.0. */ -import type { SuperTest } from 'supertest'; +import type { Agent as SuperTestAgent } from 'supertest'; import type { Client } from '@elastic/elasticsearch'; import { AUTHENTICATION } from './authentication'; -export const createUsersAndRoles = async (es: Client, supertest: SuperTest) => { +export const createUsersAndRoles = async (es: Client, supertest: SuperTestAgent) => { await supertest .put('/api/security/role/kibana_legacy_user') .send({ diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts index 38a4a8d8db8c7..6b79b34489111 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts @@ -258,7 +258,7 @@ export function bulkCreateTestSuiteFactory(context: FtrProviderContext) { const query = test.overwrite ? '?overwrite=true' : ''; await supertest .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_create${query}`) - .auth(user?.username, user?.password) + .auth(user?.username!, user?.password!) .send(requestBody) .expect(test.responseStatusCode) .then(test.responseBody); diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_delete.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_delete.ts index 578f8a4e0cd1f..f7fe4ba4061ce 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/bulk_delete.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_delete.ts @@ -138,7 +138,7 @@ export function bulkDeleteTestSuiteFactory(context: FtrProviderContext) { const query = testForce && testForce === true ? '?force=true' : ''; await supertest .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_delete${query}`) - .auth(user?.username, user?.password) + .auth(user?.username!, user?.password!) .send(requestBody) .expect(test.responseStatusCode) .then(test.responseBody); diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts index 15a51c3db3364..d25d1e0a5d87c 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts @@ -125,7 +125,7 @@ export function bulkGetTestSuiteFactory(context: FtrProviderContext) { it(`should return ${test.responseStatusCode} ${test.title}`, async () => { await supertest .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_get`) - .auth(user?.username, user?.password) + .auth(user?.username!, user?.password!) .send(test.request) .expect(test.responseStatusCode) .then(test.responseBody); diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_resolve.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_resolve.ts index a203865e294aa..b3c8669d48216 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/bulk_resolve.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_resolve.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { SuperTest } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { TEST_CASES } from './resolve'; import { SPACES } from '../lib/spaces'; import { @@ -29,7 +29,7 @@ export interface BulkResolveTestCase extends TestCase { export { TEST_CASES }; // re-export the (non-bulk) resolve test cases -export function bulkResolveTestSuiteFactory(esArchiver: any, supertest: SuperTest) { +export function bulkResolveTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) { const expectSavedObjectForbidden = expectResponses.forbiddenTypes('bulk_get'); const expectResponseBody = ( @@ -119,7 +119,7 @@ export function bulkResolveTestSuiteFactory(esArchiver: any, supertest: SuperTes it(`should return ${test.responseStatusCode} ${test.title}`, async () => { await supertest .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_resolve`) - .auth(user?.username, user?.password) + .auth(user?.username!, user?.password!) .send(test.request) .expect(test.responseStatusCode) .then(test.responseBody); diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_update.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_update.ts index e79089615e7ee..384b8db8aa0a7 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/bulk_update.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_update.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { SuperTest } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; import { SPACES } from '../lib/spaces'; import { expectResponses, getUrlPrefix, getTestTitle } from '../lib/saved_object_test_utils'; @@ -36,7 +36,7 @@ const createRequest = ({ type, id, namespace }: BulkUpdateTestCase) => ({ ...(namespace && { namespace }), // individual "object namespace" string }); -export function bulkUpdateTestSuiteFactory(esArchiver: any, supertest: SuperTest) { +export function bulkUpdateTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) { const expectSavedObjectForbidden = expectResponses.forbiddenTypes('bulk_update'); const expectResponseBody = ( @@ -118,7 +118,7 @@ export function bulkUpdateTestSuiteFactory(esArchiver: any, supertest: SuperTest const requestBody = test.request.map((x) => ({ ...x, ...attrs })); await supertest .put(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_update`) - .auth(user?.username, user?.password) + .auth(user?.username!, user?.password!) .send(requestBody) .expect(test.responseStatusCode) .then(test.responseBody); diff --git a/x-pack/test/saved_object_api_integration/common/suites/create.ts b/x-pack/test/saved_object_api_integration/common/suites/create.ts index dfad5e638a708..b12fef1c7cade 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/create.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/create.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { SuperTest } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; import { SPACES, ALL_SPACES_ID } from '../lib/spaces'; import { @@ -85,7 +85,7 @@ const createRequest = ({ type, id, initialNamespaces }: CreateTestCase) => ({ initialNamespaces, }); -export function createTestSuiteFactory(esArchiver: any, supertest: SuperTest) { +export function createTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) { const expectSavedObjectForbidden = expectResponses.forbiddenTypes('create'); const expectResponseBody = (testCase: CreateTestCase, user?: TestUser): ExpectResponseBody => @@ -155,7 +155,7 @@ export function createTestSuiteFactory(esArchiver: any, supertest: SuperTest = Object.freeze({ */ const createRequest = ({ type, id, force }: DeleteTestCase) => ({ type, id, force }); -export function deleteTestSuiteFactory(es: Client, esArchiver: any, supertest: SuperTest) { +export function deleteTestSuiteFactory(es: Client, esArchiver: any, supertest: SuperTestAgent) { const expectSavedObjectForbidden = expectResponses.forbiddenTypes('delete'); const expectResponseBody = (testCase: DeleteTestCase): ExpectResponseBody => @@ -118,7 +118,7 @@ export function deleteTestSuiteFactory(es: Client, esArchiver: any, supertest: S await supertest .delete(`${getUrlPrefix(spaceId)}/api/saved_objects/${type}/${id}`) .query({ ...(force && { force }) }) - .auth(user?.username, user?.password) + .auth(user?.username!, user?.password!) .expect(test.responseStatusCode) .then(test.responseBody); }); diff --git a/x-pack/test/saved_object_api_integration/common/suites/export.ts b/x-pack/test/saved_object_api_integration/common/suites/export.ts index 6df4c2f8dd12c..b7936f94a98fb 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/export.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/export.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { SuperTest } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { SAVED_OBJECT_TEST_CASES, CONFLICT_TEST_CASES, @@ -154,7 +154,7 @@ const EMPTY_RESULT = { missingReferences: [], }; -export function exportTestSuiteFactory(esArchiver: any, supertest: SuperTest) { +export function exportTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) { const expectSavedObjectForbiddenBulkGet = expectResponses.forbiddenTypes('bulk_get'); const expectResponseBody = (testCase: ExportTestCase): ExpectResponseBody => @@ -259,7 +259,7 @@ export function exportTestSuiteFactory(esArchiver: any, supertest: SuperTest { await supertest .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_export`) - .auth(user?.username, user?.password) + .auth(user?.username!, user?.password!) .send(test.request) .expect(test.responseStatusCode) .then(test.responseBody); diff --git a/x-pack/test/saved_object_api_integration/common/suites/find.ts b/x-pack/test/saved_object_api_integration/common/suites/find.ts index 202fc02dbfc1c..c7afc205f5b6f 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/find.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/find.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { SuperTest } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import querystring from 'querystring'; import { SAVED_OBJECT_TEST_CASES, @@ -187,7 +187,7 @@ export const createRequest = ({ query }: FindTestCase) => ({ query }); const getTestTitle = ({ failure, title }: FindTestCase) => `${failure?.reason || 'success'} ["${title}"]`; -export function findTestSuiteFactory(esArchiver: any, supertest: SuperTest) { +export function findTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) { const expectResponseBody = (testCase: FindTestCase, user?: TestUser): ExpectResponseBody => async (response: Record) => { @@ -298,7 +298,7 @@ export function findTestSuiteFactory(esArchiver: any, supertest: SuperTest) await supertest .get(`${getUrlPrefix(spaceId)}/api/saved_objects/_find${query}`) - .auth(user?.username, user?.password) + .auth(user?.username!, user?.password!) .expect(test.responseStatusCode) .then(test.responseBody); }); diff --git a/x-pack/test/saved_object_api_integration/common/suites/get.ts b/x-pack/test/saved_object_api_integration/common/suites/get.ts index b106930103f84..024f061d2cb23 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/get.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/get.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SuperTest } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; import { SPACES } from '../lib/spaces'; import { @@ -25,7 +25,7 @@ export type GetTestCase = TestCase; const DOES_NOT_EXIST = Object.freeze({ type: 'dashboard', id: 'does-not-exist' }); export const TEST_CASES: Record = Object.freeze({ ...CASES, DOES_NOT_EXIST }); -export function getTestSuiteFactory(esArchiver: any, supertest: SuperTest) { +export function getTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) { const expectSavedObjectForbidden = expectResponses.forbiddenTypes('get'); const expectResponseBody = (testCase: GetTestCase): ExpectResponseBody => @@ -81,7 +81,7 @@ export function getTestSuiteFactory(esArchiver: any, supertest: SuperTest) const { type, id } = test.request; await supertest .get(`${getUrlPrefix(spaceId)}/api/saved_objects/${type}/${id}`) - .auth(user?.username, user?.password) + .auth(user?.username!, user?.password!) .expect(test.responseStatusCode) .then(test.responseBody); }); diff --git a/x-pack/test/saved_object_api_integration/common/suites/import.ts b/x-pack/test/saved_object_api_integration/common/suites/import.ts index 7580521e170a6..1af1bf07510b2 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/import.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/import.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { SuperTest } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import type { Client } from '@elastic/elasticsearch'; import type { SavedObjectReference } from '@kbn/core/server'; import { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; @@ -121,7 +121,7 @@ export const importTestCaseFailures = { condition !== false ? { failureType: 'missing_references' } : {}, }; -export function importTestSuiteFactory(es: Client, esArchiver: any, supertest: SuperTest) { +export function importTestSuiteFactory(es: Client, esArchiver: any, supertest: SuperTestAgent) { const expectSavedObjectForbidden = (action: string, typeOrTypes: string | string[]) => expectResponses.forbiddenTypes(action)(typeOrTypes); const expectResponseBody = @@ -310,7 +310,7 @@ export function importTestSuiteFactory(es: Client, esArchiver: any, supertest: S : ''; await supertest .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_import${query}`) - .auth(user?.username, user?.password) + .auth(user?.username!, user?.password!) .attach('file', Buffer.from(requestBody, 'utf8'), 'export.ndjson') .expect(test.responseStatusCode) .then(test.responseBody); diff --git a/x-pack/test/saved_object_api_integration/common/suites/resolve.ts b/x-pack/test/saved_object_api_integration/common/suites/resolve.ts index ebb71a860d744..8f03686d4cabc 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/resolve.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/resolve.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { SuperTest } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; import { SPACES } from '../lib/spaces'; import { @@ -70,7 +70,7 @@ export const TEST_CASES = Object.freeze({ HIDDEN: CASES.HIDDEN, }); -export function resolveTestSuiteFactory(esArchiver: any, supertest: SuperTest) { +export function resolveTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) { const expectSavedObjectForbidden = expectResponses.forbiddenTypes('bulk_get'); const expectResponseBody = (testCase: ResolveTestCase): ExpectResponseBody => @@ -135,7 +135,7 @@ export function resolveTestSuiteFactory(esArchiver: any, supertest: SuperTest + supertest: SuperTestAgent ) { const expectSavedObjectForbidden = (action: string, typeOrTypes: string | string[]) => expectResponses.forbiddenTypes(action)(typeOrTypes); @@ -373,7 +373,7 @@ export function resolveImportErrorsTestSuiteFactory( const query = test.createNewCopies ? '?createNewCopies=true' : ''; await supertest .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_resolve_import_errors${query}`) - .auth(user?.username, user?.password) + .auth(user?.username!, user?.password!) .field('retries', JSON.stringify(test.request.retries)) .attach('file', Buffer.from(requestBody, 'utf8'), 'export.ndjson') .expect(test.responseStatusCode) diff --git a/x-pack/test/saved_object_api_integration/common/suites/update.ts b/x-pack/test/saved_object_api_integration/common/suites/update.ts index 1fc2cef6e051a..ee37e0feccfe2 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/update.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/update.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { SuperTest } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; import { SPACES } from '../lib/spaces'; import { expectResponses, getUrlPrefix, getTestTitle } from '../lib/saved_object_test_utils'; @@ -34,7 +34,7 @@ export const TEST_CASES: Record = Object.freeze({ const createRequest = ({ type, id, upsert }: UpdateTestCase) => ({ type, id, upsert }); -export function updateTestSuiteFactory(esArchiver: any, supertest: SuperTest) { +export function updateTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) { const expectSavedObjectForbidden = expectResponses.forbiddenTypes('update'); const expectResponseBody = (testCase: UpdateTestCase): ExpectResponseBody => @@ -94,7 +94,7 @@ export function updateTestSuiteFactory(esArchiver: any, supertest: SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, id: string ): Promise => { diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/detection_engine/rule_execution_logic/trial_license_complete_tier/execution_logic/utils.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/detection_engine/rule_execution_logic/trial_license_complete_tier/execution_logic/utils.ts index ec6fac6cf2bcd..31278019dad3e 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/detection_engine/rule_execution_logic/trial_license_complete_tier/execution_logic/utils.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/detection_engine/rule_execution_logic/trial_license_complete_tier/execution_logic/utils.ts @@ -10,10 +10,7 @@ import supertest from 'supertest'; import { NodeMetrics } from '@kbn/task-manager-plugin/server/routes/metrics'; import { RetryService } from '@kbn/ftr-common-functional-services'; -export const getMetricsRequest = ( - request: supertest.SuperTest, - reset: boolean = false -) => { +export const getMetricsRequest = (request: supertest.Agent, reset: boolean = false) => { return request .get(`/api/task_manager/metrics${reset ? '' : '?reset=false'}`) .set('kbn-xsrf', 'foo') @@ -22,7 +19,7 @@ export const getMetricsRequest = ( }; export const getMetricsWithRetry = ( - request: supertest.SuperTest, + request: supertest.Agent, retry: RetryService, reset: boolean = false, callback?: (metrics: NodeMetrics) => boolean diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/actions/create_new_webhook_action.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/actions/create_new_webhook_action.ts index 79ea9738372f0..79a5b715f9fe1 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/actions/create_new_webhook_action.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/actions/create_new_webhook_action.ts @@ -17,9 +17,7 @@ import { getWebHookAction } from './get_web_hook_action'; * * @param supertest The supertest deps */ -export const createWebHookRuleAction = async ( - supertest: SuperTest.SuperTest -): Promise => { +export const createWebHookRuleAction = async (supertest: SuperTest.Agent): Promise => { return ( await supertest .post('/api/actions/action') diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/get_alerts.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/get_alerts.ts index 21d8233c8496b..70caaa4edfd2c 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/get_alerts.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/get_alerts.ts @@ -18,7 +18,7 @@ import { refreshIndex } from '..'; import { getAlertsByIds, waitForRuleStatus } from '../../../../../common/utils/security_solution'; export type GetAlerts = ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, es: Client, rule: RuleResponse, diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/migrations/finalize_alerts_migration.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/migrations/finalize_alerts_migration.ts index 02a7475f54aac..1f7d03cab9c5e 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/migrations/finalize_alerts_migration.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/migrations/finalize_alerts_migration.ts @@ -21,7 +21,7 @@ export const finalizeAlertsMigration = async ({ supertest, log, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; log: ToolingLog; migrationIds: string[]; }): Promise => { diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/migrations/start_alerts_migration.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/migrations/start_alerts_migration.ts index 5d472221154c1..304cf11d79dce 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/migrations/start_alerts_migration.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/migrations/start_alerts_migration.ts @@ -21,7 +21,7 @@ export const startAlertsMigration = async ({ supertest, log, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; log: ToolingLog; indices: string[]; }): Promise => { diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/wait_for_alert_to_complete.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/wait_for_alert_to_complete.ts index 7d942198bc0d5..d6799e6be611c 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/wait_for_alert_to_complete.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/alerts/wait_for_alert_to_complete.ts @@ -11,7 +11,7 @@ import type SuperTest from 'supertest'; import { waitFor } from '../../../../../common/utils/security_solution'; export const waitForAlertToComplete = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, id: string ): Promise => { diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/connectors/create_connector.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/connectors/create_connector.ts index 0ca8f88166c89..c6c67e37ebf24 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/connectors/create_connector.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/connectors/create_connector.ts @@ -15,7 +15,7 @@ export interface CreateConnectorBody { } export async function createConnector( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, connector: CreateConnectorBody, id = '' ): Promise { diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/connectors/delete_connector.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/connectors/delete_connector.ts index 683f845fd8bf8..1003c7cd8880b 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/connectors/delete_connector.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/connectors/delete_connector.ts @@ -7,9 +7,6 @@ import type SuperTest from 'supertest'; -export function deleteConnector( - supertest: SuperTest.SuperTest, - connectorId: string -): SuperTest.Test { +export function deleteConnector(supertest: SuperTest.Agent, connectorId: string): SuperTest.Test { return supertest.delete(`/api/actions/connector/${connectorId}`).set('kbn-xsrf', 'foo'); } diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/connectors/get_connector.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/connectors/get_connector.ts index 8f7e4830372f9..9132b188ecd33 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/connectors/get_connector.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/connectors/get_connector.ts @@ -9,7 +9,7 @@ import { Connector } from '@kbn/actions-plugin/server/application/connector/type import type SuperTest from 'supertest'; export async function getConnector( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, connectorId: string ): Promise { const response = await supertest diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/item/create_exception_list_item.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/item/create_exception_list_item.ts index fccbd3e243b17..39f202c13bce6 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/item/create_exception_list_item.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/item/create_exception_list_item.ts @@ -22,7 +22,7 @@ import { EXCEPTION_LIST_ITEM_URL } from '@kbn/securitysolution-list-constants'; * @param log The tooling logger */ export const createExceptionListItem = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, exceptionListItem: CreateExceptionListItemSchema ): Promise => { diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/create_container_with_endpoint_entries.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/create_container_with_endpoint_entries.ts index 7541514448b5c..442d341815c2f 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/create_container_with_endpoint_entries.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/create_container_with_endpoint_entries.ts @@ -27,7 +27,7 @@ import { createExceptionList } from './create_exception_list'; * @param osTypes The os types to optionally add or not to add to the container */ export const createContainerWithEndpointEntries = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, endpointEntries: Array<{ entries: NonEmptyEntriesArray; diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/create_container_with_entries.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/create_container_with_entries.ts index 973e0d1962a75..36aa1fb0e0652 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/create_container_with_entries.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/create_container_with_entries.ts @@ -23,7 +23,7 @@ import { waitFor } from '../../../../../../common/utils/security_solution'; * @param osTypes The os types to optionally add or not to add to the container */ export const createContainerWithEntries = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, entries: NonEmptyEntriesArray[] ): Promise => { diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/create_exception_list.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/create_exception_list.ts index 24ebabb5243b2..cae20d074a1c3 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/create_exception_list.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/create_exception_list.ts @@ -23,7 +23,7 @@ import { deleteExceptionList } from './delete_exception_list'; * @param log The tooling logger */ export const createExceptionList = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, exceptionList: CreateExceptionListSchema ): Promise => { diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/delete_exception_list.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/delete_exception_list.ts index 6c5558a005b97..17cc52ac8c4b6 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/delete_exception_list.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/exception_list_and_item/list/delete_exception_list.ts @@ -18,7 +18,7 @@ import type { RuleResponse } from '@kbn/security-solution-plugin/common/api/dete * @param log The tooling logger */ export const deleteExceptionList = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, listId: string ): Promise => { diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/get_stats.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/get_stats.ts index 9415f6900a54f..bd8b3d3ea175c 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/get_stats.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/get_stats.ts @@ -22,7 +22,7 @@ import { getDetectionMetricsFromBody } from './get_detection_metrics_from_body'; * @returns The detection metrics */ export const getStats = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog ): Promise => { const response = await supertest diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/machine_learning/machine_learning_setup.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/machine_learning/machine_learning_setup.ts index d7c7e6387c739..a9b9bf1c8ce5b 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/machine_learning/machine_learning_setup.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/machine_learning/machine_learning_setup.ts @@ -15,7 +15,7 @@ export const executeSetupModuleRequest = async ({ }: { module: string; rspCode: number; - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; }) => { const { body } = await supertest .post(`/internal/ml/modules/setup/${module}`) @@ -40,7 +40,7 @@ export const forceStartDatafeeds = async ({ }: { jobId: string; rspCode: number; - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; }) => { const { body } = await supertest .post(`/internal/ml/jobs/force_start_datafeeds`) diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_legacy_rule_action.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_legacy_rule_action.ts index 8e0cb59d5ee90..439dd6a44f4d8 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_legacy_rule_action.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_legacy_rule_action.ts @@ -10,7 +10,7 @@ import type SuperTest from 'supertest'; import { UPDATE_OR_CREATE_LEGACY_ACTIONS } from '@kbn/security-solution-plugin/common/constants'; export const createLegacyRuleAction = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, alertId: string, connectorId: string ): Promise => diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_non_security_rule.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_non_security_rule.ts index 09bc0f9b81a6d..c6fd0f8d1bc78 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_non_security_rule.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_non_security_rule.ts @@ -30,9 +30,7 @@ const SIMPLE_APM_RULE_DATA = { * Created a non security rule. Helpful in tests to verify functionality works with presence of non security rules. * @param supertest The supertest deps */ -export async function createNonSecurityRule( - supertest: SuperTest.SuperTest -): Promise { +export async function createNonSecurityRule(supertest: SuperTest.Agent): Promise { await supertest .post('/api/alerting/rule') .set('kbn-xsrf', 'true') diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_rule_saved_object.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_rule_saved_object.ts index 93a6322011623..f4e3f22a0c9a6 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_rule_saved_object.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_rule_saved_object.ts @@ -21,7 +21,7 @@ import { * @param supertest */ export const createRuleThroughAlertingEndpoint = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, rule: InternalRuleCreate ): Promise> => { const { body } = await supertest diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_rule_with_auth.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_rule_with_auth.ts index 7b5e4435a3dbb..cde330f8c76a1 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_rule_with_auth.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_rule_with_auth.ts @@ -19,7 +19,7 @@ import type { * @param rule The rule to create */ export const createRuleWithAuth = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, rule: RuleCreateProps, auth: { user: string; pass: string } ): Promise => { diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_rule_with_exception_entries.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_rule_with_exception_entries.ts index ca2a8129b7713..a04ac5950596e 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_rule_with_exception_entries.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/create_rule_with_exception_entries.ts @@ -31,7 +31,7 @@ import { createRule } from '../../../../../common/utils/security_solution'; * @param osTypes The os types to optionally add or not to add to the container */ export const createRuleWithExceptionEntries = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, rule: RuleCreateProps, entries: NonEmptyEntriesArray[], diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/fetch_rule.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/fetch_rule.ts index 8e9e1008ff404..651bb2a595f8f 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/fetch_rule.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/fetch_rule.ts @@ -18,7 +18,7 @@ import { DETECTION_ENGINE_RULES_URL } from '@kbn/security-solution-plugin/common * @param rule The rule to create */ export const fetchRule = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, idOrRuleId: { id: string; ruleId?: never } | { id?: never; ruleId: string } ): Promise => ( diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/find_immutable_rule_by_id.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/find_immutable_rule_by_id.ts index 55e7375c48986..f4b026748e986 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/find_immutable_rule_by_id.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/find_immutable_rule_by_id.ts @@ -17,7 +17,7 @@ import { DETECTION_ENGINE_RULES_URL } from '@kbn/security-solution-plugin/common * @param supertest The supertest deps */ export const findImmutableRuleById = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, ruleId: string ): Promise<{ diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/get_coverage_overview.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/get_coverage_overview.ts index f93a29b0ec149..b512494f245e2 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/get_coverage_overview.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/get_coverage_overview.ts @@ -13,7 +13,7 @@ import { } from '@kbn/security-solution-plugin/common/api/detection_engine'; export const getCoverageOverview = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, filter?: CoverageOverviewFilter ): Promise => { const response = await supertest diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/get_rule_actions.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/get_rule_actions.ts index 3251d2b0a6b56..36784cc47aa1a 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/get_rule_actions.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/get_rule_actions.ts @@ -11,19 +11,16 @@ import { RuleActionArray } from '@kbn/securitysolution-io-ts-alerting-types'; import { getSlackAction } from '..'; import { getWebHookAction } from '..'; -const createConnector = async ( - supertest: SuperTest.SuperTest, - payload: Record -) => +const createConnector = async (supertest: SuperTest.Agent, payload: Record) => (await supertest.post('/api/actions/action').set('kbn-xsrf', 'true').send(payload).expect(200)) .body; -const createWebHookConnector = (supertest: SuperTest.SuperTest) => +const createWebHookConnector = (supertest: SuperTest.Agent) => createConnector(supertest, getWebHookAction()); -const createSlackConnector = (supertest: SuperTest.SuperTest) => +const createSlackConnector = (supertest: SuperTest.Agent) => createConnector(supertest, getSlackAction()); export const getActionsWithoutFrequencies = async ( - supertest: SuperTest.SuperTest + supertest: SuperTest.Agent ): Promise => { const webHookAction = await createWebHookConnector(supertest); const slackConnector = await createSlackConnector(supertest); @@ -44,7 +41,7 @@ export const getActionsWithoutFrequencies = async ( }; export const getActionsWithFrequencies = async ( - supertest: SuperTest.SuperTest + supertest: SuperTest.Agent ): Promise => { const webHookAction = await createWebHookConnector(supertest); const slackConnector = await createSlackConnector(supertest); @@ -67,7 +64,7 @@ export const getActionsWithFrequencies = async ( }; export const getSomeActionsWithFrequencies = async ( - supertest: SuperTest.SuperTest + supertest: SuperTest.Agent ): Promise => { const webHookAction = await createWebHookConnector(supertest); const slackConnector = await createSlackConnector(supertest); diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/patch_rule.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/patch_rule.ts index f62f49b20d622..44456c93a16cd 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/patch_rule.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/patch_rule.ts @@ -21,7 +21,7 @@ import { * @param rule The rule to create */ export const patchRule = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, patchedRule: RulePatchProps ): Promise => { diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/delete_prebuilt_rules_fleet_package.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/delete_prebuilt_rules_fleet_package.ts index 1647ff301a324..a3468ccb32b5a 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/delete_prebuilt_rules_fleet_package.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/delete_prebuilt_rules_fleet_package.ts @@ -13,9 +13,7 @@ import type SuperTest from 'supertest'; * * @param supertest Supertest instance */ -export async function deletePrebuiltRulesFleetPackage( - supertest: SuperTest.SuperTest -) { +export async function deletePrebuiltRulesFleetPackage(supertest: SuperTest.Agent) { const resp = await supertest .get(epmRouteService.getInfoPath('security_detection_engine')) .set('kbn-xsrf', 'true') diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_installed_rules.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_installed_rules.ts index f796dd06e777b..04a9c52565bf1 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_installed_rules.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_installed_rules.ts @@ -17,9 +17,7 @@ import { FindRulesResponse } from '@kbn/security-solution-plugin/common/api/dete * @returns Fleet install package response */ -export const getInstalledRules = async ( - supertest: SuperTest.SuperTest -): Promise => { +export const getInstalledRules = async (supertest: SuperTest.Agent): Promise => { const { body: rulesResponse } = await supertest .get(`${DETECTION_ENGINE_RULES_URL_FIND}?per_page=10000`) .set('kbn-xsrf', 'true') diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_prebuilt_rules_and_timelines_status.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_prebuilt_rules_and_timelines_status.ts index 7f683ca9994be..420f8a7aca1ce 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_prebuilt_rules_and_timelines_status.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_prebuilt_rules_and_timelines_status.ts @@ -21,7 +21,7 @@ import { refreshSavedObjectIndices } from '../../refresh_index'; */ export const getPrebuiltRulesAndTimelinesStatus = async ( es: Client, - supertest: SuperTest.SuperTest + supertest: SuperTest.Agent ): Promise => { await refreshSavedObjectIndices(es); diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_prebuilt_rules_fleet_package.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_prebuilt_rules_fleet_package.ts index ec69b6cfb14c2..2441e6f4dbc88 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_prebuilt_rules_fleet_package.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_prebuilt_rules_fleet_package.ts @@ -14,7 +14,7 @@ import type SuperTest from 'supertest'; * @param supertest Supertest instance * @returns The API endpoint response. Will have status 200 if package installed or 404 if not */ -export async function getPrebuiltRulesFleetPackage(supertest: SuperTest.SuperTest) { +export async function getPrebuiltRulesFleetPackage(supertest: SuperTest.Agent) { return await supertest .get(epmRouteService.getInfoPath('security_detection_engine')) .set('kbn-xsrf', 'true') diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_prebuilt_rules_status.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_prebuilt_rules_status.ts index da044637fc77b..10ca202c66f46 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_prebuilt_rules_status.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/get_prebuilt_rules_status.ts @@ -20,7 +20,7 @@ import { refreshSavedObjectIndices } from '../../refresh_index'; */ export const getPrebuiltRulesStatus = async ( es: Client, - supertest: SuperTest.SuperTest + supertest: SuperTest.Agent ): Promise => { await refreshSavedObjectIndices(es); diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_fleet_package_by_url.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_fleet_package_by_url.ts index 863e4d79fb006..b88a848758a8f 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_fleet_package_by_url.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_fleet_package_by_url.ts @@ -26,7 +26,7 @@ const ATTEMPT_TIMEOUT = 120000; export const installPrebuiltRulesPackageViaFleetAPI = async ( es: Client, - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, retryService: RetryService ): Promise => { const fleetResponse = await retryService.tryWithRetries( @@ -66,7 +66,7 @@ export const installPrebuiltRulesPackageViaFleetAPI = async ( export const installPrebuiltRulesPackageByVersion = async ( es: Client, - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, version: string, retryService: RetryService ): Promise => { diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_mock_prebuilt_rules.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_mock_prebuilt_rules.ts index 0e15f416e1238..843d0531e53ba 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_mock_prebuilt_rules.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_mock_prebuilt_rules.ts @@ -19,7 +19,7 @@ import { installPrebuiltRulesAndTimelines } from './install_prebuilt_rules_and_t * @returns Install prebuilt rules response */ export const installMockPrebuiltRules = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, es: Client ): Promise => { // Ensure there are prebuilt rule saved objects before installing rules diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules.ts index 499f97877bf16..eec88072e7d1e 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules.ts @@ -30,7 +30,7 @@ import { refreshSavedObjectIndices } from '../../refresh_index'; */ export const installPrebuiltRules = async ( es: Client, - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, rules?: RuleVersionSpecifier[] ): Promise => { let payload = {}; diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules_and_timelines.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules_and_timelines.ts index c83e8693f2390..a52a44a90bfe7 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules_and_timelines.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules_and_timelines.ts @@ -31,7 +31,7 @@ import { refreshSavedObjectIndices } from '../../refresh_index'; */ export const installPrebuiltRulesAndTimelines = async ( es: Client, - supertest: SuperTest.SuperTest + supertest: SuperTest.Agent ): Promise => { const response = await supertest .put(PREBUILT_RULES_URL) diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules_fleet_package.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules_fleet_package.ts index cbe609501a5f2..f7a7337d40241 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules_fleet_package.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules_fleet_package.ts @@ -36,7 +36,7 @@ export const installPrebuiltRulesFleetPackage = async ({ retryService, }: { es: Client; - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; version?: string; overrideExistingPackage: boolean; retryService: RetryService; diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/review_install_prebuilt_rules.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/review_install_prebuilt_rules.ts index 573b481a3b30f..487d2dbe53044 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/review_install_prebuilt_rules.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/review_install_prebuilt_rules.ts @@ -16,7 +16,7 @@ import type SuperTest from 'supertest'; * @returns Review Install prebuilt rules response */ export const reviewPrebuiltRulesToInstall = async ( - supertest: SuperTest.SuperTest + supertest: SuperTest.Agent ): Promise => { const response = await supertest .post(REVIEW_RULE_INSTALLATION_URL) diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/review_upgrade_prebuilt_rules.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/review_upgrade_prebuilt_rules.ts index 9bbf980dcccca..17347ffcdd1e3 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/review_upgrade_prebuilt_rules.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/review_upgrade_prebuilt_rules.ts @@ -16,7 +16,7 @@ import type SuperTest from 'supertest'; * @returns Review Upgrade prebuilt rules response */ export const reviewPrebuiltRulesToUpgrade = async ( - supertest: SuperTest.SuperTest + supertest: SuperTest.Agent ): Promise => { const response = await supertest .post(REVIEW_RULE_UPGRADE_URL) diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/upgrade_prebuilt_rules.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/upgrade_prebuilt_rules.ts index c22aa9106a272..f12d0adbc65f3 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/upgrade_prebuilt_rules.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/upgrade_prebuilt_rules.ts @@ -26,7 +26,7 @@ import { refreshSavedObjectIndices } from '../../refresh_index'; */ export const upgradePrebuiltRules = async ( es: Client, - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, rules?: RuleVersionSpecifier[] ): Promise => { let payload = {}; diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/preview_rule.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/preview_rule.ts index ec060c4076404..a939454e72c9f 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/preview_rule.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/preview_rule.ts @@ -27,7 +27,7 @@ export const previewRule = async ({ invocationCount = 1, timeframeEnd = new Date(), }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; rule: RuleCreateProps; invocationCount?: number; timeframeEnd?: Date; diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/preview_rule_with_exception_entries.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/preview_rule_with_exception_entries.ts index fb5d480bbbffc..f02a5d370daaa 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/preview_rule_with_exception_entries.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/preview_rule_with_exception_entries.ts @@ -35,7 +35,7 @@ export const previewRuleWithExceptionEntries = async ({ invocationCount, timeframeEnd, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; log: ToolingLog; rule: RuleCreateProps; entries: NonEmptyEntriesArray[]; diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/update_rule.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/update_rule.ts index 5c6c69a230465..cee439311d2a1 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/update_rule.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/update_rule.ts @@ -21,7 +21,7 @@ import { * @param rule The rule to create */ export const updateRule = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, updatedRule: RuleUpdateProps ): Promise => ( diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/telemetry/get_security_telemetry_stats.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/telemetry/get_security_telemetry_stats.ts index 462cdecbb498d..d1345597adc95 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/telemetry/get_security_telemetry_stats.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/telemetry/get_security_telemetry_stats.ts @@ -21,7 +21,7 @@ import { * @returns The detection metrics */ export const getSecurityTelemetryStats = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog ): Promise => { const response = await supertest diff --git a/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/asset_criticality.ts b/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/asset_criticality.ts index 6f13a84504e1d..3a46aa56ef614 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/asset_criticality.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/asset_criticality.ts @@ -104,7 +104,7 @@ export const getAssetCriticalityDoc = async (opts: { }; export const assetCriticalityRouteHelpersFactory = ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, namespace?: string ) => ({ status: async () => @@ -170,7 +170,7 @@ export const assetCriticalityRouteHelpersFactory = ( }); export const assetCriticalityRouteHelpersFactoryNoAuth = ( - supertestWithoutAuth: SuperTest.SuperTest, + supertestWithoutAuth: SuperTest.Agent, namespace?: string ) => ({ privilegesForUser: async ({ username, password }: { username: string; password: string }) => diff --git a/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/get_risk_engine_stats.ts b/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/get_risk_engine_stats.ts index 5629e0da9a89d..fd9ff0eb88177 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/get_risk_engine_stats.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/get_risk_engine_stats.ts @@ -22,7 +22,7 @@ import { getRiskEngineMetricsFromBody } from './get_risk_engine_metrics_from_bod * @returns The detection metrics */ export const getRiskEngineStats = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog ): Promise => { const response = await supertest diff --git a/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/risk_engine.ts b/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/risk_engine.ts index be7010ab1fc7b..dbd4ed78c1896 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/risk_engine.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/risk_engine.ts @@ -76,7 +76,7 @@ export const createAndSyncRuleAndAlertsFactory = log, namespace, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; log: ToolingLog; namespace?: string; }) => @@ -412,7 +412,7 @@ export const clearLegacyDashboards = async ({ supertest, log, }: { - supertest: SuperTest.SuperTest; + supertest: SuperTest.Agent; log: ToolingLog; }): Promise => { try { @@ -481,10 +481,7 @@ export const getLegacyRiskScoreDashboards = async ({ return savedObejectLens?.saved_objects.filter((s) => s?.attributes?.title?.includes('Risk')); }; -export const riskEngineRouteHelpersFactory = ( - supertest: SuperTest.SuperTest, - namespace?: string -) => ({ +export const riskEngineRouteHelpersFactory = (supertest: SuperTest.Agent, namespace?: string) => ({ init: async (expectStatusCode: number = 200) => await supertest .post(routeWithNamespace(RISK_ENGINE_INIT_URL, namespace)) @@ -536,7 +533,7 @@ interface Credentials { } export const riskEngineRouteHelpersFactoryNoAuth = ( - supertestWithoutAuth: SuperTest.SuperTest, + supertestWithoutAuth: SuperTest.Agent, namespace?: string ) => ({ privilegesForUser: async ({ username, password }: Credentials) => @@ -576,11 +573,7 @@ export const riskEngineRouteHelpersFactoryNoAuth = ( .expect(expectStatusCode), }); -export const installLegacyRiskScore = async ({ - supertest, -}: { - supertest: SuperTest.SuperTest; -}) => { +export const installLegacyRiskScore = async ({ supertest }: { supertest: SuperTest.Agent }) => { await supertest .post('/internal/risk_score') .set('kbn-xsrf', 'true') diff --git a/x-pack/test/security_solution_api_integration/test_suites/genai/invoke_ai/utils/create_connector.ts b/x-pack/test/security_solution_api_integration/test_suites/genai/invoke_ai/utils/create_connector.ts index ac2d60ad631e2..0c7823ef07885 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/genai/invoke_ai/utils/create_connector.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/genai/invoke_ai/utils/create_connector.ts @@ -45,7 +45,7 @@ const connectorSetup = { * @param spaceId The space id */ export const createConnector = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, objectRemover: ObjectRemover, apiUrl: string, connectorType: 'bedrock' | 'openai', diff --git a/x-pack/test/security_solution_api_integration/test_suites/genai/invoke_ai/utils/post_actions_client_execute.ts b/x-pack/test/security_solution_api_integration/test_suites/genai/invoke_ai/utils/post_actions_client_execute.ts index 0477401a26533..b5ed8c15b3fb2 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/genai/invoke_ai/utils/post_actions_client_execute.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/genai/invoke_ai/utils/post_actions_client_execute.ts @@ -21,7 +21,7 @@ import { Response } from 'superagent'; export const postActionsClientExecute = async ( connectorId: string, args: any, - supertest: SuperTest.SuperTest + supertest: SuperTest.Agent ): Promise => { const response = await supertest .post(`/internal/elastic_assistant/actions/connector/${connectorId}/_execute`) diff --git a/x-pack/test/security_solution_api_integration/test_suites/investigation/saved_objects/trial_license_complete_tier/helpers.ts b/x-pack/test/security_solution_api_integration/test_suites/investigation/saved_objects/trial_license_complete_tier/helpers.ts index 38212020ba18a..1f1a4bb821082 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/investigation/saved_objects/trial_license_complete_tier/helpers.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/investigation/saved_objects/trial_license_complete_tier/helpers.ts @@ -9,10 +9,7 @@ import type SuperTest from 'supertest'; import { v4 as uuidv4 } from 'uuid'; import { TimelineType } from '@kbn/security-solution-plugin/common/api/timeline'; -export const createBasicTimeline = async ( - supertest: SuperTest.SuperTest, - titleToSaved: string -) => +export const createBasicTimeline = async (supertest: SuperTest.Agent, titleToSaved: string) => await supertest .post('/api/timeline') .set('kbn-xsrf', 'true') @@ -25,7 +22,7 @@ export const createBasicTimeline = async ( }); export const createBasicTimelineTemplate = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, titleToSaved: string ) => await supertest diff --git a/x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/utils.ts b/x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/utils.ts index d45a77be0840b..c4bde53fcab7d 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/utils.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/utils.ts @@ -41,7 +41,7 @@ import { countDownTest } from '../../../common/utils/security_solution'; * @param supertest The supertest client library */ export const createListsIndex = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog ): Promise => { return countDownTest( @@ -61,7 +61,7 @@ export const createListsIndex = async ( * @param supertest The supertest client library */ export const deleteListsIndex = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog ): Promise => { return countDownTest( @@ -82,7 +82,7 @@ export const deleteListsIndex = async ( * @param supertest The supertest client library */ export const createExceptionListsIndex = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog ): Promise => { return countDownTest( @@ -205,7 +205,7 @@ export const binaryToString = (res: any, callback: any): void => { * @param supertest The supertest handle */ export const deleteAllExceptions = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog ): Promise => { await deleteAllExceptionsByType(supertest, log, 'single'); @@ -218,7 +218,7 @@ export const deleteAllExceptions = async ( * @param supertest The supertest handle */ export const deleteAllExceptionsByType = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, type: NamespaceType ): Promise => { @@ -260,7 +260,7 @@ export const deleteAllExceptionsByType = async ( * @param testValues Optional test values in case you're using CIDR or range based lists */ export const importFile = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, type: Type, contents: string[], @@ -297,7 +297,7 @@ export const importFile = async ( * @param fileName filename to import as */ export const importTextFile = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, type: Type, contents: string[], @@ -330,7 +330,7 @@ export const importTextFile = async ( * @param itemValue The item value to wait for */ export const waitForListItem = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, itemValue: string, fileName: string @@ -362,7 +362,7 @@ export const waitForListItem = async ( * @param itemValue The item value to wait for */ export const waitForListItems = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, itemValues: string[], fileName: string @@ -378,7 +378,7 @@ export const waitForListItems = async ( * @param itemValue The item value to wait for */ export const waitForTextListItem = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, itemValue: string, fileName: string @@ -417,7 +417,7 @@ export const waitForTextListItem = async ( * @param itemValue The item value to wait for */ export const waitForTextListItems = async ( - supertest: SuperTest.SuperTest, + supertest: SuperTest.Agent, log: ToolingLog, itemValues: string[], fileName: string diff --git a/x-pack/test/spaces_api_integration/common/lib/create_users_and_roles.ts b/x-pack/test/spaces_api_integration/common/lib/create_users_and_roles.ts index 15ee9785aa690..58ef5ba9f9481 100644 --- a/x-pack/test/spaces_api_integration/common/lib/create_users_and_roles.ts +++ b/x-pack/test/spaces_api_integration/common/lib/create_users_and_roles.ts @@ -5,11 +5,11 @@ * 2.0. */ -import { SuperTest } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import type { Client } from '@elastic/elasticsearch'; import { AUTHENTICATION } from './authentication'; -export const createUsersAndRoles = async (es: Client, supertest: SuperTest) => { +export const createUsersAndRoles = async (es: Client, supertest: SuperTestAgent) => { await supertest .put('/api/security/role/kibana_legacy_user') .send({ diff --git a/x-pack/test/spaces_api_integration/common/suites/disable_legacy_url_aliases.ts b/x-pack/test/spaces_api_integration/common/suites/disable_legacy_url_aliases.ts index 002ed6c3e6515..5889a10479f31 100644 --- a/x-pack/test/spaces_api_integration/common/suites/disable_legacy_url_aliases.ts +++ b/x-pack/test/spaces_api_integration/common/suites/disable_legacy_url_aliases.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { SuperTest } from 'supertest'; +import type { Agent as SuperTestAgent } from 'supertest'; import type { Client } from '@elastic/elasticsearch'; import type { LegacyUrlAlias } from '@kbn/core-saved-objects-base-server-internal'; import { MAIN_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server'; @@ -48,7 +48,7 @@ const getTestTitle = ({ targetSpace, targetType, sourceId }: DisableLegacyUrlAli export function disableLegacyUrlAliasesTestSuiteFactory( es: Client, esArchiver: any, - supertest: SuperTest + supertest: SuperTestAgent ) { const expectResponseBody = (testCase: DisableLegacyUrlAliasesTestCase, statusCode: 204 | 403): ExpectResponseBody => @@ -117,7 +117,7 @@ export function disableLegacyUrlAliasesTestSuiteFactory( const requestBody = test.request; await supertest .post(`${getUrlPrefix(spaceId)}/api/spaces/_disable_legacy_url_aliases`) - .auth(user?.username, user?.password) + .auth(user?.username!, user?.password!) .send(requestBody) .expect(test.responseStatusCode) .then(test.responseBody); diff --git a/x-pack/test/spaces_api_integration/common/suites/get_shareable_references.ts b/x-pack/test/spaces_api_integration/common/suites/get_shareable_references.ts index bedc8a52409b6..c1630bc288169 100644 --- a/x-pack/test/spaces_api_integration/common/suites/get_shareable_references.ts +++ b/x-pack/test/spaces_api_integration/common/suites/get_shareable_references.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { deepFreeze } from '@kbn/std'; -import { SuperTest } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { SavedObjectsCollectMultiNamespaceReferencesResponse, SavedObjectReferenceWithContext, @@ -192,7 +192,7 @@ const getRedactedSpaces = (authorizedSpace: string | undefined, spaces: string[] return redactedSpaces.sort((a, b) => (a === '?' ? 1 : b === '?' ? -1 : 0)); // unknown spaces are always at the end of the array }; -export function getShareableReferencesTestSuiteFactory(esArchiver: any, supertest: SuperTest) { +export function getShareableReferencesTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) { const expectForbidden = expectResponses.forbiddenTypes('share_to_space'); const expectResponseBody = ( @@ -274,7 +274,7 @@ export function getShareableReferencesTestSuiteFactory(esArchiver: any, supertes const requestBody = test.request; await supertest .post(`${getUrlPrefix(spaceId)}/api/spaces/_get_shareable_references`) - .auth(user?.username, user?.password) + .auth(user?.username!, user?.password!) .send(requestBody) .expect(test.responseStatusCode) .then(test.responseBody); diff --git a/x-pack/test/spaces_api_integration/common/suites/update_objects_spaces.ts b/x-pack/test/spaces_api_integration/common/suites/update_objects_spaces.ts index 14eb97c38c6ee..777581d9aa5a0 100644 --- a/x-pack/test/spaces_api_integration/common/suites/update_objects_spaces.ts +++ b/x-pack/test/spaces_api_integration/common/suites/update_objects_spaces.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import type { Client } from '@elastic/elasticsearch'; import type { SearchTotalHits } from '@elastic/elasticsearch/lib/api/types'; import { without, uniq } from 'lodash'; -import { SuperTest } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { SavedObjectsErrorHelpers, SavedObjectsUpdateObjectsSpacesResponse, @@ -61,7 +61,7 @@ const getTestTitle = ({ objects, spacesToAdd, spacesToRemove }: UpdateObjectsSpa export function updateObjectsSpacesTestSuiteFactory( es: Client, esArchiver: any, - supertest: SuperTest + supertest: SuperTestAgent ) { const expectForbidden = expectResponses.forbiddenTypes('share_to_space'); const expectResponseBody = @@ -162,7 +162,7 @@ export function updateObjectsSpacesTestSuiteFactory( const requestBody = test.request; await supertest .post(`${getUrlPrefix(spaceId)}/api/spaces/_update_objects_spaces`) - .auth(user?.username, user?.password) + .auth(user?.username!, user?.password!) .send(requestBody) .expect(test.responseStatusCode) .then(test.responseBody); diff --git a/x-pack/test_serverless/api_integration/services/svl_cases/api.ts b/x-pack/test_serverless/api_integration/services/svl_cases/api.ts index 8f23eba1ea981..7089655551fbe 100644 --- a/x-pack/test_serverless/api_integration/services/svl_cases/api.ts +++ b/x-pack/test_serverless/api_integration/services/svl_cases/api.ts @@ -141,7 +141,7 @@ export function SvlCasesApiServiceProvider({ getService }: FtrProviderContext) { params: CasePostRequest, expectedHttpCode: number = 200, auth: { user: User; space: string | null } | null = { user: superUser, space: null }, - headers: Record = {} + headers: Record = {} ): Promise { const apiCall = supertest.post(`${CASES_URL}`); diff --git a/x-pack/test_serverless/api_integration/services/transform/api.ts b/x-pack/test_serverless/api_integration/services/transform/api.ts index 39c2d01c6adb1..c865dcec6e8a0 100644 --- a/x-pack/test_serverless/api_integration/services/transform/api.ts +++ b/x-pack/test_serverless/api_integration/services/transform/api.ts @@ -217,7 +217,7 @@ export function TransformAPIProvider({ getService }: FtrProviderContext) { ); const { body, status } = await esSupertest .put(`/_transform/${transformId}${deferValidation ? '?defer_validation=true' : ''}`) - .set(headers) + .set(headers as Record) .send(transformConfig); this.assertResponseStatusCode(200, status, body); } else { diff --git a/x-pack/test_serverless/api_integration/test_suites/common/alerting/helpers/alerting_api_helper.ts b/x-pack/test_serverless/api_integration/test_suites/common/alerting/helpers/alerting_api_helper.ts index bd8c64bed6731..88f3f1a76d3bb 100644 --- a/x-pack/test_serverless/api_integration/test_suites/common/alerting/helpers/alerting_api_helper.ts +++ b/x-pack/test_serverless/api_integration/test_suites/common/alerting/helpers/alerting_api_helper.ts @@ -6,7 +6,7 @@ */ import moment from 'moment'; -import type { SuperTest, Test } from 'supertest'; +import type { Agent as SuperTestAgent } from 'supertest'; interface CreateEsQueryRuleParams { size: number; @@ -32,7 +32,7 @@ export async function createIndexConnector({ name, indexName, }: { - supertest: SuperTest; + supertest: SuperTestAgent; name: string; indexName: string; }) { @@ -56,7 +56,7 @@ export async function createSlackConnector({ supertest, name, }: { - supertest: SuperTest; + supertest: SuperTestAgent; name: string; }) { const { body } = await supertest @@ -87,7 +87,7 @@ export async function createEsQueryRule({ notifyWhen, enabled = true, }: { - supertest: SuperTest; + supertest: SuperTestAgent; ruleTypeId: string; name: string; params: CreateEsQueryRuleParams; @@ -134,7 +134,7 @@ export async function createAnomalyRule({ ruleTypeId = 'apm.anomaly', params, }: { - supertest: SuperTest; + supertest: SuperTestAgent; name?: string; consumer?: string; actions?: any[]; @@ -184,7 +184,7 @@ export async function createLatencyThresholdRule({ ruleTypeId = 'apm.transaction_duration', params, }: { - supertest: SuperTest; + supertest: SuperTestAgent; name?: string; consumer?: string; actions?: any[]; @@ -233,7 +233,7 @@ export async function createInventoryRule({ ruleTypeId = 'metrics.alert.inventory.threshold', params, }: { - supertest: SuperTest; + supertest: SuperTestAgent; name?: string; consumer?: string; actions?: any[]; @@ -287,7 +287,7 @@ export async function disableRule({ supertest, ruleId, }: { - supertest: SuperTest; + supertest: SuperTestAgent; ruleId: string; }) { const { body } = await supertest @@ -303,7 +303,7 @@ export async function updateEsQueryRule({ ruleId, updates, }: { - supertest: SuperTest; + supertest: SuperTestAgent; ruleId: string; updates: any; }) { @@ -341,7 +341,7 @@ export async function runRule({ supertest, ruleId, }: { - supertest: SuperTest; + supertest: SuperTestAgent; ruleId: string; }) { const response = await supertest @@ -356,7 +356,7 @@ export async function muteRule({ supertest, ruleId, }: { - supertest: SuperTest; + supertest: SuperTestAgent; ruleId: string; }) { const { body } = await supertest @@ -371,7 +371,7 @@ export async function enableRule({ supertest, ruleId, }: { - supertest: SuperTest; + supertest: SuperTestAgent; ruleId: string; }) { const { body } = await supertest @@ -387,7 +387,7 @@ export async function muteAlert({ ruleId, alertId, }: { - supertest: SuperTest; + supertest: SuperTestAgent; ruleId: string; alertId: string; }) { @@ -403,7 +403,7 @@ export async function unmuteRule({ supertest, ruleId, }: { - supertest: SuperTest; + supertest: SuperTestAgent; ruleId: string; }) { const { body } = await supertest @@ -418,7 +418,7 @@ export async function snoozeRule({ supertest, ruleId, }: { - supertest: SuperTest; + supertest: SuperTestAgent; ruleId: string; }) { const { body } = await supertest @@ -443,7 +443,7 @@ export async function findRule({ supertest, ruleId, }: { - supertest: SuperTest; + supertest: SuperTestAgent; ruleId: string; }) { if (!ruleId) { diff --git a/x-pack/test_serverless/api_integration/test_suites/common/alerting/helpers/alerting_wait_for_helpers.ts b/x-pack/test_serverless/api_integration/test_suites/common/alerting/helpers/alerting_wait_for_helpers.ts index 00b746697cd23..55bfa422c5f4b 100644 --- a/x-pack/test_serverless/api_integration/test_suites/common/alerting/helpers/alerting_wait_for_helpers.ts +++ b/x-pack/test_serverless/api_integration/test_suites/common/alerting/helpers/alerting_wait_for_helpers.ts @@ -6,7 +6,7 @@ */ import pRetry from 'p-retry'; -import type { SuperTest, Test } from 'supertest'; +import type { Agent as SuperTestAgent } from 'supertest'; import type { Client } from '@elastic/elasticsearch'; import type { AggregationsAggregate, @@ -372,7 +372,7 @@ export async function waitForNumRuleRuns({ esClient, testStart, }: { - supertest: SuperTest; + supertest: SuperTestAgent; numOfRuns: number; ruleId: string; esClient: Client; diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/apm_api_integration/common/apm_api_supertest.ts b/x-pack/test_serverless/api_integration/test_suites/observability/apm_api_integration/common/apm_api_supertest.ts index ac324b3fda087..62db8c2eddda4 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/apm_api_integration/common/apm_api_supertest.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/apm_api_integration/common/apm_api_supertest.ts @@ -16,7 +16,7 @@ import type { APIEndpoint } from '@kbn/apm-plugin/server'; import { formatRequest } from '@kbn/server-route-repository'; import { InheritedFtrProviderContext } from '../../../../services'; -export function createApmApiClient(st: supertest.SuperTest) { +export function createApmApiClient(st: supertest.Agent) { return async ( options: { type?: 'form-data'; diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/dataset_quality_api_integration/common/dataset_quality_api_supertest.ts b/x-pack/test_serverless/api_integration/test_suites/observability/dataset_quality_api_integration/common/dataset_quality_api_supertest.ts index 2cdb6ec4fd765..f1d746b49ff06 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/dataset_quality_api_integration/common/dataset_quality_api_supertest.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/dataset_quality_api_integration/common/dataset_quality_api_supertest.ts @@ -13,7 +13,7 @@ import type { APIEndpoint } from '@kbn/dataset-quality-plugin/server/routes'; import { formatRequest } from '@kbn/server-route-repository'; import { InheritedFtrProviderContext } from '../../../../services'; -export function createDatasetQualityApiClient(st: supertest.SuperTest) { +export function createDatasetQualityApiClient(st: supertest.Agent) { return async ( options: { type?: 'form-data'; diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/synthetics/synthetics_enablement.ts b/x-pack/test_serverless/api_integration/test_suites/observability/synthetics/synthetics_enablement.ts index fae09f97cf2a2..9925c00fe5748 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/synthetics/synthetics_enablement.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/synthetics/synthetics_enablement.ts @@ -65,7 +65,7 @@ export default function ({ getService }: FtrProviderContext) { async function enablementPut(role: RoleName = 'admin', expectedStatus: number = 200) { return supertestWithoutAuth .put(SYNTHETICS_API_URLS.SYNTHETICS_ENABLEMENT) - .set(internalRequestHeader) + .set(internalRequestHeader as unknown as Record) .set(await svlUserManager.getApiCredentialsForRole(role)) .expect(expectedStatus); } @@ -73,7 +73,7 @@ export default function ({ getService }: FtrProviderContext) { async function enablementDelete(role: RoleName = 'admin', expectedStatus: number = 200) { return supertestWithoutAuth .delete(SYNTHETICS_API_URLS.SYNTHETICS_ENABLEMENT) - .set(internalRequestHeader) + .set(internalRequestHeader as unknown as Record) .set(await svlUserManager.getApiCredentialsForRole(role)) .expect(expectedStatus); } diff --git a/x-pack/test_serverless/shared/lib/object_remover.ts b/x-pack/test_serverless/shared/lib/object_remover.ts index ad029ca579cbd..ef43c70d0ee49 100644 --- a/x-pack/test_serverless/shared/lib/object_remover.ts +++ b/x-pack/test_serverless/shared/lib/object_remover.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SuperTest, Test } from 'supertest'; +import { Agent as SuperTestAgent } from 'supertest'; import { getUrlPathPrefixForSpace } from './space_path_prefix'; @@ -18,10 +18,10 @@ interface ObjectToRemove { } export class ObjectRemover { - private readonly supertest: SuperTest; + private readonly supertest: SuperTestAgent; private objectsToRemove: ObjectToRemove[] = []; - constructor(supertest: SuperTest) { + constructor(supertest: SuperTestAgent) { this.supertest = supertest; } @@ -60,7 +60,7 @@ export class ObjectRemover { } interface DeleteObjectParams { - supertest: SuperTest; + supertest: SuperTestAgent; url: string; plugin: string; } diff --git a/x-pack/test_serverless/shared/services/bsearch_secure.ts b/x-pack/test_serverless/shared/services/bsearch_secure.ts index 2493c1d76e09c..14a373ab99686 100644 --- a/x-pack/test_serverless/shared/services/bsearch_secure.ts +++ b/x-pack/test_serverless/shared/services/bsearch_secure.ts @@ -25,7 +25,7 @@ const parseBfetchResponse = (resp: request.Response): Array> }; interface SendOptions { - supertestWithoutAuth: SuperTest.SuperTest; + supertestWithoutAuth: SuperTest.Agent; apiKeyHeader: { Authorization: string }; referer?: string; kibanaVersion?: string; diff --git a/yarn.lock b/yarn.lock index cf2d9e2fb8052..195b869f022c5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9555,10 +9555,10 @@ dependencies: "@types/node" "*" -"@types/cookiejar@*": - version "2.1.2" - resolved "https://registry.yarnpkg.com/@types/cookiejar/-/cookiejar-2.1.2.tgz#66ad9331f63fe8a3d3d9d8c6e3906dd10f6446e8" - integrity sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog== +"@types/cookiejar@^2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@types/cookiejar/-/cookiejar-2.1.5.tgz#14a3e83fa641beb169a2dd8422d91c3c345a9a78" + integrity sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q== "@types/cytoscape@^3.14.0": version "3.14.0" @@ -10163,6 +10163,11 @@ resolved "https://registry.yarnpkg.com/@types/mdurl/-/mdurl-1.0.2.tgz#e2ce9d83a613bacf284c7be7d491945e39e1f8e9" integrity sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA== +"@types/methods@^1.1.4": + version "1.1.4" + resolved "https://registry.yarnpkg.com/@types/methods/-/methods-1.1.4.tgz#d3b7ac30ac47c91054ea951ce9eed07b1051e547" + integrity sha512-ymXWVrDiCxTBE3+RIrrP533E70eA+9qu7zdWoHuOmGujkYtzf4HQF96b8nwHLqhuf4ykX61IGRIB38CC6/sImQ== + "@types/micromatch@^4.0.2": version "4.0.2" resolved "https://registry.yarnpkg.com/@types/micromatch/-/micromatch-4.0.2.tgz#ce29c8b166a73bf980a5727b1e4a4d099965151d" @@ -10701,20 +10706,22 @@ resolved "https://registry.yarnpkg.com/@types/stylis/-/stylis-4.2.0.tgz#199a3f473f0c3a6f6e4e1b17cdbc967f274bdc6b" integrity sha512-n4sx2bqL0mW1tvDf/loQ+aMX7GQD3lc3fkCMC55VFNDu/vBOabO+LTIeXKM14xK0ppk5TUGcWRjiSpIlUpghKw== -"@types/superagent@*": - version "3.8.4" - resolved "https://registry.yarnpkg.com/@types/superagent/-/superagent-3.8.4.tgz#24a5973c7d1a9c024b4bbda742a79267c33fb86a" - integrity sha512-Dnh0Iw6NO55z1beXvlsvUrfk4cd9eL2nuTmUk+rAhSVCk10PGGFbqCCTwbau9D0d2W3DITiXl4z8VCqppGkMPQ== +"@types/superagent@^8.1.0": + version "8.1.7" + resolved "https://registry.yarnpkg.com/@types/superagent/-/superagent-8.1.7.tgz#1153819ed4db34427409a1cc58f3e2f13eeec862" + integrity sha512-NmIsd0Yj4DDhftfWvvAku482PZum4DBW7U51OvS8gvOkDDY0WT1jsVyDV3hK+vplrsYw8oDwi9QxOM7U68iwww== dependencies: - "@types/cookiejar" "*" + "@types/cookiejar" "^2.1.5" + "@types/methods" "^1.1.4" "@types/node" "*" -"@types/supertest@^2.0.12": - version "2.0.12" - resolved "https://registry.yarnpkg.com/@types/supertest/-/supertest-2.0.12.tgz#ddb4a0568597c9aadff8dbec5b2e8fddbe8692fc" - integrity sha512-X3HPWTwXRerBZS7Mo1k6vMVR1Z6zmJcDVn5O/31whe0tnjE4te6ZJSJGq1RiqHPjzPdMTfjCFogDJmwng9xHaQ== +"@types/supertest@^6.0.2": + version "6.0.2" + resolved "https://registry.yarnpkg.com/@types/supertest/-/supertest-6.0.2.tgz#2af1c466456aaf82c7c6106c6b5cbd73a5e86588" + integrity sha512-137ypx2lk/wTQbW6An6safu9hXmajAifU/s7szAHLN/FeIm5w7yR0Wkl9fdJMRSHwOn4HLAI0DaB2TOORuhPDg== dependencies: - "@types/superagent" "*" + "@types/methods" "^1.1.4" + "@types/superagent" "^8.1.0" "@types/tapable@^1", "@types/tapable@^1.0.5", "@types/tapable@^1.0.6": version "1.0.6" @@ -17726,15 +17733,14 @@ formdata-polyfill@^4.0.10: dependencies: fetch-blob "^3.1.2" -formidable@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/formidable/-/formidable-2.1.2.tgz#fa973a2bec150e4ce7cac15589d7a25fc30ebd89" - integrity sha512-CM3GuJ57US06mlpQ47YcunuUZ9jpm8Vx+P2CGt2j7HpgkKZO/DJYQ0Bobim8G6PFQmK5lOqOOdUXboU+h73A4g== +formidable@^3.5.1: + version "3.5.1" + resolved "https://registry.yarnpkg.com/formidable/-/formidable-3.5.1.tgz#9360a23a656f261207868b1484624c4c8d06ee1a" + integrity sha512-WJWKelbRHN41m5dumb0/k8TeAx7Id/y3a+Z7QfhxP/htI9Js5zYaEDtG8uMgG0vM0lOlqnmjE99/kfpOYi/0Og== dependencies: dezalgo "^1.0.4" hexoid "^1.0.0" once "^1.4.0" - qs "^6.11.0" formik@^2.4.5: version "2.4.5" @@ -27655,7 +27661,7 @@ semver@7.5.4: dependencies: lru-cache "^6.0.0" -semver@7.6.0, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.0, semver@^7.5.2, semver@^7.5.3, semver@^7.5.4: +semver@7.6.0, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.5.0, semver@^7.5.2, semver@^7.5.3, semver@^7.5.4: version "7.6.0" resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d" integrity sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg== @@ -29098,21 +29104,20 @@ stylus-lookup@^5.0.1: dependencies: commander "^10.0.1" -superagent@^8.0.5, superagent@^8.1.2: - version "8.1.2" - resolved "https://registry.yarnpkg.com/superagent/-/superagent-8.1.2.tgz#03cb7da3ec8b32472c9d20f6c2a57c7f3765f30b" - integrity sha512-6WTxW1EB6yCxV5VFOIPQruWGHqc3yI7hEmZK6h+pyk69Lk/Ut7rLUY6W/ONF2MjBuGjvmMiIpsrVJ2vjrHlslA== +superagent@^9.0.1, superagent@^9.0.2: + version "9.0.2" + resolved "https://registry.yarnpkg.com/superagent/-/superagent-9.0.2.tgz#a18799473fc57557289d6b63960610e358bdebc1" + integrity sha512-xuW7dzkUpcJq7QnhOsnNUgtYp3xRwpt2F7abdRYIpCsAt0hhUqia0EdxyXZQQpNmGtsCzYHryaKSV3q3GJnq7w== dependencies: component-emitter "^1.3.0" cookiejar "^2.1.4" debug "^4.3.4" fast-safe-stringify "^2.1.1" form-data "^4.0.0" - formidable "^2.1.2" + formidable "^3.5.1" methods "^1.1.2" mime "2.6.0" qs "^6.11.0" - semver "^7.3.8" supercluster@^8.0.1: version "8.0.1" @@ -29128,13 +29133,13 @@ superjson@^1.10.0: dependencies: copy-anything "^3.0.2" -supertest@^6.3.3: - version "6.3.3" - resolved "https://registry.yarnpkg.com/supertest/-/supertest-6.3.3.tgz#42f4da199fee656106fd422c094cf6c9578141db" - integrity sha512-EMCG6G8gDu5qEqRQ3JjjPs6+FYT1a7Hv5ApHvtSghmOFJYtsU5S+pSb6Y2EUeCEY3CmEL3mmQ8YWlPOzQomabA== +supertest@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/supertest/-/supertest-7.0.0.tgz#cac53b3d6872a0b317980b2b0cfa820f09cd7634" + integrity sha512-qlsr7fIC0lSddmA3tzojvzubYxvlGtzumcdHgPwbFWMISQwL22MhM2Y3LNt+6w9Yyx7559VW5ab70dgphm8qQA== dependencies: methods "^1.1.2" - superagent "^8.0.5" + superagent "^9.0.1" supports-color@8.1.1, supports-color@^8.0.0, supports-color@^8.1.1: version "8.1.1"