Update supertest and superagent to latest version (#183587)

## Summary

Related to https://github.com/elastic/kibana/issues/7104

Update supertest, superagent, and the corresponding type package, to
their latest version.

(of course, types had some signature changes and we're massively using
supertest in all our FTR suites so the whole Kibana multiverse has to
review it)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Pierre Gayvallet 2024-05-17 13:23:21 +02:00 committed by GitHub
parent 4b7d014582
commit 148eeec0fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
153 changed files with 439 additions and 431 deletions

View file

@ -1523,7 +1523,7 @@
"@types/source-map-support": "^0.5.3", "@types/source-map-support": "^0.5.3",
"@types/stats-lite": "^2.2.0", "@types/stats-lite": "^2.2.0",
"@types/styled-components": "^5.1.0", "@types/styled-components": "^5.1.0",
"@types/supertest": "^2.0.12", "@types/supertest": "^6.0.2",
"@types/tapable": "^1.0.6", "@types/tapable": "^1.0.6",
"@types/tar": "^6.1.11", "@types/tar": "^6.1.11",
"@types/testing-library__jest-dom": "^5.14.7", "@types/testing-library__jest-dom": "^5.14.7",
@ -1697,8 +1697,8 @@
"style-loader": "^1.1.3", "style-loader": "^1.1.3",
"stylelint": "^14.9.1", "stylelint": "^14.9.1",
"stylelint-scss": "^4.3.0", "stylelint-scss": "^4.3.0",
"superagent": "^8.1.2", "superagent": "^9.0.2",
"supertest": "^6.3.3", "supertest": "^7.0.0",
"svgo": "^2.8.0", "svgo": "^2.8.0",
"table": "^6.8.1", "table": "^6.8.1",
"tape": "^5.0.1", "tape": "^5.0.1",

View file

@ -1622,7 +1622,7 @@ describe('setup contract', () => {
.get('/static/some_json.json') .get('/static/some_json.json')
.expect(200); .expect(200);
const etag = response.get('etag'); const etag = response.get('etag')!;
expect(etag).not.toBeUndefined(); expect(etag).not.toBeUndefined();
await supertest(innerServer.listener) await supertest(innerServer.listener)

View file

@ -28,7 +28,7 @@ describe('BasePathProxyServer', () => {
let logger: TestLog; let logger: TestLog;
let config: IHttpConfig; let config: IHttpConfig;
let basePath: string; let basePath: string;
let proxySupertest: supertest.SuperTest<supertest.Test>; let proxySupertest: supertest.Agent;
beforeEach(async () => { beforeEach(async () => {
logger = new TestLog(); logger = new TestLog();
@ -330,7 +330,7 @@ describe('BasePathProxyServer', () => {
describe('shouldRedirect', () => { describe('shouldRedirect', () => {
let proxyServerWithoutShouldRedirect: BasePathProxyServer; let proxyServerWithoutShouldRedirect: BasePathProxyServer;
let proxyWithoutShouldRedirectSupertest: supertest.SuperTest<supertest.Test>; let proxyWithoutShouldRedirectSupertest: supertest.Agent;
beforeEach(async () => { beforeEach(async () => {
// setup and start a proxy server which does not use "shouldRedirectFromOldBasePath" // 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', () => { describe('constructor option for sending in a custom basePath', () => {
let proxyServerWithFooBasePath: BasePathProxyServer; let proxyServerWithFooBasePath: BasePathProxyServer;
let proxyWithFooBasePath: supertest.SuperTest<supertest.Test>; let proxyWithFooBasePath: supertest.Agent;
beforeEach(async () => { beforeEach(async () => {
// setup and start a proxy server which uses a basePath of "foo" // setup and start a proxy server which uses a basePath of "foo"

View file

@ -134,7 +134,7 @@ describe('Cookie based SessionStorage', () => {
const response = await supertest(innerServer.listener).get('/').expect(200); 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).toBeDefined();
expect(cookies).toHaveLength(1); expect(cookies).toHaveLength(1);
@ -172,7 +172,7 @@ describe('Cookie based SessionStorage', () => {
const response = await supertest(innerServer.listener).get('/').expect(200); 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).toBeDefined();
expect(cookies).toHaveLength(1); expect(cookies).toHaveLength(1);
@ -204,7 +204,7 @@ describe('Cookie based SessionStorage', () => {
const response = await supertest(innerServer.listener).get('/').expect(200, { value: null }); 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(); expect(cookies).not.toBeDefined();
}); });
@ -237,7 +237,7 @@ describe('Cookie based SessionStorage', () => {
.get('/') .get('/')
.expect(200, { value: userData }); .expect(200, { value: userData });
const cookies = response.get('set-cookie'); const cookies = response.get('set-cookie')!;
expect(cookies).toBeDefined(); expect(cookies).toBeDefined();
await delay(sessionDurationMs); await delay(sessionDurationMs);
@ -283,7 +283,7 @@ describe('Cookie based SessionStorage', () => {
.get('/') .get('/')
.expect(200, { value: userData }); .expect(200, { value: userData });
const cookies = response.get('set-cookie'); const cookies = response.get('set-cookie')!;
expect(cookies).toBeDefined(); expect(cookies).toBeDefined();
const sessionCookie = retrieveSessionCookie(cookies[0]); const sessionCookie = retrieveSessionCookie(cookies[0]);
@ -418,7 +418,7 @@ describe('Cookie based SessionStorage', () => {
const response = await supertest(innerServer.listener).get('/').expect(200); 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 sessionCookie = retrieveSessionCookie(cookies[0]);
const response2 = await supertest(innerServer.listener) const response2 = await supertest(innerServer.listener)
@ -475,7 +475,7 @@ describe('Cookie based SessionStorage', () => {
const response = await supertest(innerServer.listener).get('/').expect(200); 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).toBeDefined();
expect(cookies).toHaveLength(1); expect(cookies).toHaveLength(1);

View file

@ -29,7 +29,7 @@ interface AdditionalOptions {
describe('Routing versioned requests', () => { describe('Routing versioned requests', () => {
let router: IRouter; let router: IRouter;
let supertest: Supertest.SuperTest<Supertest.Test>; let supertest: Supertest.Agent;
async function setupServer(cliArgs: Partial<CliArgs> = {}, options: AdditionalOptions = {}) { async function setupServer(cliArgs: Partial<CliArgs> = {}, options: AdditionalOptions = {}) {
logger = loggingSystemMock.create(); logger = loggingSystemMock.create();

View file

@ -116,7 +116,7 @@ describe('ServerMetricsCollector', () => {
// Subscribe to the aborted$ event // Subscribe to the aborted$ event
const waitFor1stAbort = disconnectAborted$.pipe(take(1)).toPromise(); const waitFor1stAbort = disconnectAborted$.pipe(take(1)).toPromise();
discoReq1.abort(); void discoReq1.abort();
// Wait for the aborted$ event // Wait for the aborted$ event
await waitFor1stAbort; await waitFor1stAbort;
@ -132,7 +132,7 @@ describe('ServerMetricsCollector', () => {
// Subscribe to the aborted$ event // Subscribe to the aborted$ event
const waitFor2ndAbort = disconnectAborted$.pipe(take(1)).toPromise(); const waitFor2ndAbort = disconnectAborted$.pipe(take(1)).toPromise();
discoReq2.abort(); void discoReq2.abort();
// Wait for the aborted$ event // Wait for the aborted$ event
await waitFor2ndAbort; await waitFor2ndAbort;

View file

@ -70,7 +70,7 @@ export default function ({ getService }: FtrProviderContext) {
await supertest await supertest
.get(FIELDS_PATH) .get(FIELDS_PATH)
.set('If-None-Match', response.get('etag')) .set('If-None-Match', response.get('etag')!)
.query({ .query({
pattern: '*', pattern: '*',
include_unmapped: true, include_unmapped: true,

View file

@ -6,7 +6,6 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
import { SuperTest, Test } from 'supertest';
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context'; 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']; const defaultTypes = ['visualization', 'index-pattern', 'search', 'dashboard'];
export default function ({ getService }: FtrProviderContext) { export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest') as SuperTest<Test>; const supertest = getService('supertest');
const kibanaServer = getService('kibanaServer'); const kibanaServer = getService('kibanaServer');
const esArchiver = getService('esArchiver'); const esArchiver = getService('esArchiver');

View file

@ -87,7 +87,7 @@ export default function optInTest({ getService }: FtrProviderContext) {
} }
async function postTelemetryV2OptIn( async function postTelemetryV2OptIn(
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
value: unknown, value: unknown,
statusCode: number statusCode: number
): Promise<any> { ): Promise<any> {

View file

@ -13,13 +13,15 @@ import { format as formatUrl } from 'url';
import supertest from 'supertest'; import supertest from 'supertest';
import { FtrProviderContext } from '../../functional/ftr_provider_context'; import { FtrProviderContext } from '../../functional/ftr_provider_context';
export function KibanaSupertestProvider({ getService }: FtrProviderContext) { export function KibanaSupertestProvider({ getService }: FtrProviderContext): supertest.Agent {
const config = getService('config'); const config = getService('config');
const kibanaServerUrl = formatUrl(config.get('servers.kibana')); const kibanaServerUrl = formatUrl(config.get('servers.kibana'));
return supertest(kibanaServerUrl); return supertest(kibanaServerUrl);
} }
export function ElasticsearchSupertestProvider({ getService }: FtrProviderContext) { export function ElasticsearchSupertestProvider({
getService,
}: FtrProviderContext): supertest.Agent {
const config = getService('config'); const config = getService('config');
const esServerConfig = config.get('servers.elasticsearch'); const esServerConfig = config.get('servers.elasticsearch');

View file

@ -40,7 +40,7 @@ const getSpaceUrlPrefix = (spaceId?: string): string => {
* Options for the send method * Options for the send method
*/ */
interface SendOptions { interface SendOptions {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
options: object; options: object;
strategy: string; strategy: string;
space?: string; space?: string;

View file

@ -74,7 +74,7 @@ describe('APMEventClient', () => {
resolve(undefined); resolve(undefined);
}, 100); }, 100);
}); });
incomingRequest.abort(); void incomingRequest.abort();
}, 100); }, 100);
}); });

View file

@ -13,7 +13,7 @@ async function delay(millis: number): Promise<void> {
} }
export function createWaitForExecutionCount( export function createWaitForExecutionCount(
st: supertest.SuperTest<supertest.Test>, st: supertest.Agent,
spaceId?: string, spaceId?: string,
delayMs: number = 3000 delayMs: number = 3000
) { ) {

View file

@ -6,7 +6,7 @@
*/ */
import type { Client } from '@elastic/elasticsearch'; 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 { ToolingLog } from '@kbn/tooling-log';
import { ThresholdParams } from '@kbn/observability-plugin/common/custom_threshold_rule/types'; import { ThresholdParams } from '@kbn/observability-plugin/common/custom_threshold_rule/types';
import { refreshSavedObjectIndices } from './refresh_index'; import { refreshSavedObjectIndices } from './refresh_index';
@ -17,7 +17,7 @@ export async function createIndexConnector({
indexName, indexName,
logger, logger,
}: { }: {
supertest: SuperTest<Test>; supertest: SuperTestAgent;
name: string; name: string;
indexName: string; indexName: string;
logger: ToolingLog; logger: ToolingLog;
@ -51,7 +51,7 @@ export async function createRule<Params = ThresholdParams>({
logger, logger,
esClient, esClient,
}: { }: {
supertest: SuperTest<Test>; supertest: SuperTestAgent;
ruleTypeId: string; ruleTypeId: string;
name: string; name: string;
params: Params; params: Params;

View file

@ -29,7 +29,7 @@ export async function waitForRuleStatus({
}: { }: {
id: string; id: string;
expectedStatus: string; expectedStatus: string;
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
retryService: RetryService; retryService: RetryService;
logger: ToolingLog; logger: ToolingLog;
}): Promise<Record<string, any>> { }): Promise<Record<string, any>> {

View file

@ -5,7 +5,7 @@
* 2.0. * 2.0.
*/ */
import { SuperTest, Test } from 'supertest'; import { Agent as SuperTestAgent } from 'supertest';
import { ToolingLog } from '@kbn/tooling-log'; import { ToolingLog } from '@kbn/tooling-log';
export const createDataView = async ({ export const createDataView = async ({
@ -15,7 +15,7 @@ export const createDataView = async ({
title, title,
logger, logger,
}: { }: {
supertest: SuperTest<Test>; supertest: SuperTestAgent;
id: string; id: string;
name: string; name: string;
title: string; title: string;
@ -50,7 +50,7 @@ export const deleteDataView = async ({
id, id,
logger, logger,
}: { }: {
supertest: SuperTest<Test>; supertest: SuperTestAgent;
id: string; id: string;
logger: ToolingLog; logger: ToolingLog;
}) => { }) => {

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { SuperTest, Test } from 'supertest'; import { Agent as SuperTestAgent } from 'supertest';
import { chunk, omit } from 'lodash'; import { chunk, omit } from 'lodash';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { SuperuserAtSpace1, UserAtSpaceScenarios } from '../../../scenarios'; import { SuperuserAtSpace1, UserAtSpaceScenarios } from '../../../scenarios';
@ -16,7 +16,7 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context';
const findTestUtils = ( const findTestUtils = (
describeType: 'internal' | 'public', describeType: 'internal' | 'public',
objectRemover: ObjectRemover, objectRemover: ObjectRemover,
supertest: SuperTest<Test>, supertest: SuperTestAgent,
supertestWithoutAuth: any supertestWithoutAuth: any
) => { ) => {
describe.skip(describeType, () => { describe.skip(describeType, () => {

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { SuperTest, Test } from 'supertest'; import { Agent as SuperTestAgent } from 'supertest';
import { chunk, omit } from 'lodash'; import { chunk, omit } from 'lodash';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { UserAtSpaceScenarios } from '../../../scenarios'; import { UserAtSpaceScenarios } from '../../../scenarios';
@ -16,7 +16,7 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context';
const findTestUtils = ( const findTestUtils = (
describeType: 'internal' | 'public', describeType: 'internal' | 'public',
objectRemover: ObjectRemover, objectRemover: ObjectRemover,
supertest: SuperTest<Test>, supertest: SuperTestAgent,
supertestWithoutAuth: any supertestWithoutAuth: any
) => { ) => {
// FLAKY: https://github.com/elastic/kibana/issues/182314 // FLAKY: https://github.com/elastic/kibana/issues/182314

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { SuperTest, Test } from 'supertest'; import { Agent as SuperTestAgent } from 'supertest';
import { SuperuserAtSpace1, UserAtSpaceScenarios } from '../../../scenarios'; import { SuperuserAtSpace1, UserAtSpaceScenarios } from '../../../scenarios';
import { import {
getUrlPrefix, getUrlPrefix,
@ -19,7 +19,7 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context';
const getTestUtils = ( const getTestUtils = (
describeType: 'internal' | 'public', describeType: 'internal' | 'public',
objectRemover: ObjectRemover, objectRemover: ObjectRemover,
supertest: SuperTest<Test>, supertest: SuperTestAgent,
supertestWithoutAuth: any supertestWithoutAuth: any
) => { ) => {
describe(describeType, () => { describe(describeType, () => {

View file

@ -131,7 +131,7 @@ export default function createCrowdstrikeTests({ getService }: FtrProviderContex
password = 'changeme', password = 'changeme',
errorLogger = logErrorDetails, errorLogger = logErrorDetails,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
subAction: string; subAction: string;
subActionParams: Record<string, unknown>; subActionParams: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;

View file

@ -140,7 +140,7 @@ export default function createSentinelOneTests({ getService }: FtrProviderContex
password = 'changeme', password = 'changeme',
errorLogger = logErrorDetails, errorLogger = logErrorDetails,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
subAction: string; subAction: string;
subActionParams: Record<string, unknown>; subActionParams: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;

View file

@ -22,7 +22,7 @@ const createSubActionConnector = async ({
connectorTypeId = 'test.sub-action-connector', connectorTypeId = 'test.sub-action-connector',
expectedHttpCode = 200, expectedHttpCode = 200,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
config?: Record<string, unknown>; config?: Record<string, unknown>;
secrets?: Record<string, unknown>; secrets?: Record<string, unknown>;
connectorTypeId?: string; connectorTypeId?: string;
@ -56,7 +56,7 @@ const executeSubAction = async ({
subActionParams, subActionParams,
expectedHttpCode = 200, expectedHttpCode = 200,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
connectorId: string; connectorId: string;
subAction: string; subAction: string;
subActionParams: Record<string, unknown>; subActionParams: Record<string, unknown>;

View file

@ -8,7 +8,7 @@
import http from 'http'; import http from 'http';
import https from 'https'; import https from 'https';
import getPort from 'get-port'; import getPort from 'get-port';
import { SuperTest, Test } from 'supertest'; import { Agent as SuperTestAgent } from 'supertest';
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { URL, format as formatUrl } from 'url'; import { URL, format as formatUrl } from 'url';
import { import {
@ -177,7 +177,7 @@ export default function webhookTest({ getService }: FtrProviderContext) {
} }
export async function createWebhookAction( export async function createWebhookAction(
supertest: SuperTest<Test>, supertest: SuperTestAgent,
webhookSimulatorURL: string, webhookSimulatorURL: string,
config: Record<string, string | Record<string, string>> = {} config: Record<string, string | Record<string, string>> = {}
): Promise<string> { ): Promise<string> {

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { SuperTest, Test } from 'supertest'; import { Agent as SuperTestAgent } from 'supertest';
import { fromKueryExpression } from '@kbn/es-query'; import { fromKueryExpression } from '@kbn/es-query';
import { Spaces } from '../../../scenarios'; import { Spaces } from '../../../scenarios';
import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../../common/lib'; import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../../common/lib';
@ -14,7 +14,7 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context';
async function createAlert( async function createAlert(
objectRemover: ObjectRemover, objectRemover: ObjectRemover,
supertest: SuperTest<Test>, supertest: SuperTestAgent,
overwrites = {} overwrites = {}
) { ) {
const { body: createdAlert } = await supertest const { body: createdAlert } = await supertest
@ -28,7 +28,7 @@ async function createAlert(
const findTestUtils = ( const findTestUtils = (
describeType: 'internal' | 'public', describeType: 'internal' | 'public',
supertest: SuperTest<Test>, supertest: SuperTestAgent,
objectRemover: ObjectRemover objectRemover: ObjectRemover
) => { ) => {
describe(describeType, () => { describe(describeType, () => {

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { SuperTest, Test } from 'supertest'; import { Agent as SuperTestAgent } from 'supertest';
import { Spaces } from '../../../scenarios'; import { Spaces } from '../../../scenarios';
import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../../common/lib'; import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../../common/lib';
import { FtrProviderContext } from '../../../../common/ftr_provider_context'; import { FtrProviderContext } from '../../../../common/ftr_provider_context';
@ -14,7 +14,7 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context';
const getTestUtils = ( const getTestUtils = (
describeType: 'internal' | 'public', describeType: 'internal' | 'public',
objectRemover: ObjectRemover, objectRemover: ObjectRemover,
supertest: SuperTest<Test> supertest: SuperTestAgent
) => { ) => {
describe(describeType, () => { describe(describeType, () => {
afterEach(() => objectRemover.removeAll()); afterEach(() => objectRemover.removeAll());

View file

@ -8,7 +8,7 @@
import moment from 'moment'; import moment from 'moment';
import type { RetryService } from '@kbn/ftr-common-functional-services'; import type { RetryService } from '@kbn/ftr-common-functional-services';
import type { IValidatedEvent } from '@kbn/event-log-plugin/server'; 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 expect from '@kbn/expect';
import type { FtrProviderContext } from '../../../../common/ftr_provider_context'; import type { FtrProviderContext } from '../../../../common/ftr_provider_context';
import { getUrlPrefix, getTestRuleData, ObjectRemover, getEventLog } from '../../../../common/lib'; import { getUrlPrefix, getTestRuleData, ObjectRemover, getEventLog } from '../../../../common/lib';
@ -23,7 +23,7 @@ export const createRule = async ({
}: { }: {
actionId: string; actionId: string;
pattern: { instance: boolean[] }; pattern: { instance: boolean[] };
supertest: SuperTest<Test>; supertest: SuperTestAgent;
objectRemover: ObjectRemover; objectRemover: ObjectRemover;
overwrites?: any; overwrites?: any;
}) => { }) => {
@ -65,7 +65,7 @@ export const createAction = async ({
supertest, supertest,
objectRemover, objectRemover,
}: { }: {
supertest: SuperTest<Test>; supertest: SuperTestAgent;
objectRemover: ObjectRemover; objectRemover: ObjectRemover;
}) => { }) => {
const { body: createdAction } = await supertest const { body: createdAction } = await supertest
@ -89,7 +89,7 @@ export const createMaintenanceWindow = async ({
objectRemover, objectRemover,
}: { }: {
overwrites?: any; overwrites?: any;
supertest: SuperTest<Test>; supertest: SuperTestAgent;
objectRemover: ObjectRemover; objectRemover: ObjectRemover;
}) => { }) => {
const { body: window } = await supertest const { body: window } = await supertest
@ -112,11 +112,7 @@ export const createMaintenanceWindow = async ({
return window; return window;
}; };
export const getActiveMaintenanceWindows = async ({ export const getActiveMaintenanceWindows = async ({ supertest }: { supertest: SuperTestAgent }) => {
supertest,
}: {
supertest: SuperTest<Test>;
}) => {
const { body: activeMaintenanceWindows } = await supertest const { body: activeMaintenanceWindows } = await supertest
.get(`${getUrlPrefix(Spaces.space1.id)}/internal/alerting/rules/maintenance_window/_active`) .get(`${getUrlPrefix(Spaces.space1.id)}/internal/alerting/rules/maintenance_window/_active`)
.set('kbn-xsrf', 'foo') .set('kbn-xsrf', 'foo')
@ -130,7 +126,7 @@ export const finishMaintenanceWindow = async ({
supertest, supertest,
}: { }: {
id: string; id: string;
supertest: SuperTest<Test>; supertest: SuperTestAgent;
}) => { }) => {
return supertest return supertest
.post( .post(
@ -188,7 +184,7 @@ export const expectNoActionsFired = async ({
retry, retry,
}: { }: {
id: string; id: string;
supertest: SuperTest<Test>; supertest: SuperTestAgent;
retry: RetryService; retry: RetryService;
}) => { }) => {
const events = await retry.try(async () => { const events = await retry.try(async () => {
@ -215,7 +211,7 @@ export const runSoon = async ({
retry, retry,
}: { }: {
id: string; id: string;
supertest: SuperTest<Test>; supertest: SuperTestAgent;
retry: RetryService; retry: RetryService;
}) => { }) => {
return retry.try(async () => { return retry.try(async () => {

View file

@ -9,11 +9,11 @@ import type { AssetWithoutTimestamp } from '@kbn/assetManager-plugin/common/type
import type { WriteSamplesPostBody } from '@kbn/assetManager-plugin/server'; import type { WriteSamplesPostBody } from '@kbn/assetManager-plugin/server';
import { apm, infra, timerange } from '@kbn/apm-synthtrace-client'; import { apm, infra, timerange } from '@kbn/apm-synthtrace-client';
import expect from '@kbn/expect'; 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'; const SAMPLE_ASSETS_ENDPOINT = '/api/asset-manager/assets/sample';
export type KibanaSupertest = SuperTest<Test>; export type KibanaSupertest = SuperTestAgent;
// NOTE: In almost every case in tests, you want { refresh: true } // NOTE: In almost every case in tests, you want { refresh: true }
// in the options of this function, so it is defaulted to that value. // in the options of this function, so it is defaulted to that value.

View file

@ -5,7 +5,7 @@
* 2.0. * 2.0.
*/ */
import type { SuperTest, Test } from 'supertest'; import type { Agent as SuperTestAgent } from 'supertest';
import { Client } from '@elastic/elasticsearch'; import { Client } from '@elastic/elasticsearch';
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
@ -43,7 +43,7 @@ export const addIndex = async <T>(es: Client, findingsMock: T[], indexName: stri
}; };
export async function createPackagePolicy( export async function createPackagePolicy(
supertest: SuperTest<Test>, supertest: SuperTestAgent,
agentPolicyId: string, agentPolicyId: string,
policyTemplate: string, policyTemplate: string,
input: string, input: string,

View file

@ -36,7 +36,9 @@ export function templatesApi(getService: FtrProviderContext['getService']) {
.send(payload); .send(payload);
// Delete all templates created during tests // Delete all templates created during tests
const cleanUpTemplates = async (additionalRequestHeaders: object = {}) => { const cleanUpTemplates = async (
additionalRequestHeaders: Record<string, string | string[]> = {}
) => {
try { try {
await deleteTemplates(templatesCreated).set(additionalRequestHeaders); await deleteTemplates(templatesCreated).set(additionalRequestHeaders);
templatesCreated = []; templatesCreated = [];

View file

@ -6,9 +6,6 @@
*/ */
import { apm, timerange } from '@kbn/apm-synthtrace-client'; import { apm, timerange } from '@kbn/apm-synthtrace-client';
import { SuperTest, Test } from 'supertest';
export type KibanaSupertest = SuperTest<Test>;
// generates traces, metrics for services // generates traces, metrics for services
export function generateServicesData({ export function generateServicesData({

View file

@ -50,7 +50,7 @@ function getCacheDetails(body: UnencryptedTelemetryPayload): CacheDetails[] {
* @param timestamp The new timestamp to be set * @param timestamp The new timestamp to be set
*/ */
function updateMonitoringDates( function updateMonitoringDates(
esSupertest: SuperTest.SuperTest<SuperTest.Test>, esSupertest: SuperTest.Agent,
fromTimestamp: string, fromTimestamp: string,
toTimestamp: string, toTimestamp: string,
timestamp: string timestamp: string

View file

@ -15,7 +15,7 @@ import type {
import type { APIEndpoint } from '@kbn/apm-plugin/server'; import type { APIEndpoint } from '@kbn/apm-plugin/server';
import { formatRequest } from '@kbn/server-route-repository'; import { formatRequest } from '@kbn/server-route-repository';
export function createApmApiClient(st: supertest.SuperTest<supertest.Test>) { export function createApmApiClient(st: supertest.Agent) {
return async <TEndpoint extends APIEndpoint>( return async <TEndpoint extends APIEndpoint>(
options: { options: {
type?: 'form-data'; type?: 'form-data';

View file

@ -30,7 +30,7 @@ export interface BetterTestResponse<T> {
* This is useful for tests that expect a 200 response * 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. * It also makes it easier to debug tests that fail because of a 500 response.
*/ */
export function getBettertest(st: supertest.SuperTest<supertest.Test>) { export function getBettertest(st: supertest.Agent) {
return async <T>({ return async <T>({
pathname, pathname,
method = 'get', method = 'get',

View file

@ -8,7 +8,7 @@
import { Client, errors } from '@elastic/elasticsearch'; import { Client, errors } from '@elastic/elasticsearch';
import { ParsedTechnicalFields } from '@kbn/rule-registry-plugin/common'; import { ParsedTechnicalFields } from '@kbn/rule-registry-plugin/common';
import pRetry from 'p-retry'; 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 { ApmRuleType } from '@kbn/rule-data-utils';
import { ApmRuleParamsType } from '@kbn/apm-plugin/common/rules/schema'; import { ApmRuleParamsType } from '@kbn/apm-plugin/common/rules/schema';
import { ApmDocumentType } from '@kbn/apm-plugin/common/document_type'; import { ApmDocumentType } from '@kbn/apm-plugin/common/document_type';
@ -26,7 +26,7 @@ export async function createApmRule<T extends ApmRuleType>({
params, params,
actions = [], actions = [],
}: { }: {
supertest: SuperTest<Test>; supertest: SuperTestAgent;
ruleTypeId: T; ruleTypeId: T;
name: string; name: string;
params: ApmRuleParamsType[T]; params: ApmRuleParamsType[T];
@ -111,7 +111,7 @@ export async function runRuleSoon({
supertest, supertest,
}: { }: {
ruleId: string; ruleId: string;
supertest: SuperTest<Test>; supertest: SuperTestAgent;
}): Promise<Record<string, any>> { }): Promise<Record<string, any>> {
return pRetry( return pRetry(
async () => { async () => {
@ -143,13 +143,13 @@ export async function deleteRuleById({
supertest, supertest,
ruleId, ruleId,
}: { }: {
supertest: SuperTest<Test>; supertest: SuperTestAgent;
ruleId: string; ruleId: string;
}) { }) {
await supertest.delete(`/api/alerting/rule/${ruleId}`).set('kbn-xsrf', 'foo'); await supertest.delete(`/api/alerting/rule/${ruleId}`).set('kbn-xsrf', 'foo');
} }
export async function deleteApmRules(supertest: SuperTest<Test>) { export async function deleteApmRules(supertest: SuperTestAgent) {
const res = await supertest.get( const res = await supertest.get(
`/api/alerting/rules/_find?filter=alert.attributes.consumer:apm&per_page=10000` `/api/alerting/rules/_find?filter=alert.attributes.consumer:apm&per_page=10000`
); );
@ -180,7 +180,7 @@ export async function createIndexConnector({
supertest, supertest,
name, name,
}: { }: {
supertest: SuperTest<Test>; supertest: SuperTestAgent;
name: string; name: string;
}) { }) {
const { body } = await supertest const { body } = await supertest
@ -228,7 +228,7 @@ export async function deleteAllActionConnectors({
supertest, supertest,
es, es,
}: { }: {
supertest: SuperTest<Test>; supertest: SuperTestAgent;
es: Client; es: Client;
}): Promise<any> { }): Promise<any> {
const res = await supertest.get(`/api/actions/connectors`); const res = await supertest.get(`/api/actions/connectors`);
@ -245,7 +245,7 @@ async function deleteActionConnector({
supertest, supertest,
actionId, actionId,
}: { }: {
supertest: SuperTest<Test>; supertest: SuperTestAgent;
actionId: string; actionId: string;
}) { }) {
return supertest.delete(`/api/actions/connector/${actionId}`).set('kbn-xsrf', 'foo'); return supertest.delete(`/api/actions/connector/${actionId}`).set('kbn-xsrf', 'foo');

View file

@ -7,7 +7,7 @@
import { Client } from '@elastic/elasticsearch'; import { Client } from '@elastic/elasticsearch';
import { ToolingLog } from '@kbn/tooling-log'; import { ToolingLog } from '@kbn/tooling-log';
import type { SuperTest, Test } from 'supertest'; import type { Agent as SuperTestAgent } from 'supertest';
import { import {
clearKibanaApmEventLog, clearKibanaApmEventLog,
deleteApmRules, deleteApmRules,
@ -22,7 +22,7 @@ export async function cleanupRuleAndAlertState({
logger, logger,
}: { }: {
es: Client; es: Client;
supertest: SuperTest<Test>; supertest: SuperTestAgent;
logger: ToolingLog; logger: ToolingLog;
}) { }) {
try { try {

View file

@ -17,7 +17,7 @@ export async function waitForActiveRule({
logger, logger,
}: { }: {
ruleId: string; ruleId: string;
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
logger?: ToolingLog; logger?: ToolingLog;
}): Promise<Record<string, any>> { }): Promise<Record<string, any>> {
return pRetry( return pRetry(

View file

@ -30,7 +30,7 @@ import { createComment, deleteAllComments } from './api';
import { postCaseReq } from './mock'; import { postCaseReq } from './mock';
export const createSecuritySolutionAlerts = async ( export const createSecuritySolutionAlerts = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
log: ToolingLog, log: ToolingLog,
numberOfSignals: number = 1 numberOfSignals: number = 1
): Promise<estypes.SearchResponse<DetectionAlert & RiskEnrichmentFields>> => { ): Promise<estypes.SearchResponse<DetectionAlert & RiskEnrichmentFields>> => {
@ -47,7 +47,7 @@ export const createSecuritySolutionAlerts = async (
}; };
export const getSecuritySolutionAlerts = async ( export const getSecuritySolutionAlerts = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
alertIds: string[] alertIds: string[]
): Promise<estypes.SearchResponse<DetectionAlert & RiskEnrichmentFields>> => { ): Promise<estypes.SearchResponse<DetectionAlert & RiskEnrichmentFields>> => {
const { body: updatedAlert } = await supertest const { body: updatedAlert } = await supertest
@ -70,7 +70,7 @@ export const getAlertById = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
id: string; id: string;
index: string; index: string;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -97,7 +97,7 @@ export const createCaseAttachAlertAndDeleteAlert = async ({
alerts, alerts,
getAlerts, getAlerts,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
totalCases: number; totalCases: number;
indexOfCaseToDelete: number; indexOfCaseToDelete: number;
owner: string; owner: string;
@ -145,7 +145,7 @@ export const createCaseAttachAlertAndDeleteCase = async ({
alerts, alerts,
getAlerts, getAlerts,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
totalCases: number; totalCases: number;
indicesOfCaseToDelete: number[]; indicesOfCaseToDelete: number[];
owner: string; owner: string;
@ -194,7 +194,7 @@ export const createCaseAndAttachAlert = async ({
alerts, alerts,
getAlerts, getAlerts,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
totalCases: number; totalCases: number;
owner: string; owner: string;
alerts: Alerts; alerts: Alerts;

View file

@ -33,7 +33,7 @@ export const bulkGetAttachments = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
attachmentIds: string[]; attachmentIds: string[];
caseId: string; caseId: string;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -57,12 +57,12 @@ export const createComment = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
headers = {}, headers = {},
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
params: AttachmentRequest; params: AttachmentRequest;
auth?: { user: User; space: string | null } | null; auth?: { user: User; space: string | null } | null;
expectedHttpCode?: number; expectedHttpCode?: number;
headers?: Record<string, unknown>; headers?: Record<string, string | string[]>;
}): Promise<Case> => { }): Promise<Case> => {
const apiCall = supertest.post( const apiCall = supertest.post(
`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}/${caseId}/comments` `${getSpaceUrlPrefix(auth?.space)}${CASES_URL}/${caseId}/comments`
@ -86,7 +86,7 @@ export const bulkCreateAttachments = async ({
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
expectedHttpCode = 200, expectedHttpCode = 200,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
params: BulkCreateAttachmentsRequest; params: BulkCreateAttachmentsRequest;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -110,7 +110,7 @@ export const createCaseAndBulkCreateAttachments = async ({
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
expectedHttpCode = 200, expectedHttpCode = 200,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
numberOfAttachments?: number; numberOfAttachments?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
expectedHttpCode?: number; expectedHttpCode?: number;
@ -156,7 +156,7 @@ export const deleteComment = async ({
expectedHttpCode = 204, expectedHttpCode = 204,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
commentId: string; commentId: string;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -178,7 +178,7 @@ export const deleteAllComments = async ({
expectedHttpCode = 204, expectedHttpCode = 204,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -199,7 +199,7 @@ export const getAllComments = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
expectedHttpCode?: number; expectedHttpCode?: number;
@ -219,7 +219,7 @@ export const getComment = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
commentId: string; commentId: string;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -241,12 +241,12 @@ export const updateComment = async ({
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
headers = {}, headers = {},
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
req: AttachmentPatchRequest; req: AttachmentPatchRequest;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null } | null; auth?: { user: User; space: string | null } | null;
headers?: Record<string, unknown>; headers?: Record<string, string | string[]>;
}): Promise<Case> => { }): Promise<Case> => {
const apiCall = supertest.patch( const apiCall = supertest.patch(
`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}/${caseId}/comments` `${getSpaceUrlPrefix(auth?.space)}${CASES_URL}/${caseId}/comments`
@ -269,7 +269,7 @@ export const bulkDeleteFileAttachments = async ({
expectedHttpCode = 204, expectedHttpCode = 204,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
fileIds: string[]; fileIds: string[];
expectedHttpCode?: number; expectedHttpCode?: number;
@ -290,7 +290,7 @@ export const findAttachments = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
query?: Record<string, unknown>; query?: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;

View file

@ -15,11 +15,11 @@ import { superUser } from '../authentication/users';
import { getSpaceUrlPrefix, setupAuth } from './helpers'; import { getSpaceUrlPrefix, setupAuth } from './helpers';
export const createCase = async ( export const createCase = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
params: CasePostRequest, params: CasePostRequest,
expectedHttpCode: number = 200, expectedHttpCode: number = 200,
auth: { user: User; space: string | null } | null = { user: superUser, space: null }, auth: { user: User; space: string | null } | null = { user: superUser, space: null },
headers: Record<string, unknown> = {} headers: Record<string, string | string[]> = {}
): Promise<Case> => { ): Promise<Case> => {
const apiCall = supertest.post(`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}`); const apiCall = supertest.post(`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}`);
@ -44,7 +44,7 @@ export const deleteCases = async ({
expectedHttpCode = 204, expectedHttpCode = 204,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseIDs: string[]; caseIDs: string[];
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };

View file

@ -60,11 +60,11 @@ export const getConfigurationOutput = (update = false, overwrite = {}): Partial<
}; };
export const createConfiguration = async ( export const createConfiguration = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
req: ConfigurationRequest = getConfigurationRequest(), req: ConfigurationRequest = getConfigurationRequest(),
expectedHttpCode: number = 200, expectedHttpCode: number = 200,
auth: { user: User; space: string | null } | null = { user: superUser, space: null }, auth: { user: User; space: string | null } | null = { user: superUser, space: null },
headers: Record<string, unknown> = {} headers: Record<string, string | string[]> = {}
): Promise<Configuration> => { ): Promise<Configuration> => {
const apiCall = supertest.post(`${getSpaceUrlPrefix(auth?.space)}${CASE_CONFIGURE_URL}`); const apiCall = supertest.post(`${getSpaceUrlPrefix(auth?.space)}${CASE_CONFIGURE_URL}`);
@ -86,7 +86,7 @@ export const getConfiguration = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
query?: Record<string, unknown>; query?: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -102,12 +102,12 @@ export const getConfiguration = async ({
}; };
export const updateConfiguration = async ( export const updateConfiguration = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
id: string, id: string,
req: ConfigurationPatchRequest, req: ConfigurationPatchRequest,
expectedHttpCode: number = 200, expectedHttpCode: number = 200,
auth: { user: User; space: string | null } | null = { user: superUser, space: null }, auth: { user: User; space: string | null } | null = { user: superUser, space: null },
headers: Record<string, unknown> = {} headers: Record<string, string | string[]> = {}
): Promise<Configuration> => { ): Promise<Configuration> => {
const apiCall = supertest.patch(`${getSpaceUrlPrefix(auth?.space)}${CASE_CONFIGURE_URL}/${id}`); const apiCall = supertest.patch(`${getSpaceUrlPrefix(auth?.space)}${CASE_CONFIGURE_URL}/${id}`);

View file

@ -194,7 +194,7 @@ export const getCaseConnectors = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
}): Promise<FindActionResult[]> => { }): Promise<FindActionResult[]> => {
@ -215,13 +215,13 @@ export const createCaseWithConnector = async ({
createCaseReq = getPostCaseRequest(), createCaseReq = getPostCaseRequest(),
headers = {}, headers = {},
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
serviceNowSimulatorURL: string; serviceNowSimulatorURL: string;
actionsRemover: ActionsRemover; actionsRemover: ActionsRemover;
configureReq?: Record<string, unknown>; configureReq?: Record<string, unknown>;
auth?: { user: User; space: string | null } | null; auth?: { user: User; space: string | null } | null;
createCaseReq?: CasePostRequest; createCaseReq?: CasePostRequest;
headers?: Record<string, unknown>; headers?: Record<string, string | string[]>;
}): Promise<{ }): Promise<{
postedCase: Case; postedCase: Case;
connector: CreateConnectorResponse; connector: CreateConnectorResponse;
@ -288,7 +288,7 @@ export const createConnector = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
req: Record<string, unknown>; req: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -309,7 +309,7 @@ export const getConnectors = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -329,7 +329,7 @@ export const executeConnector = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
connectorId: string; connectorId: string;
req: Record<string, unknown>; req: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -352,7 +352,7 @@ export const executeSystemConnector = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
connectorId: string; connectorId: string;
req: Record<string, unknown>; req: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;

View file

@ -23,7 +23,7 @@ export const downloadFile = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
fileId: string; fileId: string;
kind: string; kind: string;
mimeType: string; mimeType: string;
@ -49,7 +49,7 @@ export const deleteFileForFileKind = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
fileKind: string; fileKind: string;
id: string; id: string;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -72,7 +72,7 @@ export const deleteFiles = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
files: string[]; files: string[];
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -91,7 +91,7 @@ export const deleteAllFilesForKind = async ({
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
expectedHttpCode = 200, expectedHttpCode = 200,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
kind: string; kind: string;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -124,7 +124,7 @@ export const deleteAllFiles = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
ignoreErrors = true, ignoreErrors = true,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
ignoreErrors?: boolean; ignoreErrors?: boolean;
@ -165,7 +165,7 @@ export const getFileById = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
id: string; id: string;
kind: string; kind: string;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -185,7 +185,7 @@ export const listFiles = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
params: Parameters<BaseFilesClient['list']>[0]; params: Parameters<BaseFilesClient['list']>[0];
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -213,7 +213,7 @@ export const createFile = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
params: CreateFileSchema; params: CreateFileSchema;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -238,7 +238,7 @@ export const uploadFile = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
data: string | object; data: string | object;
kind: string; kind: string;
fileId: string; fileId: string;
@ -264,7 +264,7 @@ export const createAndUploadFile = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
data: string | object; data: string | object;
createFileParams: CreateFileSchema; createFileParams: CreateFileSchema;
expectedHttpCode?: number; expectedHttpCode?: number;

View file

@ -129,7 +129,7 @@ export const setStatus = async ({
supertest, supertest,
cases, cases,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
cases: SetStatusCasesParams[]; cases: SetStatusCasesParams[];
}): Promise<Cases> => { }): Promise<Cases> => {
const { body }: { body: Cases } = await supertest const { body }: { body: Cases } = await supertest
@ -143,7 +143,7 @@ export const setStatus = async ({
/** /**
* Add case as a connector * Add case as a connector
*/ */
export const createCaseAction = async (supertest: SuperTest.SuperTest<SuperTest.Test>) => { export const createCaseAction = async (supertest: SuperTest.Agent) => {
const { body: createdAction } = await supertest const { body: createdAction } = await supertest
.post('/api/actions/connector') .post('/api/actions/connector')
.set('kbn-xsrf', 'foo') .set('kbn-xsrf', 'foo')
@ -159,10 +159,7 @@ export const createCaseAction = async (supertest: SuperTest.SuperTest<SuperTest.
/** /**
* Remove a connector * Remove a connector
*/ */
export const deleteCaseAction = async ( export const deleteCaseAction = async (supertest: SuperTest.Agent, id: string) => {
supertest: SuperTest.SuperTest<SuperTest.Test>,
id: string
) => {
await supertest.delete(`/api/actions/connector/${id}`).set('kbn-xsrf', 'foo'); await supertest.delete(`/api/actions/connector/${id}`).set('kbn-xsrf', 'foo');
}; };
@ -418,11 +415,11 @@ export const updateCase = async ({
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
headers = {}, headers = {},
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
params: CasesPatchRequest; params: CasesPatchRequest;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null } | null; auth?: { user: User; space: string | null } | null;
headers?: Record<string, unknown>; headers?: Record<string, string | string[]>;
}): Promise<Case[]> => { }): Promise<Case[]> => {
const apiCall = supertest.patch(`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}`); const apiCall = supertest.patch(`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}`);
@ -444,7 +441,7 @@ export const getAllCasesStatuses = async ({
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
query = {}, query = {},
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
query?: Record<string, unknown>; query?: Record<string, unknown>;
@ -465,7 +462,7 @@ export const getCase = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
includeComments?: boolean; includeComments?: boolean;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -490,7 +487,7 @@ export const getCaseMetrics = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
features: CaseMetricsFeature[] | CaseMetricsFeature; features: CaseMetricsFeature[] | CaseMetricsFeature;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -512,7 +509,7 @@ export const resolveCase = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
includeComments?: boolean; includeComments?: boolean;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -537,7 +534,7 @@ export const findCases = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
query?: Record<string, unknown>; query?: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -560,7 +557,7 @@ export const getCasesByAlert = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
alertID: string; alertID: string;
query?: Record<string, unknown>; query?: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -581,7 +578,7 @@ export const getTags = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
query?: Record<string, unknown>; query?: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -602,7 +599,7 @@ export const getReporters = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
query?: Record<string, unknown>; query?: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -623,7 +620,7 @@ export const getCategories = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
query?: Record<string, unknown>; query?: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -646,12 +643,12 @@ export const pushCase = async ({
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
headers = {}, headers = {},
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
connectorId: string; connectorId: string;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null } | null; auth?: { user: User; space: string | null } | null;
headers?: Record<string, unknown>; headers?: Record<string, string | string[]>;
}): Promise<Case> => { }): Promise<Case> => {
const apiCall = supertest.post( const apiCall = supertest.post(
`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}/${caseId}/connector/${connectorId}/_push` `${getSpaceUrlPrefix(auth?.space)}${CASES_URL}/${caseId}/connector/${connectorId}/_push`
@ -674,7 +671,7 @@ export const getAlertsAttachedToCase = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -727,7 +724,7 @@ export const getCasesMetrics = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
features: string[] | string; features: string[] | string;
query?: Record<string, unknown>; query?: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -774,7 +771,7 @@ export const bulkGetCases = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
ids: string[]; ids: string[];
fields?: string[]; fields?: string[];
expectedHttpCode?: number; expectedHttpCode?: number;
@ -796,7 +793,7 @@ export const searchCases = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
body?: Record<string, unknown>; body?: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -820,13 +817,13 @@ export const replaceCustomField = async ({
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
headers = {}, headers = {},
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
customFieldId: string; customFieldId: string;
params: CustomFieldPutRequest; params: CustomFieldPutRequest;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null } | null; auth?: { user: User; space: string | null } | null;
headers?: Record<string, unknown>; headers?: Record<string, string | string[]>;
}): Promise<CaseCustomField> => { }): Promise<CaseCustomField> => {
const apiCall = supertest.put( const apiCall = supertest.put(
`${getSpaceUrlPrefix( `${getSpaceUrlPrefix(

View file

@ -42,7 +42,7 @@ export const getCaseUserActions = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseID: string; caseID: string;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -61,7 +61,7 @@ export const findCaseUserActions = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseID: string; caseID: string;
options?: UserActionFindRequest; options?: UserActionFindRequest;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -82,7 +82,7 @@ export const getCaseUserActionStats = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseID: string; caseID: string;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -101,7 +101,7 @@ export const getCaseUsers = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
caseId: string; caseId: string;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };

View file

@ -38,7 +38,7 @@ export const bulkGetUserProfiles = async <T extends string>({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
req: BulkGetUserProfilesParams<T>; req: BulkGetUserProfilesParams<T>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -62,7 +62,7 @@ export const suggestUserProfiles = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
req: SuggestUserProfilesRequest; req: SuggestUserProfilesRequest;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -89,10 +89,10 @@ export const updateUserProfileAvatar = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
headers = {}, headers = {},
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
req: UserProfileAvatarData; req: UserProfileAvatarData;
expectedHttpCode?: number; expectedHttpCode?: number;
headers?: Record<string, unknown>; headers?: Record<string, string | string[]>;
}): Promise<void> => { }): Promise<void> => {
await supertest await supertest
.post('/internal/security/user_profile/_data') .post('/internal/security/user_profile/_data')
@ -106,7 +106,7 @@ export const loginUsers = async ({
supertest, supertest,
users = [superUser], users = [superUser],
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
users?: User[]; users?: User[];
}) => { }) => {
const cookies: Cookie[] = []; const cookies: Cookie[] = [];

View file

@ -52,7 +52,7 @@ export default ({ getService }: FtrProviderContext): void => {
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
superTestService?: SuperTest.SuperTest<SuperTest.Test>; superTestService?: SuperTest.Agent;
data: object; data: object;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };

View file

@ -700,7 +700,7 @@ const createCaseWithFiles = async ({
owner, owner,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
fileKind: string; fileKind: string;
owner: string; owner: string;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };

View file

@ -161,7 +161,7 @@ export default ({ getService }: FtrProviderContext): void => {
}); });
}; };
const expectImportToHaveOneCase = async (supertestService: supertest.SuperTest<supertest.Test>) => { const expectImportToHaveOneCase = async (supertestService: supertest.Agent) => {
const findResponse = await findCases({ supertest: supertestService, query: {} }); const findResponse = await findCases({ supertest: supertestService, query: {} });
expect(findResponse.total).to.eql(1); expect(findResponse.total).to.eql(1);
expect(findResponse.cases[0].title).to.eql('A case with a connector'); expect(findResponse.cases[0].title).to.eql('A case with a connector');

View file

@ -1352,7 +1352,7 @@ const executeConnectorAndVerifyCorrectness = async ({
connectorId, connectorId,
req, req,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
connectorId: string; connectorId: string;
req: Record<string, unknown>; req: Record<string, unknown>;
}) => { }) => {

View file

@ -28,7 +28,7 @@ const getSpaceUrlPrefix = (spaceId?: string): string => {
}; };
interface SendOptions { interface SendOptions {
supertestWithoutAuth: SuperTest.SuperTest<SuperTest.Test>; supertestWithoutAuth: SuperTest.Agent;
auth: { username: string; password: string }; auth: { username: string; password: string };
referer?: string; referer?: string;
kibanaVersion?: string; kibanaVersion?: string;

View file

@ -17,7 +17,7 @@ import { countDownTest } from '../count_down_test';
* @param supertest The supertest client library * @param supertest The supertest client library
*/ */
export const createAlertsIndex = async ( export const createAlertsIndex = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
log: ToolingLog log: ToolingLog
): Promise<void> => { ): Promise<void> => {
await countDownTest( await countDownTest(

View file

@ -16,7 +16,7 @@ import { countDownTest } from '../count_down_test';
* For use inside of afterEach blocks of tests * For use inside of afterEach blocks of tests
*/ */
export const deleteAllAlerts = async ( export const deleteAllAlerts = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
log: ToolingLog, log: ToolingLog,
es: Client, es: Client,
index: Array<'.alerts-security.alerts-*' | '.preview.alerts-security.alerts-*'> = [ index: Array<'.alerts-security.alerts-*' | '.preview.alerts-security.alerts-*'> = [

View file

@ -20,7 +20,7 @@ import { getQueryAlertsId } from './get_query_alerts_ids';
* @param ids Rule id * @param ids Rule id
*/ */
export const getAlertsById = async ( export const getAlertsById = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
log: ToolingLog, log: ToolingLog,
id: string id: string
): Promise<SearchResponse<DetectionAlert>> => { ): Promise<SearchResponse<DetectionAlert>> => {

View file

@ -23,7 +23,7 @@ import { routeWithNamespace } from '../route_with_namespace';
* @param ids Array of the rule ids * @param ids Array of the rule ids
*/ */
export const getAlertsByIds = async ( export const getAlertsByIds = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
log: ToolingLog, log: ToolingLog,
ids: string[], ids: string[],
size?: number, size?: number,

View file

@ -18,7 +18,7 @@ import { waitFor } from '../wait_for';
* @param numberOfAlerts The number of alerts to wait for, default is 1 * @param numberOfAlerts The number of alerts to wait for, default is 1
*/ */
export const waitForAlertsToBePresent = async ( export const waitForAlertsToBePresent = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
log: ToolingLog, log: ToolingLog,
numberOfAlerts = 1, numberOfAlerts = 1,
alertIds: string[], alertIds: string[],

View file

@ -27,7 +27,7 @@ import { routeWithNamespace } from '../route_with_namespace';
* @param rule The rule to create * @param rule The rule to create
*/ */
export const createRule = async ( export const createRule = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
log: ToolingLog, log: ToolingLog,
rule: RuleCreateProps, rule: RuleCreateProps,
namespace?: string namespace?: string

View file

@ -19,7 +19,7 @@ import { countDownTest } from '../count_down_test';
* @param supertest The supertest agent. * @param supertest The supertest agent.
*/ */
export const deleteAllRules = async ( export const deleteAllRules = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
log: ToolingLog log: ToolingLog
): Promise<void> => { ): Promise<void> => {
await countDownTest( await countDownTest(

View file

@ -17,7 +17,7 @@ import { DETECTION_ENGINE_RULES_URL } from '@kbn/security-solution-plugin/common
* @param ruleId The rule id to delete * @param ruleId The rule id to delete
*/ */
export const deleteRule = async ( export const deleteRule = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
ruleId: string ruleId: string
): Promise<RuleResponse> => { ): Promise<RuleResponse> => {
const response = await supertest const response = await supertest

View file

@ -16,7 +16,7 @@ import { waitFor } from '../wait_for';
import { routeWithNamespace } from '../route_with_namespace'; import { routeWithNamespace } from '../route_with_namespace';
interface WaitForRuleStatusBaseParams { interface WaitForRuleStatusBaseParams {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
log: ToolingLog; log: ToolingLog;
afterDate?: Date; afterDate?: Date;
namespace?: string; namespace?: string;

View file

@ -12,7 +12,7 @@ import type { APIEndpoint } from '@kbn/dataset-quality-plugin/server/routes';
import { formatRequest } from '@kbn/server-route-repository'; import { formatRequest } from '@kbn/server-route-repository';
import type { APIClientRequestParamsOf, APIReturnType } from '@kbn/dataset-quality-plugin/common'; import type { APIClientRequestParamsOf, APIReturnType } from '@kbn/dataset-quality-plugin/common';
export function createDatasetQualityApiClient(st: supertest.SuperTest<supertest.Test>) { export function createDatasetQualityApiClient(st: supertest.Agent) {
return async <TEndpoint extends APIEndpoint>( return async <TEndpoint extends APIEndpoint>(
options: { options: {
type?: 'form-data'; type?: 'form-data';

View file

@ -5,7 +5,7 @@
* 2.0. * 2.0.
*/ */
import { SuperTest, Test } from 'supertest'; import { Agent as SuperTestAgent } from 'supertest';
export interface IntegrationPackage { export interface IntegrationPackage {
name: string; name: string;
@ -26,7 +26,7 @@ export async function installCustomIntegration({
supertest, supertest,
customIntegration, customIntegration,
}: { }: {
supertest: SuperTest<Test>; supertest: SuperTestAgent;
customIntegration: CustomIntegration; customIntegration: CustomIntegration;
}) { }) {
const { integrationName, datasets } = customIntegration; const { integrationName, datasets } = customIntegration;
@ -41,7 +41,7 @@ export async function installPackage({
supertest, supertest,
pkg, pkg,
}: { }: {
supertest: SuperTest<Test>; supertest: SuperTestAgent;
pkg: IntegrationPackage; pkg: IntegrationPackage;
}) { }) {
const { name, version } = pkg; const { name, version } = pkg;
@ -56,7 +56,7 @@ export async function uninstallPackage({
supertest, supertest,
pkg, pkg,
}: { }: {
supertest: SuperTest<Test>; supertest: SuperTestAgent;
pkg: IntegrationPackage; pkg: IntegrationPackage;
}) { }) {
const { name, version } = pkg; const { name, version } = pkg;

View file

@ -9,6 +9,7 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { INGEST_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server'; import { INGEST_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server';
import { HTTPError } from 'superagent';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { skipIfNoDockerRegistry } from '../../helpers'; import { skipIfNoDockerRegistry } from '../../helpers';
@ -167,7 +168,7 @@ export default function (providerContext: FtrProviderContext) {
.type('application/gzip') .type('application/gzip')
.send(buf) .send(buf)
.expect(400); .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."}' '{"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') .type('application/zip')
.send(buf) .send(buf)
.expect(400); .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."}' '{"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') .type('application/zip')
.send(buf) .send(buf)
.expect(400); .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"}' '{"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') .type('application/zip')
.send(buf) .send(buf)
.expect(400); .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."}' '{"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') .type('application/zip')
.send(buf) .send(buf)
.expect(400); .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 ^."}' '{"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') .type('application/zip')
.send(buf) .send(buf)
.expect(400); .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."}' '{"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') .type('application/zip')
.send(buf) .send(buf)
.expect(400); .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"}' '{"statusCode":400,"error":"Bad Request","message":"Name thisIsATypo and version 0.1.4 do not match top-level directory apache-0.1.4"}'
); );
}); });

View file

@ -15,7 +15,7 @@ import {
} from '@kbn/fleet-plugin/common'; } from '@kbn/fleet-plugin/common';
import { KbnClient } from '@kbn/test'; import { KbnClient } from '@kbn/test';
import { UNINSTALL_TOKENS_SAVED_OBJECT_TYPE } from '@kbn/fleet-plugin/common'; 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'; import { FtrProviderContext } from '../api_integration/ftr_provider_context';
export function warnAndSkipTest(mochaContext: Mocha.Context, log: ToolingLog) { export function warnAndSkipTest(mochaContext: Mocha.Context, log: ToolingLog) {
@ -109,7 +109,7 @@ export async function generateAgent(
}); });
} }
export function setPrereleaseSetting(supertest: SuperTest<Test>) { export function setPrereleaseSetting(supertest: SuperTestAgent) {
before(async () => { before(async () => {
await supertest await supertest
.put('/api/fleet/settings') .put('/api/fleet/settings')
@ -126,7 +126,7 @@ export function setPrereleaseSetting(supertest: SuperTest<Test>) {
} }
export const generateNAgentPolicies = async ( export const generateNAgentPolicies = async (
supertest: SuperTest<Test>, supertest: SuperTestAgent,
number: number, number: number,
overwrite?: Partial<CreateAgentPolicyRequest['body']> overwrite?: Partial<CreateAgentPolicyRequest['body']>
): Promise<AgentPolicy[]> => { ): Promise<AgentPolicy[]> => {
@ -142,7 +142,7 @@ export const generateNAgentPolicies = async (
}; };
export const generateAgentPolicy = async ( export const generateAgentPolicy = async (
supertest: SuperTest<Test>, supertest: SuperTestAgent,
overwrite?: Partial<CreateAgentPolicyRequest['body']> overwrite?: Partial<CreateAgentPolicyRequest['body']>
): Promise<AgentPolicy> => { ): Promise<AgentPolicy> => {
const response = await supertest const response = await supertest

View file

@ -237,7 +237,7 @@ export function TransformAPIProvider({ getService }: FtrProviderContext) {
); );
const { body, status } = await esSupertest const { body, status } = await esSupertest
.put(`/_transform/${transformId}${deferValidation ? '?defer_validation=true' : ''}`) .put(`/_transform/${transformId}${deferValidation ? '?defer_validation=true' : ''}`)
.set(headers) .set(headers as Record<string, string>)
.send(transformConfig); .send(transformConfig);
this.assertResponseStatusCode(200, status, body); this.assertResponseStatusCode(200, status, body);
} else { } else {

View file

@ -24,7 +24,7 @@ import {
import { FtrProviderContext } from '../../../ftr_provider_context'; import { FtrProviderContext } from '../../../ftr_provider_context';
const createLogStashDataView = async ( const createLogStashDataView = async (
supertest: SuperTest.SuperTest<SuperTest.Test> supertest: SuperTest.Agent
): Promise<{ data_view: { id: string } }> => { ): Promise<{ data_view: { id: string } }> => {
const { body } = await supertest const { body } = await supertest
.post(`/api/data_views/data_view`) .post(`/api/data_views/data_view`)
@ -36,7 +36,7 @@ const createLogStashDataView = async (
}; };
const deleteLogStashDataView = async ( const deleteLogStashDataView = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
dataViewId: string dataViewId: string
): Promise<void> => { ): Promise<void> => {
await supertest await supertest

View file

@ -48,10 +48,7 @@ export const createSlackConnector = async ({
return connector; return connector;
}; };
export const getConnectorByName = async ( export const getConnectorByName = async (name: string, supertest: SuperTest.Agent) => {
name: string,
supertest: SuperTest.SuperTest<SuperTest.Test>
) => {
const { body } = await supertest const { body } = await supertest
.get(`/api/actions/connectors`) .get(`/api/actions/connectors`)
.set('kbn-xsrf', 'foo') .set('kbn-xsrf', 'foo')
@ -65,7 +62,7 @@ export async function createRuleWithActionsAndParams(
testRunUuid: string, testRunUuid: string,
params: Record<string, any> = {}, params: Record<string, any> = {},
overwrites: Record<string, any> = {}, overwrites: Record<string, any> = {},
supertest: SuperTest.SuperTest<SuperTest.Test> supertest: SuperTest.Agent
) { ) {
return await createAlwaysFiringRule( return await createAlwaysFiringRule(
{ {
@ -94,7 +91,7 @@ export async function createRuleWithActionsAndParams(
async function createAlwaysFiringRule( async function createAlwaysFiringRule(
overwrites: Record<string, any> = {}, overwrites: Record<string, any> = {},
supertest: SuperTest.SuperTest<SuperTest.Test> supertest: SuperTest.Agent
) { ) {
const { body: createdRule } = await supertest const { body: createdRule } = await supertest
.post(`/api/alerting/rule`) .post(`/api/alerting/rule`)
@ -109,10 +106,7 @@ async function createAlwaysFiringRule(
return createdRule; return createdRule;
} }
export async function getAlertSummary( export async function getAlertSummary(ruleId: string, supertest: SuperTest.Agent) {
ruleId: string,
supertest: SuperTest.SuperTest<SuperTest.Test>
) {
const { body: summary } = await supertest const { body: summary } = await supertest
.get(`/internal/alerting/rule/${encodeURIComponent(ruleId)}/_alert_summary`) .get(`/internal/alerting/rule/${encodeURIComponent(ruleId)}/_alert_summary`)
.expect(200); .expect(200);

View file

@ -30,10 +30,7 @@ export const getPackagesArgs = (): string[] => {
export const bundledPackagesLocation = path.join(path.dirname(__filename), '/fixtures/packages'); export const bundledPackagesLocation = path.join(path.dirname(__filename), '/fixtures/packages');
export function installPackage( export function installPackage(supertest: SuperTest.Agent, packageName: SupportedPackage) {
supertest: SuperTest.SuperTest<SuperTest.Test>,
packageName: SupportedPackage
) {
const pkg = PACKAGES.find(({ name }) => name === packageName); const pkg = PACKAGES.find(({ name }) => name === packageName);
const request = supertest const request = supertest
.post('/api/fleet/epm/packages') .post('/api/fleet/epm/packages')

View file

@ -15,7 +15,7 @@ import supertest from 'supertest';
import { format } from 'url'; import { format } from 'url';
import { Subtract } from 'utility-types'; import { Subtract } from 'utility-types';
export function createObservabilityAIAssistantApiClient(st: supertest.SuperTest<supertest.Test>) { export function createObservabilityAIAssistantApiClient(st: supertest.Agent) {
return <TEndpoint extends ObservabilityAIAssistantAPIEndpoint>( return <TEndpoint extends ObservabilityAIAssistantAPIEndpoint>(
options: { options: {
type?: 'form-data'; type?: 'form-data';
@ -70,17 +70,62 @@ type WithoutPromise<T extends Promise<any>> = Subtract<T, Promise<any>>;
// end(one:string) // end(one:string)
// end(one:string, two: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> = T extends { type OverloadedParameters<T> = T extends {
(...args: infer A1): any; (...args: infer A1): any;
(...args: infer A2): any; (...args: infer A2): any;
(...args: infer A3): any; (...args: infer A3): any;
(...args: infer A4): 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 ? 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 ? 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 ? A1 | A2
: T extends (...args: infer A) => any : T extends (...args: infer A) => any
? A ? A

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; 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'; import { FtrProviderContext } from '../../common/ftr_provider_context';
export default function ApiTest({ getService }: FtrProviderContext) { export default function ApiTest({ getService }: FtrProviderContext) {
@ -71,7 +71,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
}); });
} }
export async function deleteAllActionConnectors(supertest: SuperTest<Test>): Promise<any> { export async function deleteAllActionConnectors(supertest: SuperTestAgent): Promise<any> {
const res = await supertest.get(`/api/actions/connectors`); const res = await supertest.get(`/api/actions/connectors`);
const body = res.body as Array<{ id: string; connector_type_id: string; name: string }>; const body = res.body as Array<{ id: string; connector_type_id: string; name: string }>;

View file

@ -24,7 +24,7 @@ export type APIClientRequestParamsOf<TEndpoint extends APIEndpoint> = ClientRequ
TEndpoint TEndpoint
>; >;
export function createObsApiClient(st: supertest.SuperTest<supertest.Test>) { export function createObsApiClient(st: supertest.Agent) {
return async <TEndpoint extends APIEndpoint>( return async <TEndpoint extends APIEndpoint>(
options: { options: {
type?: 'form-data'; type?: 'form-data';

View file

@ -15,7 +15,7 @@ import type {
import type { APIEndpoint } from '@kbn/observability-onboarding-plugin/server/routes'; import type { APIEndpoint } from '@kbn/observability-onboarding-plugin/server/routes';
import { formatRequest } from '@kbn/server-route-repository'; import { formatRequest } from '@kbn/server-route-repository';
export function createObservabilityOnboardingApiClient(st: supertest.SuperTest<supertest.Test>) { export function createObservabilityOnboardingApiClient(st: supertest.Agent) {
return async <TEndpoint extends APIEndpoint>( return async <TEndpoint extends APIEndpoint>(
options: { options: {
type?: 'form-data'; type?: 'form-data';

View file

@ -10,7 +10,7 @@ import request from 'superagent';
import supertest from 'supertest'; import supertest from 'supertest';
import { format } from 'url'; import { format } from 'url';
export function createProfilingApiClient(st: supertest.SuperTest<supertest.Test>) { export function createProfilingApiClient(st: supertest.Agent) {
return async (options: { return async (options: {
endpoint: string; endpoint: string;
params?: { params?: {

View file

@ -23,7 +23,7 @@ export type BetterTest = <T extends any>(options: {
* This is useful for tests that expect a 200 response * 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. * It also makes it easier to debug tests that fail because of a 500 response.
*/ */
export function getBettertest(st: supertest.SuperTest<supertest.Test>): BetterTest { export function getBettertest(st: supertest.Agent): BetterTest {
return async ({ pathname, method = 'get', query, body }) => { return async ({ pathname, method = 'get', query, body }) => {
const url = format({ pathname, query }); const url = format({ pathname, query });
@ -60,7 +60,7 @@ export class BetterTestError extends Error {
const req = res.req as any; const req = res.req as any;
super( super(
`Unhandled BetterTestError: `Unhandled BetterTestError:
Status: "${res.status}" Status: "${res.status}"
Path: "${req.method} ${req.path}" Path: "${req.method} ${req.path}"
Body: ${JSON.stringify(res.body)}` Body: ${JSON.stringify(res.body)}`
); );

View file

@ -5,11 +5,11 @@
* 2.0. * 2.0.
*/ */
import type { SuperTest } from 'supertest'; import type { Agent as SuperTestAgent } from 'supertest';
import type { Client } from '@elastic/elasticsearch'; import type { Client } from '@elastic/elasticsearch';
import { AUTHENTICATION } from './authentication'; import { AUTHENTICATION } from './authentication';
export const createUsersAndRoles = async (es: Client, supertest: SuperTest<any>) => { export const createUsersAndRoles = async (es: Client, supertest: SuperTestAgent) => {
await supertest await supertest
.put('/api/security/role/kibana_legacy_user') .put('/api/security/role/kibana_legacy_user')
.send({ .send({

View file

@ -258,7 +258,7 @@ export function bulkCreateTestSuiteFactory(context: FtrProviderContext) {
const query = test.overwrite ? '?overwrite=true' : ''; const query = test.overwrite ? '?overwrite=true' : '';
await supertest await supertest
.post(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_create${query}`) .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_create${query}`)
.auth(user?.username, user?.password) .auth(user?.username!, user?.password!)
.send(requestBody) .send(requestBody)
.expect(test.responseStatusCode) .expect(test.responseStatusCode)
.then(test.responseBody); .then(test.responseBody);

View file

@ -138,7 +138,7 @@ export function bulkDeleteTestSuiteFactory(context: FtrProviderContext) {
const query = testForce && testForce === true ? '?force=true' : ''; const query = testForce && testForce === true ? '?force=true' : '';
await supertest await supertest
.post(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_delete${query}`) .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_delete${query}`)
.auth(user?.username, user?.password) .auth(user?.username!, user?.password!)
.send(requestBody) .send(requestBody)
.expect(test.responseStatusCode) .expect(test.responseStatusCode)
.then(test.responseBody); .then(test.responseBody);

View file

@ -125,7 +125,7 @@ export function bulkGetTestSuiteFactory(context: FtrProviderContext) {
it(`should return ${test.responseStatusCode} ${test.title}`, async () => { it(`should return ${test.responseStatusCode} ${test.title}`, async () => {
await supertest await supertest
.post(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_get`) .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_get`)
.auth(user?.username, user?.password) .auth(user?.username!, user?.password!)
.send(test.request) .send(test.request)
.expect(test.responseStatusCode) .expect(test.responseStatusCode)
.then(test.responseBody); .then(test.responseBody);

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { SuperTest } from 'supertest'; import { Agent as SuperTestAgent } from 'supertest';
import { TEST_CASES } from './resolve'; import { TEST_CASES } from './resolve';
import { SPACES } from '../lib/spaces'; import { SPACES } from '../lib/spaces';
import { import {
@ -29,7 +29,7 @@ export interface BulkResolveTestCase extends TestCase {
export { TEST_CASES }; // re-export the (non-bulk) resolve test cases export { TEST_CASES }; // re-export the (non-bulk) resolve test cases
export function bulkResolveTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>) { export function bulkResolveTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) {
const expectSavedObjectForbidden = expectResponses.forbiddenTypes('bulk_get'); const expectSavedObjectForbidden = expectResponses.forbiddenTypes('bulk_get');
const expectResponseBody = const expectResponseBody =
( (
@ -119,7 +119,7 @@ export function bulkResolveTestSuiteFactory(esArchiver: any, supertest: SuperTes
it(`should return ${test.responseStatusCode} ${test.title}`, async () => { it(`should return ${test.responseStatusCode} ${test.title}`, async () => {
await supertest await supertest
.post(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_resolve`) .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_resolve`)
.auth(user?.username, user?.password) .auth(user?.username!, user?.password!)
.send(test.request) .send(test.request)
.expect(test.responseStatusCode) .expect(test.responseStatusCode)
.then(test.responseBody); .then(test.responseBody);

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; 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 { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases';
import { SPACES } from '../lib/spaces'; import { SPACES } from '../lib/spaces';
import { expectResponses, getUrlPrefix, getTestTitle } from '../lib/saved_object_test_utils'; 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 ...(namespace && { namespace }), // individual "object namespace" string
}); });
export function bulkUpdateTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>) { export function bulkUpdateTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) {
const expectSavedObjectForbidden = expectResponses.forbiddenTypes('bulk_update'); const expectSavedObjectForbidden = expectResponses.forbiddenTypes('bulk_update');
const expectResponseBody = const expectResponseBody =
( (
@ -118,7 +118,7 @@ export function bulkUpdateTestSuiteFactory(esArchiver: any, supertest: SuperTest
const requestBody = test.request.map((x) => ({ ...x, ...attrs })); const requestBody = test.request.map((x) => ({ ...x, ...attrs }));
await supertest await supertest
.put(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_update`) .put(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_update`)
.auth(user?.username, user?.password) .auth(user?.username!, user?.password!)
.send(requestBody) .send(requestBody)
.expect(test.responseStatusCode) .expect(test.responseStatusCode)
.then(test.responseBody); .then(test.responseBody);

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; 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 { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases';
import { SPACES, ALL_SPACES_ID } from '../lib/spaces'; import { SPACES, ALL_SPACES_ID } from '../lib/spaces';
import { import {
@ -85,7 +85,7 @@ const createRequest = ({ type, id, initialNamespaces }: CreateTestCase) => ({
initialNamespaces, initialNamespaces,
}); });
export function createTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>) { export function createTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) {
const expectSavedObjectForbidden = expectResponses.forbiddenTypes('create'); const expectSavedObjectForbidden = expectResponses.forbiddenTypes('create');
const expectResponseBody = const expectResponseBody =
(testCase: CreateTestCase, user?: TestUser): ExpectResponseBody => (testCase: CreateTestCase, user?: TestUser): ExpectResponseBody =>
@ -155,7 +155,7 @@ export function createTestSuiteFactory(esArchiver: any, supertest: SuperTest<any
const query = test.overwrite ? '?overwrite=true' : ''; const query = test.overwrite ? '?overwrite=true' : '';
await supertest await supertest
.post(`${getUrlPrefix(spaceId)}/api/saved_objects/${path}${query}`) .post(`${getUrlPrefix(spaceId)}/api/saved_objects/${path}${query}`)
.auth(user?.username, user?.password) .auth(user?.username!, user?.password!)
.send(requestBody) .send(requestBody)
.expect(test.responseStatusCode) .expect(test.responseStatusCode)
.then(test.responseBody); .then(test.responseBody);

View file

@ -5,7 +5,7 @@
* 2.0. * 2.0.
*/ */
import { SuperTest } from 'supertest'; import { Agent as SuperTestAgent } from 'supertest';
import type { Client } from '@elastic/elasticsearch'; import type { Client } from '@elastic/elasticsearch';
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import type { SearchTotalHits } from '@elastic/elasticsearch/lib/api/types'; import type { SearchTotalHits } from '@elastic/elasticsearch/lib/api/types';
@ -38,7 +38,7 @@ export const TEST_CASES: Record<string, DeleteTestCase> = Object.freeze({
*/ */
const createRequest = ({ type, id, force }: DeleteTestCase) => ({ type, id, force }); const createRequest = ({ type, id, force }: DeleteTestCase) => ({ type, id, force });
export function deleteTestSuiteFactory(es: Client, esArchiver: any, supertest: SuperTest<any>) { export function deleteTestSuiteFactory(es: Client, esArchiver: any, supertest: SuperTestAgent) {
const expectSavedObjectForbidden = expectResponses.forbiddenTypes('delete'); const expectSavedObjectForbidden = expectResponses.forbiddenTypes('delete');
const expectResponseBody = const expectResponseBody =
(testCase: DeleteTestCase): ExpectResponseBody => (testCase: DeleteTestCase): ExpectResponseBody =>
@ -118,7 +118,7 @@ export function deleteTestSuiteFactory(es: Client, esArchiver: any, supertest: S
await supertest await supertest
.delete(`${getUrlPrefix(spaceId)}/api/saved_objects/${type}/${id}`) .delete(`${getUrlPrefix(spaceId)}/api/saved_objects/${type}/${id}`)
.query({ ...(force && { force }) }) .query({ ...(force && { force }) })
.auth(user?.username, user?.password) .auth(user?.username!, user?.password!)
.expect(test.responseStatusCode) .expect(test.responseStatusCode)
.then(test.responseBody); .then(test.responseBody);
}); });

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { SuperTest } from 'supertest'; import { Agent as SuperTestAgent } from 'supertest';
import { import {
SAVED_OBJECT_TEST_CASES, SAVED_OBJECT_TEST_CASES,
CONFLICT_TEST_CASES, CONFLICT_TEST_CASES,
@ -154,7 +154,7 @@ const EMPTY_RESULT = {
missingReferences: [], missingReferences: [],
}; };
export function exportTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>) { export function exportTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) {
const expectSavedObjectForbiddenBulkGet = expectResponses.forbiddenTypes('bulk_get'); const expectSavedObjectForbiddenBulkGet = expectResponses.forbiddenTypes('bulk_get');
const expectResponseBody = const expectResponseBody =
(testCase: ExportTestCase): ExpectResponseBody => (testCase: ExportTestCase): ExpectResponseBody =>
@ -259,7 +259,7 @@ export function exportTestSuiteFactory(esArchiver: any, supertest: SuperTest<any
it(`should return ${test.responseStatusCode} ${test.title}`, async () => { it(`should return ${test.responseStatusCode} ${test.title}`, async () => {
await supertest await supertest
.post(`${getUrlPrefix(spaceId)}/api/saved_objects/_export`) .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_export`)
.auth(user?.username, user?.password) .auth(user?.username!, user?.password!)
.send(test.request) .send(test.request)
.expect(test.responseStatusCode) .expect(test.responseStatusCode)
.then(test.responseBody); .then(test.responseBody);

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { SuperTest } from 'supertest'; import { Agent as SuperTestAgent } from 'supertest';
import querystring from 'querystring'; import querystring from 'querystring';
import { import {
SAVED_OBJECT_TEST_CASES, SAVED_OBJECT_TEST_CASES,
@ -187,7 +187,7 @@ export const createRequest = ({ query }: FindTestCase) => ({ query });
const getTestTitle = ({ failure, title }: FindTestCase) => const getTestTitle = ({ failure, title }: FindTestCase) =>
`${failure?.reason || 'success'} ["${title}"]`; `${failure?.reason || 'success'} ["${title}"]`;
export function findTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>) { export function findTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) {
const expectResponseBody = const expectResponseBody =
(testCase: FindTestCase, user?: TestUser): ExpectResponseBody => (testCase: FindTestCase, user?: TestUser): ExpectResponseBody =>
async (response: Record<string, any>) => { async (response: Record<string, any>) => {
@ -298,7 +298,7 @@ export function findTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>)
await supertest await supertest
.get(`${getUrlPrefix(spaceId)}/api/saved_objects/_find${query}`) .get(`${getUrlPrefix(spaceId)}/api/saved_objects/_find${query}`)
.auth(user?.username, user?.password) .auth(user?.username!, user?.password!)
.expect(test.responseStatusCode) .expect(test.responseStatusCode)
.then(test.responseBody); .then(test.responseBody);
}); });

View file

@ -5,7 +5,7 @@
* 2.0. * 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 { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases';
import { SPACES } from '../lib/spaces'; import { SPACES } from '../lib/spaces';
import { import {
@ -25,7 +25,7 @@ export type GetTestCase = TestCase;
const DOES_NOT_EXIST = Object.freeze({ type: 'dashboard', id: 'does-not-exist' }); const DOES_NOT_EXIST = Object.freeze({ type: 'dashboard', id: 'does-not-exist' });
export const TEST_CASES: Record<string, GetTestCase> = Object.freeze({ ...CASES, DOES_NOT_EXIST }); export const TEST_CASES: Record<string, GetTestCase> = Object.freeze({ ...CASES, DOES_NOT_EXIST });
export function getTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>) { export function getTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) {
const expectSavedObjectForbidden = expectResponses.forbiddenTypes('get'); const expectSavedObjectForbidden = expectResponses.forbiddenTypes('get');
const expectResponseBody = const expectResponseBody =
(testCase: GetTestCase): ExpectResponseBody => (testCase: GetTestCase): ExpectResponseBody =>
@ -81,7 +81,7 @@ export function getTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>)
const { type, id } = test.request; const { type, id } = test.request;
await supertest await supertest
.get(`${getUrlPrefix(spaceId)}/api/saved_objects/${type}/${id}`) .get(`${getUrlPrefix(spaceId)}/api/saved_objects/${type}/${id}`)
.auth(user?.username, user?.password) .auth(user?.username!, user?.password!)
.expect(test.responseStatusCode) .expect(test.responseStatusCode)
.then(test.responseBody); .then(test.responseBody);
}); });

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { SuperTest } from 'supertest'; import { Agent as SuperTestAgent } from 'supertest';
import type { Client } from '@elastic/elasticsearch'; import type { Client } from '@elastic/elasticsearch';
import type { SavedObjectReference } from '@kbn/core/server'; import type { SavedObjectReference } from '@kbn/core/server';
import { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; 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' } : {}, condition !== false ? { failureType: 'missing_references' } : {},
}; };
export function importTestSuiteFactory(es: Client, esArchiver: any, supertest: SuperTest<any>) { export function importTestSuiteFactory(es: Client, esArchiver: any, supertest: SuperTestAgent) {
const expectSavedObjectForbidden = (action: string, typeOrTypes: string | string[]) => const expectSavedObjectForbidden = (action: string, typeOrTypes: string | string[]) =>
expectResponses.forbiddenTypes(action)(typeOrTypes); expectResponses.forbiddenTypes(action)(typeOrTypes);
const expectResponseBody = const expectResponseBody =
@ -310,7 +310,7 @@ export function importTestSuiteFactory(es: Client, esArchiver: any, supertest: S
: ''; : '';
await supertest await supertest
.post(`${getUrlPrefix(spaceId)}/api/saved_objects/_import${query}`) .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') .attach('file', Buffer.from(requestBody, 'utf8'), 'export.ndjson')
.expect(test.responseStatusCode) .expect(test.responseStatusCode)
.then(test.responseBody); .then(test.responseBody);

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; 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 { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases';
import { SPACES } from '../lib/spaces'; import { SPACES } from '../lib/spaces';
import { import {
@ -70,7 +70,7 @@ export const TEST_CASES = Object.freeze({
HIDDEN: CASES.HIDDEN, HIDDEN: CASES.HIDDEN,
}); });
export function resolveTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>) { export function resolveTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) {
const expectSavedObjectForbidden = expectResponses.forbiddenTypes('bulk_get'); const expectSavedObjectForbidden = expectResponses.forbiddenTypes('bulk_get');
const expectResponseBody = const expectResponseBody =
(testCase: ResolveTestCase): ExpectResponseBody => (testCase: ResolveTestCase): ExpectResponseBody =>
@ -135,7 +135,7 @@ export function resolveTestSuiteFactory(esArchiver: any, supertest: SuperTest<an
const { type, id } = test.request; const { type, id } = test.request;
await supertest await supertest
.get(`${getUrlPrefix(spaceId)}/api/saved_objects/resolve/${type}/${id}`) .get(`${getUrlPrefix(spaceId)}/api/saved_objects/resolve/${type}/${id}`)
.auth(user?.username, user?.password) .auth(user?.username!, user?.password!)
.expect(test.responseStatusCode) .expect(test.responseStatusCode)
.then(test.responseBody); .then(test.responseBody);
}); });

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { SuperTest } from 'supertest'; import { Agent as SuperTestAgent } from 'supertest';
import type { Client } from '@elastic/elasticsearch'; import type { Client } from '@elastic/elasticsearch';
import type { SavedObjectReference, SavedObjectsImportRetry } from '@kbn/core/server'; import type { SavedObjectReference, SavedObjectsImportRetry } from '@kbn/core/server';
import { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; import { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases';
@ -197,7 +197,7 @@ export const resolveImportErrorsTestCaseFailures = {
export function resolveImportErrorsTestSuiteFactory( export function resolveImportErrorsTestSuiteFactory(
es: Client, es: Client,
esArchiver: any, esArchiver: any,
supertest: SuperTest<any> supertest: SuperTestAgent
) { ) {
const expectSavedObjectForbidden = (action: string, typeOrTypes: string | string[]) => const expectSavedObjectForbidden = (action: string, typeOrTypes: string | string[]) =>
expectResponses.forbiddenTypes(action)(typeOrTypes); expectResponses.forbiddenTypes(action)(typeOrTypes);
@ -373,7 +373,7 @@ export function resolveImportErrorsTestSuiteFactory(
const query = test.createNewCopies ? '?createNewCopies=true' : ''; const query = test.createNewCopies ? '?createNewCopies=true' : '';
await supertest await supertest
.post(`${getUrlPrefix(spaceId)}/api/saved_objects/_resolve_import_errors${query}`) .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)) .field('retries', JSON.stringify(test.request.retries))
.attach('file', Buffer.from(requestBody, 'utf8'), 'export.ndjson') .attach('file', Buffer.from(requestBody, 'utf8'), 'export.ndjson')
.expect(test.responseStatusCode) .expect(test.responseStatusCode)

View file

@ -6,7 +6,7 @@
*/ */
import expect from '@kbn/expect'; 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 { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases';
import { SPACES } from '../lib/spaces'; import { SPACES } from '../lib/spaces';
import { expectResponses, getUrlPrefix, getTestTitle } from '../lib/saved_object_test_utils'; import { expectResponses, getUrlPrefix, getTestTitle } from '../lib/saved_object_test_utils';
@ -34,7 +34,7 @@ export const TEST_CASES: Record<string, UpdateTestCase> = Object.freeze({
const createRequest = ({ type, id, upsert }: UpdateTestCase) => ({ type, id, upsert }); const createRequest = ({ type, id, upsert }: UpdateTestCase) => ({ type, id, upsert });
export function updateTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>) { export function updateTestSuiteFactory(esArchiver: any, supertest: SuperTestAgent) {
const expectSavedObjectForbidden = expectResponses.forbiddenTypes('update'); const expectSavedObjectForbidden = expectResponses.forbiddenTypes('update');
const expectResponseBody = const expectResponseBody =
(testCase: UpdateTestCase): ExpectResponseBody => (testCase: UpdateTestCase): ExpectResponseBody =>
@ -94,7 +94,7 @@ export function updateTestSuiteFactory(esArchiver: any, supertest: SuperTest<any
const requestBody = { attributes, ...(upsert && { upsert: attributes }) }; const requestBody = { attributes, ...(upsert && { upsert: attributes }) };
await supertest await supertest
.put(`${getUrlPrefix(spaceId)}/api/saved_objects/${type}/${id}`) .put(`${getUrlPrefix(spaceId)}/api/saved_objects/${type}/${id}`)
.auth(user?.username, user?.password) .auth(user?.username!, user?.password!)
.send(requestBody) .send(requestBody)
.expect(test.responseStatusCode) .expect(test.responseStatusCode)
.then(test.responseBody); .then(test.responseBody);

View file

@ -43,7 +43,7 @@ interface Host {
* @returns The array of hosts sorted * @returns The array of hosts sorted
*/ */
export const getHostHits = async ( export const getHostHits = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
log: ToolingLog, log: ToolingLog,
id: string id: string
): Promise<Host[]> => { ): Promise<Host[]> => {

View file

@ -10,10 +10,7 @@ import supertest from 'supertest';
import { NodeMetrics } from '@kbn/task-manager-plugin/server/routes/metrics'; import { NodeMetrics } from '@kbn/task-manager-plugin/server/routes/metrics';
import { RetryService } from '@kbn/ftr-common-functional-services'; import { RetryService } from '@kbn/ftr-common-functional-services';
export const getMetricsRequest = ( export const getMetricsRequest = (request: supertest.Agent, reset: boolean = false) => {
request: supertest.SuperTest<supertest.Test>,
reset: boolean = false
) => {
return request return request
.get(`/api/task_manager/metrics${reset ? '' : '?reset=false'}`) .get(`/api/task_manager/metrics${reset ? '' : '?reset=false'}`)
.set('kbn-xsrf', 'foo') .set('kbn-xsrf', 'foo')
@ -22,7 +19,7 @@ export const getMetricsRequest = (
}; };
export const getMetricsWithRetry = ( export const getMetricsWithRetry = (
request: supertest.SuperTest<supertest.Test>, request: supertest.Agent,
retry: RetryService, retry: RetryService,
reset: boolean = false, reset: boolean = false,
callback?: (metrics: NodeMetrics) => boolean callback?: (metrics: NodeMetrics) => boolean

View file

@ -17,9 +17,7 @@ import { getWebHookAction } from './get_web_hook_action';
* *
* @param supertest The supertest deps * @param supertest The supertest deps
*/ */
export const createWebHookRuleAction = async ( export const createWebHookRuleAction = async (supertest: SuperTest.Agent): Promise<RuleAction> => {
supertest: SuperTest.SuperTest<SuperTest.Test>
): Promise<RuleAction> => {
return ( return (
await supertest await supertest
.post('/api/actions/action') .post('/api/actions/action')

View file

@ -18,7 +18,7 @@ import { refreshIndex } from '..';
import { getAlertsByIds, waitForRuleStatus } from '../../../../../common/utils/security_solution'; import { getAlertsByIds, waitForRuleStatus } from '../../../../../common/utils/security_solution';
export type GetAlerts = ( export type GetAlerts = (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
log: ToolingLog, log: ToolingLog,
es: Client, es: Client,
rule: RuleResponse, rule: RuleResponse,

View file

@ -21,7 +21,7 @@ export const finalizeAlertsMigration = async ({
supertest, supertest,
log, log,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
log: ToolingLog; log: ToolingLog;
migrationIds: string[]; migrationIds: string[];
}): Promise<FinalizeMigrationResponse[]> => { }): Promise<FinalizeMigrationResponse[]> => {

View file

@ -21,7 +21,7 @@ export const startAlertsMigration = async ({
supertest, supertest,
log, log,
}: { }: {
supertest: SuperTest.SuperTest<SuperTest.Test>; supertest: SuperTest.Agent;
log: ToolingLog; log: ToolingLog;
indices: string[]; indices: string[];
}): Promise<CreateMigrationResponse[]> => { }): Promise<CreateMigrationResponse[]> => {

View file

@ -11,7 +11,7 @@ import type SuperTest from 'supertest';
import { waitFor } from '../../../../../common/utils/security_solution'; import { waitFor } from '../../../../../common/utils/security_solution';
export const waitForAlertToComplete = async ( export const waitForAlertToComplete = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
log: ToolingLog, log: ToolingLog,
id: string id: string
): Promise<void> => { ): Promise<void> => {

View file

@ -15,7 +15,7 @@ export interface CreateConnectorBody {
} }
export async function createConnector( export async function createConnector(
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
connector: CreateConnectorBody, connector: CreateConnectorBody,
id = '' id = ''
): Promise<string> { ): Promise<string> {

View file

@ -7,9 +7,6 @@
import type SuperTest from 'supertest'; import type SuperTest from 'supertest';
export function deleteConnector( export function deleteConnector(supertest: SuperTest.Agent, connectorId: string): SuperTest.Test {
supertest: SuperTest.SuperTest<SuperTest.Test>,
connectorId: string
): SuperTest.Test {
return supertest.delete(`/api/actions/connector/${connectorId}`).set('kbn-xsrf', 'foo'); return supertest.delete(`/api/actions/connector/${connectorId}`).set('kbn-xsrf', 'foo');
} }

View file

@ -9,7 +9,7 @@ import { Connector } from '@kbn/actions-plugin/server/application/connector/type
import type SuperTest from 'supertest'; import type SuperTest from 'supertest';
export async function getConnector( export async function getConnector(
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
connectorId: string connectorId: string
): Promise<Connector> { ): Promise<Connector> {
const response = await supertest const response = await supertest

View file

@ -22,7 +22,7 @@ import { EXCEPTION_LIST_ITEM_URL } from '@kbn/securitysolution-list-constants';
* @param log The tooling logger * @param log The tooling logger
*/ */
export const createExceptionListItem = async ( export const createExceptionListItem = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
log: ToolingLog, log: ToolingLog,
exceptionListItem: CreateExceptionListItemSchema exceptionListItem: CreateExceptionListItemSchema
): Promise<ExceptionListItemSchema> => { ): Promise<ExceptionListItemSchema> => {

View file

@ -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 * @param osTypes The os types to optionally add or not to add to the container
*/ */
export const createContainerWithEndpointEntries = async ( export const createContainerWithEndpointEntries = async (
supertest: SuperTest.SuperTest<SuperTest.Test>, supertest: SuperTest.Agent,
log: ToolingLog, log: ToolingLog,
endpointEntries: Array<{ endpointEntries: Array<{
entries: NonEmptyEntriesArray; entries: NonEmptyEntriesArray;

Some files were not shown because too many files have changed in this diff Show more