Removes supertest-as-promised dependency (#100486)

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
This commit is contained in:
Tyler Smalley 2021-08-16 18:01:34 -07:00 committed by GitHub
parent e6d446acd7
commit 689d974729
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 106 additions and 134 deletions

View file

@ -632,7 +632,6 @@
"@types/strong-log-transformer": "^1.0.0", "@types/strong-log-transformer": "^1.0.0",
"@types/styled-components": "^5.1.0", "@types/styled-components": "^5.1.0",
"@types/supertest": "^2.0.5", "@types/supertest": "^2.0.5",
"@types/supertest-as-promised": "^2.0.38",
"@types/tapable": "^1.0.6", "@types/tapable": "^1.0.6",
"@types/tar": "^4.0.3", "@types/tar": "^4.0.3",
"@types/tar-fs": "^1.16.1", "@types/tar-fs": "^1.16.1",
@ -824,7 +823,6 @@
"stylelint-scss": "^3.18.0", "stylelint-scss": "^3.18.0",
"superagent": "^3.8.2", "superagent": "^3.8.2",
"supertest": "^3.1.0", "supertest": "^3.1.0",
"supertest-as-promised": "^4.0.2",
"supports-color": "^7.0.0", "supports-color": "^7.0.0",
"tape": "^5.0.1", "tape": "^5.0.1",
"tar-fs": "^2.1.0", "tar-fs": "^2.1.0",

View file

@ -53,7 +53,7 @@ export default function () {
To consume the test server, use can use something like supertest to send request. Just make sure that you disable your test suite if the user doesn't choose to enable your docker server: To consume the test server, use can use something like supertest to send request. Just make sure that you disable your test suite if the user doesn't choose to enable your docker server:
```ts ```ts
import makeSupertest from 'supertest-as-promised'; import supertest from 'supertest';
import { FtrProviderContext } from '../ftr_provider_context'; import { FtrProviderContext } from '../ftr_provider_context';
export default function ({ getService }: FtrProviderContext) { export default function ({ getService }: FtrProviderContext) {
@ -61,7 +61,7 @@ export default function ({ getService }: FtrProviderContext) {
const log = getService('log'); const log = getService('log');
const server = dockerServers.get('helloWorld'); const server = dockerServers.get('helloWorld');
const supertest = makeSupertest(server.url); const request = supertest(server.url);
describe('test suite name', function () { describe('test suite name', function () {
if (!server.enabled) { if (!server.enabled) {
@ -72,7 +72,7 @@ export default function ({ getService }: FtrProviderContext) {
} }
it('test name', async () => { it('test name', async () => {
await supertest.get('/foo/bar').expect(200); await request.get('/foo/bar').expect(200);
}); });
}); });
} }

View file

@ -9,12 +9,12 @@
import { FtrProviderContext } from 'test/functional/ftr_provider_context'; import { FtrProviderContext } from 'test/functional/ftr_provider_context';
import { format as formatUrl } from 'url'; import { format as formatUrl } from 'url';
import supertestAsPromised from 'supertest-as-promised'; import supertest from 'supertest';
export function KibanaSupertestProvider({ getService }: FtrProviderContext) { export function KibanaSupertestProvider({ getService }: FtrProviderContext) {
const config = getService('config'); const config = getService('config');
const kibanaServerUrl = formatUrl(config.get('servers.kibana')); const kibanaServerUrl = formatUrl(config.get('servers.kibana'));
return supertestAsPromised(kibanaServerUrl); return supertest(kibanaServerUrl);
} }
export function ElasticsearchSupertestProvider({ getService }: FtrProviderContext) { export function ElasticsearchSupertestProvider({ getService }: FtrProviderContext) {
@ -27,6 +27,5 @@ export function ElasticsearchSupertestProvider({ getService }: FtrProviderContex
agentOptions = { ca: esServerConfig!.certificateAuthorities }; agentOptions = { ca: esServerConfig!.certificateAuthorities };
} }
// @ts-ignore - supertestAsPromised doesn't like the agentOptions, but still passes it correctly to supertest return supertest.agent(elasticSearchServerUrl, agentOptions);
return supertestAsPromised.agent(elasticSearchServerUrl, agentOptions);
} }

View file

@ -7,7 +7,7 @@
*/ */
import { format as formatUrl } from 'url'; import { format as formatUrl } from 'url';
import supertestAsPromised from 'supertest-as-promised'; import supertest from 'supertest';
import { Role } from './role'; import { Role } from './role';
import { User } from './user'; import { User } from './user';
@ -110,7 +110,7 @@ export function TestUserSupertestProvider({ getService }: FtrProviderContext) {
const config = getService('config'); const config = getService('config');
const kibanaServerConfig = config.get('servers.kibana'); const kibanaServerConfig = config.get('servers.kibana');
return supertestAsPromised( return supertest(
formatUrl({ formatUrl({
...kibanaServerConfig, ...kibanaServerConfig,
auth: `${TEST_USER_NAME}:${TEST_USER_PASSWORD}`, auth: `${TEST_USER_NAME}:${TEST_USER_PASSWORD}`,

View file

@ -9,10 +9,10 @@
import { FtrProviderContext } from 'test/functional/ftr_provider_context'; import { FtrProviderContext } from 'test/functional/ftr_provider_context';
import { format as formatUrl } from 'url'; import { format as formatUrl } from 'url';
import supertestAsPromised from 'supertest-as-promised'; import supertest from 'supertest';
export function KibanaSupertestProvider({ getService }: FtrProviderContext) { export function KibanaSupertestProvider({ getService }: FtrProviderContext) {
const config = getService('config'); const config = getService('config');
const kibanaServerUrl = formatUrl(config.get('servers.kibana')); const kibanaServerUrl = formatUrl(config.get('servers.kibana'));
return supertestAsPromised(kibanaServerUrl); return supertest(kibanaServerUrl);
} }

View file

@ -8,7 +8,7 @@
import { format as formatUrl } from 'url'; import { format as formatUrl } from 'url';
import supertestAsPromised from 'supertest-as-promised'; import supertest from 'supertest';
export function createKibanaSupertestProvider({ certificateAuthorities, kibanaUrl } = {}) { export function createKibanaSupertestProvider({ certificateAuthorities, kibanaUrl } = {}) {
return function ({ getService }) { return function ({ getService }) {
@ -16,8 +16,8 @@ export function createKibanaSupertestProvider({ certificateAuthorities, kibanaUr
kibanaUrl = kibanaUrl ?? formatUrl(config.get('servers.kibana')); kibanaUrl = kibanaUrl ?? formatUrl(config.get('servers.kibana'));
return certificateAuthorities return certificateAuthorities
? supertestAsPromised.agent(kibanaUrl, { ca: certificateAuthorities }) ? supertest.agent(kibanaUrl, { ca: certificateAuthorities })
: supertestAsPromised(kibanaUrl); : supertest(kibanaUrl);
}; };
} }
@ -25,7 +25,7 @@ export function KibanaSupertestWithoutAuthProvider({ getService }) {
const config = getService('config'); const config = getService('config');
const kibanaServerConfig = config.get('servers.kibana'); const kibanaServerConfig = config.get('servers.kibana');
return supertestAsPromised( return supertest(
formatUrl({ formatUrl({
...kibanaServerConfig, ...kibanaServerConfig,
auth: false, auth: false,
@ -36,5 +36,5 @@ export function KibanaSupertestWithoutAuthProvider({ getService }) {
export function ElasticsearchSupertestProvider({ getService }) { export function ElasticsearchSupertestProvider({ getService }) {
const config = getService('config'); const config = getService('config');
const elasticSearchServerUrl = formatUrl(config.get('servers.elasticsearch')); const elasticSearchServerUrl = formatUrl(config.get('servers.elasticsearch'));
return supertestAsPromised(elasticSearchServerUrl); return supertest(elasticSearchServerUrl);
} }

View file

@ -5,13 +5,12 @@
* 2.0. * 2.0.
*/ */
import Supertest from 'supertest'; import type SuperTest from 'supertest';
import supertestAsPromised from 'supertest-as-promised';
import uuid from 'uuid'; import uuid from 'uuid';
import { TimelineType } from '../../../../../plugins/security_solution/common/types/timeline'; import { TimelineType } from '../../../../../plugins/security_solution/common/types/timeline';
export const createBasicTimeline = async ( export const createBasicTimeline = async (
supertest: Supertest.SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
titleToSaved: string titleToSaved: string
) => ) =>
await supertest await supertest
@ -26,7 +25,7 @@ export const createBasicTimeline = async (
}); });
export const createBasicTimelineTemplate = async ( export const createBasicTimelineTemplate = async (
supertest: Supertest.SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
titleToSaved: string titleToSaved: string
) => ) =>
await supertest await supertest

View file

@ -7,8 +7,7 @@
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import moment from 'moment'; import moment from 'moment';
import type { SuperTest } from 'supertest'; import type SuperTest from 'supertest';
import type supertestAsPromised from 'supertest-as-promised';
import deepmerge from 'deepmerge'; import deepmerge from 'deepmerge';
import type { FtrProviderContext } from '../../ftr_provider_context'; import type { FtrProviderContext } from '../../ftr_provider_context';
@ -29,7 +28,7 @@ import { assertTelemetryPayload } from '../../../../../test/api_integration/apis
* @param timestamp The new timestamp to be set * @param timestamp The new timestamp to be set
*/ */
function updateMonitoringDates( function updateMonitoringDates(
esSupertest: SuperTest<supertestAsPromised.Test>, esSupertest: SuperTest.SuperTest<SuperTest.Test>,
fromTimestamp: string, fromTimestamp: string,
toTimestamp: string, toTimestamp: string,
timestamp: string timestamp: string

View file

@ -7,7 +7,7 @@
import { format as formatUrl } from 'url'; import { format as formatUrl } from 'url';
import supertestAsPromised from 'supertest-as-promised'; import supertest from 'supertest';
/** /**
* Supertest provider that doesn't include user credentials into base URL that is passed * Supertest provider that doesn't include user credentials into base URL that is passed
@ -17,7 +17,7 @@ export function EsSupertestWithoutAuthProvider({ getService }) {
const config = getService('config'); const config = getService('config');
const elasticsearchServerConfig = config.get('servers.elasticsearch'); const elasticsearchServerConfig = config.get('servers.elasticsearch');
return supertestAsPromised( return supertest(
formatUrl({ formatUrl({
...elasticsearchServerConfig, ...elasticsearchServerConfig,
auth: false, auth: false,

View file

@ -7,17 +7,17 @@
import { format as formatUrl } from 'url'; import { format as formatUrl } from 'url';
import supertestAsPromised from 'supertest-as-promised'; import supertest from 'supertest';
/** /**
* Supertest provider that doesn't include user credentials into base URL that is passed * supertest provider that doesn't include user credentials into base URL that is passed
* to the supertest. It's used to test API behaviour for not yet authenticated user. * to the supertest. It's used to test API behaviour for not yet authenticated user.
*/ */
export function SupertestWithoutAuthProvider({ getService }) { export function SupertestWithoutAuthProvider({ getService }) {
const config = getService('config'); const config = getService('config');
const kibanaServerConfig = config.get('servers.kibana'); const kibanaServerConfig = config.get('servers.kibana');
return supertestAsPromised( return supertest(
formatUrl({ formatUrl({
...kibanaServerConfig, ...kibanaServerConfig,
auth: false, auth: false,

View file

@ -10,8 +10,7 @@ import expect from '@kbn/expect';
import type { ApiResponse, estypes } from '@elastic/elasticsearch'; import type { ApiResponse, estypes } from '@elastic/elasticsearch';
import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; import type { KibanaClient } from '@elastic/elasticsearch/api/kibana';
import * as st from 'supertest'; import type SuperTest from 'supertest';
import supertestAsPromised from 'supertest-as-promised';
import { ObjectRemover as ActionsRemover } from '../../../alerting_api_integration/common/lib'; import { ObjectRemover as ActionsRemover } from '../../../alerting_api_integration/common/lib';
import { import {
CASES_URL, CASES_URL,
@ -122,7 +121,7 @@ export const setStatus = async ({
cases, cases,
type, type,
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
cases: SetStatusCasesParams[]; cases: SetStatusCasesParams[];
type: 'case' | 'sub_case'; type: 'case' | 'sub_case';
}): Promise<CasesResponse | SubCasesResponse> => { }): Promise<CasesResponse | SubCasesResponse> => {
@ -160,7 +159,7 @@ export interface CreateSubCaseResp {
* generated alert style comment which can be overridden. * generated alert style comment which can be overridden.
*/ */
export const createSubCase = async (args: { export const createSubCase = async (args: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
comment?: ContextTypeGeneratedAlertType; comment?: ContextTypeGeneratedAlertType;
caseID?: string; caseID?: string;
caseInfo?: CasePostRequest; caseInfo?: CasePostRequest;
@ -172,7 +171,7 @@ export const createSubCase = async (args: {
/** /**
* Add case as a connector * Add case as a connector
*/ */
export const createCaseAction = async (supertest: st.SuperTest<supertestAsPromised.Test>) => { export const createCaseAction = async (supertest: SuperTest.SuperTest<SuperTest.Test>) => {
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')
@ -189,7 +188,7 @@ export const createCaseAction = async (supertest: st.SuperTest<supertestAsPromis
* Remove a connector * Remove a connector
*/ */
export const deleteCaseAction = async ( export const deleteCaseAction = async (
supertest: st.SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
id: string id: string
) => { ) => {
await supertest.delete(`/api/actions/connector/${id}`).set('kbn-xsrf', 'foo'); await supertest.delete(`/api/actions/connector/${id}`).set('kbn-xsrf', 'foo');
@ -208,7 +207,7 @@ export const createSubCaseComment = async ({
forceNewSubCase = false, forceNewSubCase = false,
actionID, actionID,
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
comment?: ContextTypeGeneratedAlertType; comment?: ContextTypeGeneratedAlertType;
caseID?: string; caseID?: string;
caseInfo?: CasePostRequest; caseInfo?: CasePostRequest;
@ -658,7 +657,7 @@ export const createCaseWithConnector = async ({
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
createCaseReq = getPostCaseRequest(), createCaseReq = getPostCaseRequest(),
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
servicenowSimulatorURL: string; servicenowSimulatorURL: string;
actionsRemover: ActionsRemover; actionsRemover: ActionsRemover;
configureReq?: Record<string, unknown>; configureReq?: Record<string, unknown>;
@ -717,7 +716,7 @@ export const createCaseWithConnector = async ({
}; };
export const createCase = async ( export const createCase = async (
supertest: st.SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
params: CasePostRequest, params: CasePostRequest,
expectedHttpCode: number = 200, expectedHttpCode: number = 200,
auth: { user: User; space: string | null } = { user: superUser, space: null } auth: { user: User; space: string | null } = { user: superUser, space: null }
@ -741,7 +740,7 @@ export const deleteCases = async ({
expectedHttpCode = 204, expectedHttpCode = 204,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
caseIDs: string[]; caseIDs: string[];
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -766,7 +765,7 @@ export const createComment = async ({
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
expectedHttpCode = 200, expectedHttpCode = 200,
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string; caseId: string;
params: CommentRequest; params: CommentRequest;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -788,7 +787,7 @@ export const updateCase = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
params: CasesPatchRequest; params: CasesPatchRequest;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -809,7 +808,7 @@ export const getCaseUserActions = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
caseID: string; caseID: string;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -828,7 +827,7 @@ export const deleteComment = async ({
expectedHttpCode = 204, expectedHttpCode = 204,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string; caseId: string;
commentId: string; commentId: string;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -850,7 +849,7 @@ export const deleteAllComments = async ({
expectedHttpCode = 204, expectedHttpCode = 204,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string; caseId: string;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -871,7 +870,7 @@ export const getAllComments = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string; caseId: string;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
expectedHttpCode?: number; expectedHttpCode?: number;
@ -891,7 +890,7 @@ export const getComment = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string; caseId: string;
commentId: string; commentId: string;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -912,7 +911,7 @@ export const updateComment = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string; caseId: string;
req: CommentPatchRequest; req: CommentPatchRequest;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -934,7 +933,7 @@ export const getConfiguration = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
query?: Record<string, unknown>; query?: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -950,7 +949,7 @@ export const getConfiguration = async ({
}; };
export const createConfiguration = async ( export const createConfiguration = async (
supertest: st.SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
req: CasesConfigureRequest = getConfigurationRequest(), req: CasesConfigureRequest = getConfigurationRequest(),
expectedHttpCode: number = 200, expectedHttpCode: number = 200,
auth: { user: User; space: string | null } = { user: superUser, space: null } auth: { user: User; space: string | null } = { user: superUser, space: null }
@ -975,7 +974,7 @@ export const createConnector = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
req: Record<string, unknown>; req: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -995,7 +994,7 @@ export const getCaseConnectors = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
}): Promise<FindActionResult[]> => { }): Promise<FindActionResult[]> => {
@ -1008,7 +1007,7 @@ export const getCaseConnectors = async ({
}; };
export const updateConfiguration = async ( export const updateConfiguration = async (
supertest: st.SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
id: string, id: string,
req: CasesConfigurePatch, req: CasesConfigurePatch,
expectedHttpCode: number = 200, expectedHttpCode: number = 200,
@ -1030,7 +1029,7 @@ export const getAllCasesStatuses = async ({
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
query = {}, query = {},
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
query?: Record<string, unknown>; query?: Record<string, unknown>;
@ -1051,7 +1050,7 @@ export const getCase = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string; caseId: string;
includeComments?: boolean; includeComments?: boolean;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -1074,7 +1073,7 @@ export const findCases = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
query?: Record<string, unknown>; query?: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -1097,7 +1096,7 @@ export const getCasesByAlert = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
alertID: string; alertID: string;
query?: Record<string, unknown>; query?: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -1118,7 +1117,7 @@ export const getTags = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
query?: Record<string, unknown>; query?: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -1139,7 +1138,7 @@ export const getReporters = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
query?: Record<string, unknown>; query?: Record<string, unknown>;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };
@ -1161,7 +1160,7 @@ export const pushCase = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string; caseId: string;
connectorId: string; connectorId: string;
expectedHttpCode?: number; expectedHttpCode?: number;
@ -1183,7 +1182,7 @@ export const getAlertsAttachedToCase = async ({
expectedHttpCode = 200, expectedHttpCode = 200,
auth = { user: superUser, space: null }, auth = { user: superUser, space: null },
}: { }: {
supertest: st.SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string; caseId: string;
expectedHttpCode?: number; expectedHttpCode?: number;
auth?: { user: User; space: string | null }; auth?: { user: User; space: string | null };

View file

@ -10,8 +10,7 @@ import type { ApiResponse } from '@elastic/elasticsearch';
import { Context } from '@elastic/elasticsearch/lib/Transport'; import { Context } from '@elastic/elasticsearch/lib/Transport';
import type { estypes } from '@elastic/elasticsearch'; import type { estypes } from '@elastic/elasticsearch';
import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; import type { KibanaClient } from '@elastic/elasticsearch/api/kibana';
import { SuperTest } from 'supertest'; import type SuperTest from 'supertest';
import supertestAsPromised from 'supertest-as-promised';
import type { import type {
ListArray, ListArray,
NonEmptyEntriesArray, NonEmptyEntriesArray,
@ -400,7 +399,7 @@ export const getSimpleMlRuleOutput = (ruleId = 'rule-1'): Partial<RulesSchema> =
* @param supertest The supertest agent. * @param supertest The supertest agent.
*/ */
export const deleteAllAlerts = async ( export const deleteAllAlerts = async (
supertest: SuperTest<supertestAsPromised.Test> supertest: SuperTest.SuperTest<SuperTest.Test>
): Promise<void> => { ): Promise<void> => {
await countDownTest( await countDownTest(
async () => { async () => {
@ -488,7 +487,7 @@ export const deleteAllRulesStatuses = async (es: KibanaClient): Promise<void> =>
* @param supertest The supertest client library * @param supertest The supertest client library
*/ */
export const createSignalsIndex = async ( export const createSignalsIndex = async (
supertest: SuperTest<supertestAsPromised.Test> supertest: SuperTest.SuperTest<SuperTest.Test>
): Promise<void> => { ): Promise<void> => {
await countDownTest(async () => { await countDownTest(async () => {
await supertest.post(DETECTION_ENGINE_INDEX_URL).set('kbn-xsrf', 'true').send(); await supertest.post(DETECTION_ENGINE_INDEX_URL).set('kbn-xsrf', 'true').send();
@ -501,7 +500,7 @@ export const createSignalsIndex = async (
* @param supertest The supertest client library * @param supertest The supertest client library
*/ */
export const deleteSignalsIndex = async ( export const deleteSignalsIndex = async (
supertest: SuperTest<supertestAsPromised.Test> supertest: SuperTest.SuperTest<SuperTest.Test>
): Promise<void> => { ): Promise<void> => {
await countDownTest(async () => { await countDownTest(async () => {
await supertest.delete(DETECTION_ENGINE_INDEX_URL).set('kbn-xsrf', 'true').send(); await supertest.delete(DETECTION_ENGINE_INDEX_URL).set('kbn-xsrf', 'true').send();
@ -887,7 +886,7 @@ export const countDownTest = async (
* @param rule The rule to create * @param rule The rule to create
*/ */
export const createRule = async ( export const createRule = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
rule: CreateRulesSchema rule: CreateRulesSchema
): Promise<FullResponseSchema> => { ): Promise<FullResponseSchema> => {
const { body } = await supertest const { body } = await supertest
@ -905,7 +904,7 @@ export const createRule = async (
* @param rule The rule to create * @param rule The rule to create
*/ */
export const updateRule = async ( export const updateRule = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
updatedRule: UpdateRulesSchema updatedRule: UpdateRulesSchema
): Promise<FullResponseSchema> => { ): Promise<FullResponseSchema> => {
const { body } = await supertest const { body } = await supertest
@ -921,7 +920,7 @@ export const updateRule = async (
* creates a new action and expects a 200 and does not do any retries. * creates a new action and expects a 200 and does not do any retries.
* @param supertest The supertest deps * @param supertest The supertest deps
*/ */
export const createNewAction = async (supertest: SuperTest<supertestAsPromised.Test>) => { export const createNewAction = async (supertest: SuperTest.SuperTest<SuperTest.Test>) => {
const { body } = await supertest const { body } = await supertest
.post('/api/actions/action') .post('/api/actions/action')
.set('kbn-xsrf', 'true') .set('kbn-xsrf', 'true')
@ -936,7 +935,7 @@ export const createNewAction = async (supertest: SuperTest<supertestAsPromised.T
* @param supertest The supertest deps * @param supertest The supertest deps
*/ */
export const findImmutableRuleById = async ( export const findImmutableRuleById = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
ruleId: string ruleId: string
): Promise<{ ): Promise<{
page: number; page: number;
@ -960,7 +959,7 @@ export const findImmutableRuleById = async (
* @param supertest The supertest deps * @param supertest The supertest deps
*/ */
export const getPrePackagedRulesStatus = async ( export const getPrePackagedRulesStatus = async (
supertest: SuperTest<supertestAsPromised.Test> supertest: SuperTest.SuperTest<SuperTest.Test>
): Promise<PrePackagedRulesAndTimelinesStatusSchema> => { ): Promise<PrePackagedRulesAndTimelinesStatusSchema> => {
const { body } = await supertest const { body } = await supertest
.get(`${DETECTION_ENGINE_PREPACKAGED_URL}/_status`) .get(`${DETECTION_ENGINE_PREPACKAGED_URL}/_status`)
@ -977,7 +976,7 @@ export const getPrePackagedRulesStatus = async (
* @param rule The rule to create * @param rule The rule to create
*/ */
export const createExceptionList = async ( export const createExceptionList = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
exceptionList: CreateExceptionListSchema exceptionList: CreateExceptionListSchema
): Promise<ExceptionListSchema> => { ): Promise<ExceptionListSchema> => {
const { body } = await supertest const { body } = await supertest
@ -995,7 +994,7 @@ export const createExceptionList = async (
* @param rule The rule to create * @param rule The rule to create
*/ */
export const createExceptionListItem = async ( export const createExceptionListItem = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
exceptionListItem: CreateExceptionListItemSchema exceptionListItem: CreateExceptionListItemSchema
): Promise<ExceptionListItemSchema> => { ): Promise<ExceptionListItemSchema> => {
const { body } = await supertest const { body } = await supertest
@ -1013,7 +1012,7 @@ export const createExceptionListItem = async (
* @param rule The rule to create * @param rule The rule to create
*/ */
export const getRule = async ( export const getRule = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
ruleId: string ruleId: string
): Promise<RulesSchema> => { ): Promise<RulesSchema> => {
const { body } = await supertest const { body } = await supertest
@ -1024,7 +1023,7 @@ export const getRule = async (
}; };
export const waitForAlertToComplete = async ( export const waitForAlertToComplete = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
id: string id: string
): Promise<void> => { ): Promise<void> => {
await waitFor(async () => { await waitFor(async () => {
@ -1042,7 +1041,7 @@ export const waitForAlertToComplete = async (
* @param supertest Deps * @param supertest Deps
*/ */
export const waitForRuleSuccessOrStatus = async ( export const waitForRuleSuccessOrStatus = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
id: string, id: string,
status: 'succeeded' | 'failed' | 'partial failure' | 'warning' = 'succeeded' status: 'succeeded' | 'failed' | 'partial failure' | 'warning' = 'succeeded'
): Promise<void> => { ): Promise<void> => {
@ -1063,7 +1062,7 @@ export const waitForRuleSuccessOrStatus = async (
* @param numberOfSignals The number of signals to wait for, default is 1 * @param numberOfSignals The number of signals to wait for, default is 1
*/ */
export const waitForSignalsToBePresent = async ( export const waitForSignalsToBePresent = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
numberOfSignals = 1, numberOfSignals = 1,
signalIds: string[] signalIds: string[]
): Promise<void> => { ): Promise<void> => {
@ -1078,7 +1077,7 @@ export const waitForSignalsToBePresent = async (
* @param supertest Deps * @param supertest Deps
*/ */
export const getSignalsByRuleIds = async ( export const getSignalsByRuleIds = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
ruleIds: string[] ruleIds: string[]
): Promise< ): Promise<
estypes.SearchResponse<{ estypes.SearchResponse<{
@ -1103,7 +1102,7 @@ export const getSignalsByRuleIds = async (
* @param ids Array of the rule ids * @param ids Array of the rule ids
*/ */
export const getSignalsByIds = async ( export const getSignalsByIds = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
ids: string[], ids: string[],
size?: number size?: number
): Promise< ): Promise<
@ -1128,7 +1127,7 @@ export const getSignalsByIds = async (
* @param ids Rule id * @param ids Rule id
*/ */
export const getSignalsById = async ( export const getSignalsById = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
id: string id: string
): Promise< ): Promise<
estypes.SearchResponse<{ estypes.SearchResponse<{
@ -1147,7 +1146,7 @@ export const getSignalsById = async (
}; };
export const installPrePackagedRules = async ( export const installPrePackagedRules = async (
supertest: SuperTest<supertestAsPromised.Test> supertest: SuperTest.SuperTest<SuperTest.Test>
): Promise<void> => { ): Promise<void> => {
await countDownTest(async () => { await countDownTest(async () => {
const { status } = await supertest const { status } = await supertest
@ -1166,7 +1165,7 @@ export const installPrePackagedRules = async (
* @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<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
endpointEntries: Array<{ endpointEntries: Array<{
entries: NonEmptyEntriesArray; entries: NonEmptyEntriesArray;
osTypes: OsTypeArray | undefined; osTypes: OsTypeArray | undefined;
@ -1226,7 +1225,7 @@ export const createContainerWithEndpointEntries = async (
* @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 createContainerWithEntries = async ( export const createContainerWithEntries = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
entries: NonEmptyEntriesArray[] entries: NonEmptyEntriesArray[]
): Promise<ListArray> => { ): Promise<ListArray> => {
// If not given any endpoint entries, return without any // If not given any endpoint entries, return without any
@ -1284,7 +1283,7 @@ export const createContainerWithEntries = async (
* @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 createRuleWithExceptionEntries = async ( export const createRuleWithExceptionEntries = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
rule: CreateRulesSchema, rule: CreateRulesSchema,
entries: NonEmptyEntriesArray[], entries: NonEmptyEntriesArray[],
endpointEntries?: Array<{ endpointEntries?: Array<{
@ -1367,7 +1366,7 @@ export const startSignalsMigration = async ({
indices, indices,
supertest, supertest,
}: { }: {
supertest: SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
indices: string[]; indices: string[];
}): Promise<CreateMigrationResponse[]> => { }): Promise<CreateMigrationResponse[]> => {
const { const {
@ -1391,7 +1390,7 @@ export const finalizeSignalsMigration = async ({
migrationIds, migrationIds,
supertest, supertest,
}: { }: {
supertest: SuperTest<supertestAsPromised.Test>; supertest: SuperTest.SuperTest<SuperTest.Test>;
migrationIds: string[]; migrationIds: string[];
}): Promise<FinalizeMigrationResponse[]> => { }): Promise<FinalizeMigrationResponse[]> => {
const { const {
@ -1406,7 +1405,7 @@ export const finalizeSignalsMigration = async ({
}; };
export const getOpenSignals = async ( export const getOpenSignals = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
es: KibanaClient, es: KibanaClient,
rule: FullResponseSchema rule: FullResponseSchema
) => { ) => {

View file

@ -5,7 +5,7 @@
* 2.0. * 2.0.
*/ */
import supertestAsPromised from 'supertest-as-promised'; import supertest from 'supertest';
import { Client } from '@elastic/elasticsearch'; import { Client } from '@elastic/elasticsearch';
import { format as formatUrl } from 'url'; import { format as formatUrl } from 'url';
@ -17,7 +17,7 @@ export function getSupertestWithoutAuth({ getService }: FtrProviderContext) {
kibanaUrl.auth = null; kibanaUrl.auth = null;
kibanaUrl.password = null; kibanaUrl.password = null;
return supertestAsPromised(formatUrl(kibanaUrl)); return supertest(formatUrl(kibanaUrl));
} }
export function getEsClientForAPIKey({ getService }: FtrProviderContext, esApiKey: string) { export function getEsClientForAPIKey({ getService }: FtrProviderContext, esApiKey: string) {

View file

@ -7,7 +7,7 @@
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import { format as formatUrl } from 'url'; import { format as formatUrl } from 'url';
import supertestAsPromised from 'supertest-as-promised'; import type SuperTest from 'supertest';
import { FtrService } from '../ftr_provider_context'; import { FtrService } from '../ftr_provider_context';
import { REPORT_TABLE_ID, REPORT_TABLE_ROW_ID } from '../../../plugins/reporting/common/constants'; import { REPORT_TABLE_ID, REPORT_TABLE_ROW_ID } from '../../../plugins/reporting/common/constants';
@ -52,7 +52,7 @@ export class ReportingPageObject extends FtrService {
`); `);
} }
async getResponse(fullUrl: string): Promise<supertestAsPromised.Response> { async getResponse(fullUrl: string): Promise<SuperTest.Response> {
this.log.debug(`getResponse for ${fullUrl}`); this.log.debug(`getResponse for ${fullUrl}`);
const kibanaServerConfig = this.config.get('servers.kibana'); const kibanaServerConfig = this.config.get('servers.kibana');
const baseURL = formatUrl({ const baseURL = formatUrl({

View file

@ -5,8 +5,7 @@
* 2.0. * 2.0.
*/ */
import { SuperTest } from 'supertest'; import type SuperTest from 'supertest';
import supertestAsPromised from 'supertest-as-promised';
import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; import type { KibanaClient } from '@elastic/elasticsearch/api/kibana';
import type { import type {
@ -26,7 +25,7 @@ import { countDownES, countDownTest } from '../detection_engine_api_integration/
* @param supertest The supertest client library * @param supertest The supertest client library
*/ */
export const createListsIndex = async ( export const createListsIndex = async (
supertest: SuperTest<supertestAsPromised.Test> supertest: SuperTest.SuperTest<SuperTest.Test>
): Promise<void> => { ): Promise<void> => {
return countDownTest(async () => { return countDownTest(async () => {
await supertest.post(LIST_INDEX).set('kbn-xsrf', 'true').send(); await supertest.post(LIST_INDEX).set('kbn-xsrf', 'true').send();
@ -39,7 +38,7 @@ export const createListsIndex = async (
* @param supertest The supertest client library * @param supertest The supertest client library
*/ */
export const deleteListsIndex = async ( export const deleteListsIndex = async (
supertest: SuperTest<supertestAsPromised.Test> supertest: SuperTest.SuperTest<SuperTest.Test>
): Promise<void> => { ): Promise<void> => {
return countDownTest(async () => { return countDownTest(async () => {
await supertest.delete(LIST_INDEX).set('kbn-xsrf', 'true').send(); await supertest.delete(LIST_INDEX).set('kbn-xsrf', 'true').send();
@ -53,7 +52,7 @@ export const deleteListsIndex = async (
* @param supertest The supertest client library * @param supertest The supertest client library
*/ */
export const createExceptionListsIndex = async ( export const createExceptionListsIndex = async (
supertest: SuperTest<supertestAsPromised.Test> supertest: SuperTest.SuperTest<SuperTest.Test>
): Promise<void> => { ): Promise<void> => {
return countDownTest(async () => { return countDownTest(async () => {
await supertest.post(LIST_INDEX).set('kbn-xsrf', 'true').send(); await supertest.post(LIST_INDEX).set('kbn-xsrf', 'true').send();
@ -179,7 +178,7 @@ export const deleteAllExceptions = async (es: KibanaClient): Promise<void> => {
* @param testValues Optional test values in case you're using CIDR or range based lists * @param testValues Optional test values in case you're using CIDR or range based lists
*/ */
export const importFile = async ( export const importFile = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
type: Type, type: Type,
contents: string[], contents: string[],
fileName: string, fileName: string,
@ -208,7 +207,7 @@ export const importFile = async (
* @param fileName filename to import as * @param fileName filename to import as
*/ */
export const importTextFile = async ( export const importTextFile = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
type: Type, type: Type,
contents: string[], contents: string[],
fileName: string fileName: string
@ -233,7 +232,7 @@ export const importTextFile = async (
* @param itemValue The item value to wait for * @param itemValue The item value to wait for
*/ */
export const waitForListItem = async ( export const waitForListItem = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
itemValue: string, itemValue: string,
fileName: string fileName: string
): Promise<void> => { ): Promise<void> => {
@ -254,7 +253,7 @@ export const waitForListItem = async (
* @param itemValue The item value to wait for * @param itemValue The item value to wait for
*/ */
export const waitForListItems = async ( export const waitForListItems = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
itemValues: string[], itemValues: string[],
fileName: string fileName: string
): Promise<void> => { ): Promise<void> => {
@ -269,7 +268,7 @@ export const waitForListItems = async (
* @param itemValue The item value to wait for * @param itemValue The item value to wait for
*/ */
export const waitForTextListItem = async ( export const waitForTextListItem = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
itemValue: string, itemValue: string,
fileName: string fileName: string
): Promise<void> => { ): Promise<void> => {
@ -296,7 +295,7 @@ export const waitForTextListItem = async (
* @param itemValue The item value to wait for * @param itemValue The item value to wait for
*/ */
export const waitForTextListItems = async ( export const waitForTextListItems = async (
supertest: SuperTest<supertestAsPromised.Test>, supertest: SuperTest.SuperTest<SuperTest.Test>,
itemValues: string[], itemValues: string[],
fileName: string fileName: string
): Promise<void> => { ): Promise<void> => {

View file

@ -8,7 +8,7 @@
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import url from 'url'; import url from 'url';
import { keyBy, mapValues } from 'lodash'; import { keyBy, mapValues } from 'lodash';
import supertestAsPromised from 'supertest-as-promised'; import supertest from 'supertest';
import { FtrProviderContext } from '../../ftr_provider_context'; import { FtrProviderContext } from '../../ftr_provider_context';
import { ConcreteTaskInstance } from '../../../../plugins/task_manager/server'; import { ConcreteTaskInstance } from '../../../../plugins/task_manager/server';
@ -84,10 +84,10 @@ interface MonitoringStats {
export default function ({ getService }: FtrProviderContext) { export default function ({ getService }: FtrProviderContext) {
const config = getService('config'); const config = getService('config');
const retry = getService('retry'); const retry = getService('retry');
const supertest = supertestAsPromised(url.format(config.get('servers.kibana'))); const request = supertest(url.format(config.get('servers.kibana')));
function getHealthRequest() { function getHealthRequest() {
return supertest.get('/api/task_manager/_health').set('kbn-xsrf', 'foo'); return request.get('/api/task_manager/_health').set('kbn-xsrf', 'foo');
} }
function getHealth(): Promise<MonitoringStats> { function getHealth(): Promise<MonitoringStats> {
@ -97,7 +97,7 @@ export default function ({ getService }: FtrProviderContext) {
} }
function scheduleTask(task: Partial<ConcreteTaskInstance>): Promise<ConcreteTaskInstance> { function scheduleTask(task: Partial<ConcreteTaskInstance>): Promise<ConcreteTaskInstance> {
return supertest return request
.post('/api/sample_tasks/schedule') .post('/api/sample_tasks/schedule')
.set('kbn-xsrf', 'xxx') .set('kbn-xsrf', 'xxx')
.send({ task }) .send({ task })

View file

@ -8,8 +8,6 @@
import { random, times } from 'lodash'; import { random, times } from 'lodash';
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import type { estypes } from '@elastic/elasticsearch'; import type { estypes } from '@elastic/elasticsearch';
import url from 'url';
import supertestAsPromised from 'supertest-as-promised';
import { FtrProviderContext } from '../../ftr_provider_context'; import { FtrProviderContext } from '../../ftr_provider_context';
import TaskManagerMapping from '../../../../plugins/task_manager/server/saved_objects/mappings.json'; import TaskManagerMapping from '../../../../plugins/task_manager/server/saved_objects/mappings.json';
import { import {
@ -55,9 +53,8 @@ export default function ({ getService }: FtrProviderContext) {
const es = getService('es'); const es = getService('es');
const log = getService('log'); const log = getService('log');
const retry = getService('retry'); const retry = getService('retry');
const config = getService('config'); const supertest = getService('supertest');
const testHistoryIndex = '.kibana_task_manager_test_result'; const testHistoryIndex = '.kibana_task_manager_test_result';
const supertest = supertestAsPromised(url.format(config.get('servers.kibana')));
describe('scheduling and running tasks', () => { describe('scheduling and running tasks', () => {
beforeEach(async () => { beforeEach(async () => {

View file

@ -8,7 +8,7 @@
import _ from 'lodash'; import _ from 'lodash';
import expect from '@kbn/expect'; import expect from '@kbn/expect';
import url from 'url'; import url from 'url';
import supertestAsPromised from 'supertest-as-promised'; import supertest from 'supertest';
import { FtrProviderContext } from '../../ftr_provider_context'; import { FtrProviderContext } from '../../ftr_provider_context';
import { ConcreteTaskInstance } from '../../../../plugins/task_manager/server'; import { ConcreteTaskInstance } from '../../../../plugins/task_manager/server';
@ -43,7 +43,7 @@ export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver'); const esArchiver = getService('esArchiver');
const retry = getService('retry'); const retry = getService('retry');
const config = getService('config'); const config = getService('config');
const supertest = supertestAsPromised(url.format(config.get('servers.kibana'))); const request = supertest(url.format(config.get('servers.kibana')));
const REMOVED_TASK_TYPE_ID = 'be7e1250-3322-11eb-94c1-db6995e83f6a'; const REMOVED_TASK_TYPE_ID = 'be7e1250-3322-11eb-94c1-db6995e83f6a';
@ -59,7 +59,7 @@ export default function ({ getService }: FtrProviderContext) {
function scheduleTask( function scheduleTask(
task: Partial<ConcreteTaskInstance | DeprecatedConcreteTaskInstance> task: Partial<ConcreteTaskInstance | DeprecatedConcreteTaskInstance>
): Promise<SerializedConcreteTaskInstance> { ): Promise<SerializedConcreteTaskInstance> {
return supertest return request
.post('/api/sample_tasks/schedule') .post('/api/sample_tasks/schedule')
.set('kbn-xsrf', 'xxx') .set('kbn-xsrf', 'xxx')
.send({ task }) .send({ task })
@ -70,7 +70,7 @@ export default function ({ getService }: FtrProviderContext) {
function currentTasks<State = unknown, Params = unknown>(): Promise<{ function currentTasks<State = unknown, Params = unknown>(): Promise<{
docs: Array<SerializedConcreteTaskInstance<State, Params>>; docs: Array<SerializedConcreteTaskInstance<State, Params>>;
}> { }> {
return supertest return request
.get('/api/sample_tasks') .get('/api/sample_tasks')
.expect(200) .expect(200)
.then((response) => response.body); .then((response) => response.body);

View file

@ -4858,7 +4858,7 @@
resolved "https://registry.yarnpkg.com/@types/base64-js/-/base64-js-1.2.5.tgz#582b2476169a6cba460a214d476c744441d873d5" resolved "https://registry.yarnpkg.com/@types/base64-js/-/base64-js-1.2.5.tgz#582b2476169a6cba460a214d476c744441d873d5"
integrity sha1-WCskdhaabLpGCiFNR2x0REHYc9U= integrity sha1-WCskdhaabLpGCiFNR2x0REHYc9U=
"@types/bluebird@*", "@types/bluebird@^3.1.1": "@types/bluebird@^3.1.1":
version "3.5.30" version "3.5.30"
resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.30.tgz#ee034a0eeea8b84ed868b1aa60d690b08a6cfbc5" resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.30.tgz#ee034a0eeea8b84ed868b1aa60d690b08a6cfbc5"
integrity sha512-8LhzvcjIoqoi1TghEkRMkbbmM+jhHnBokPGkJWjclMK+Ks0MxEBow3/p2/iFTZ+OIbJHQDSfpgdZEb+af3gfVw== integrity sha512-8LhzvcjIoqoi1TghEkRMkbbmM+jhHnBokPGkJWjclMK+Ks0MxEBow3/p2/iFTZ+OIbJHQDSfpgdZEb+af3gfVw==
@ -6117,16 +6117,7 @@
"@types/cookiejar" "*" "@types/cookiejar" "*"
"@types/node" "*" "@types/node" "*"
"@types/supertest-as-promised@^2.0.38": "@types/supertest@^2.0.5":
version "2.0.38"
resolved "https://registry.yarnpkg.com/@types/supertest-as-promised/-/supertest-as-promised-2.0.38.tgz#5077adf2a31429e06ba8de6799ebdb796ad50fc7"
integrity sha512-2vdlnsZBIgaX0DFNOACK4xFDqvoA1sAR78QD3LiDWGmzSfrRCNt1WFyUYe2Vf0QS03tZf6XC8bNlLaLYXhZbGA==
dependencies:
"@types/bluebird" "*"
"@types/superagent" "*"
"@types/supertest" "*"
"@types/supertest@*", "@types/supertest@^2.0.5":
version "2.0.8" version "2.0.8"
resolved "https://registry.yarnpkg.com/@types/supertest/-/supertest-2.0.8.tgz#23801236e2b85204ed771a8e7c40febba7da2bda" resolved "https://registry.yarnpkg.com/@types/supertest/-/supertest-2.0.8.tgz#23801236e2b85204ed771a8e7c40febba7da2bda"
integrity sha512-wcax7/ip4XSSJRLbNzEIUVy2xjcBIZZAuSd2vtltQfRK7kxhx5WMHbLHkYdxN3wuQCrwpYrg86/9byDjPXoGMA== integrity sha512-wcax7/ip4XSSJRLbNzEIUVy2xjcBIZZAuSd2vtltQfRK7kxhx5WMHbLHkYdxN3wuQCrwpYrg86/9byDjPXoGMA==
@ -8420,7 +8411,7 @@ bluebird@3.5.5:
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.5.tgz#a8d0afd73251effbbd5fe384a77d73003c17a71f" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.5.tgz#a8d0afd73251effbbd5fe384a77d73003c17a71f"
integrity sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w== integrity sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==
bluebird@3.7.2, bluebird@^3.3.1, bluebird@^3.3.5, bluebird@^3.4.1, bluebird@^3.5.0, bluebird@^3.5.1, bluebird@^3.5.5, bluebird@^3.7.1, bluebird@^3.7.2: bluebird@3.7.2, bluebird@^3.3.5, bluebird@^3.4.1, bluebird@^3.5.0, bluebird@^3.5.1, bluebird@^3.5.5, bluebird@^3.7.1, bluebird@^3.7.2:
version "3.7.2" version "3.7.2"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
@ -26429,14 +26420,6 @@ supercluster@^7.1.0:
dependencies: dependencies:
kdbush "^3.0.0" kdbush "^3.0.0"
supertest-as-promised@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/supertest-as-promised/-/supertest-as-promised-4.0.2.tgz#0464f2bd256568d4a59bce84269c0548f6879f1a"
integrity sha1-BGTyvSVlaNSlm86EJpwFSPaHnxo=
dependencies:
bluebird "^3.3.1"
methods "^1.1.1"
supertest@^3.1.0: supertest@^3.1.0:
version "3.1.0" version "3.1.0"
resolved "https://registry.yarnpkg.com/supertest/-/supertest-3.1.0.tgz#f9ebaf488e60f2176021ec580bdd23ad269e7bc6" resolved "https://registry.yarnpkg.com/supertest/-/supertest-3.1.0.tgz#f9ebaf488e60f2176021ec580bdd23ad269e7bc6"