diff --git a/x-pack/plugins/ingest_manager/common/constants/routes.ts b/x-pack/plugins/ingest_manager/common/constants/routes.ts index 2b1d24f14874f..ed38d8a29f035 100644 --- a/x-pack/plugins/ingest_manager/common/constants/routes.ts +++ b/x-pack/plugins/ingest_manager/common/constants/routes.ts @@ -4,12 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ // Base API paths -export const API_ROOT = `/api/ingest_manager`; + +export const API_ROOT = `/api/fleet`; export const EPM_API_ROOT = `${API_ROOT}/epm`; export const DATA_STREAM_API_ROOT = `${API_ROOT}/data_streams`; export const PACKAGE_POLICY_API_ROOT = `${API_ROOT}/package_policies`; export const AGENT_POLICY_API_ROOT = `${API_ROOT}/agent_policies`; -export const FLEET_API_ROOT = `${API_ROOT}/fleet`; +export const FLEET_API_ROOT_7_9 = `/api/ingest_manager/fleet`; export const LIMITED_CONCURRENCY_ROUTE_TAG = 'ingest:limited-concurrency'; @@ -76,37 +77,42 @@ export const APP_API_ROUTES = { // Agent API routes export const AGENT_API_ROUTES = { - LIST_PATTERN: `${FLEET_API_ROOT}/agents`, - INFO_PATTERN: `${FLEET_API_ROOT}/agents/{agentId}`, - UPDATE_PATTERN: `${FLEET_API_ROOT}/agents/{agentId}`, - DELETE_PATTERN: `${FLEET_API_ROOT}/agents/{agentId}`, - EVENTS_PATTERN: `${FLEET_API_ROOT}/agents/{agentId}/events`, - CHECKIN_PATTERN: `${FLEET_API_ROOT}/agents/{agentId}/checkin`, - ACKS_PATTERN: `${FLEET_API_ROOT}/agents/{agentId}/acks`, - ACTIONS_PATTERN: `${FLEET_API_ROOT}/agents/{agentId}/actions`, - ENROLL_PATTERN: `${FLEET_API_ROOT}/agents/enroll`, - UNENROLL_PATTERN: `${FLEET_API_ROOT}/agents/{agentId}/unenroll`, - BULK_UNENROLL_PATTERN: `${FLEET_API_ROOT}/agents/bulk_unenroll`, - REASSIGN_PATTERN: `${FLEET_API_ROOT}/agents/{agentId}/reassign`, - BULK_REASSIGN_PATTERN: `${FLEET_API_ROOT}/agents/bulk_reassign`, - STATUS_PATTERN: `${FLEET_API_ROOT}/agent-status`, - UPGRADE_PATTERN: `${FLEET_API_ROOT}/agents/{agentId}/upgrade`, - BULK_UPGRADE_PATTERN: `${FLEET_API_ROOT}/agents/bulk_upgrade`, + LIST_PATTERN: `${API_ROOT}/agents`, + INFO_PATTERN: `${API_ROOT}/agents/{agentId}`, + UPDATE_PATTERN: `${API_ROOT}/agents/{agentId}`, + DELETE_PATTERN: `${API_ROOT}/agents/{agentId}`, + EVENTS_PATTERN: `${API_ROOT}/agents/{agentId}/events`, + CHECKIN_PATTERN: `${API_ROOT}/agents/{agentId}/checkin`, + ACKS_PATTERN: `${API_ROOT}/agents/{agentId}/acks`, + ACTIONS_PATTERN: `${API_ROOT}/agents/{agentId}/actions`, + ENROLL_PATTERN: `${API_ROOT}/agents/enroll`, + UNENROLL_PATTERN: `${API_ROOT}/agents/{agentId}/unenroll`, + BULK_UNENROLL_PATTERN: `${API_ROOT}/agents/bulk_unenroll`, + REASSIGN_PATTERN: `${API_ROOT}/agents/{agentId}/reassign`, + BULK_REASSIGN_PATTERN: `${API_ROOT}/agents/bulk_reassign`, + STATUS_PATTERN: `${API_ROOT}/agent-status`, + UPGRADE_PATTERN: `${API_ROOT}/agents/{agentId}/upgrade`, + BULK_UPGRADE_PATTERN: `${API_ROOT}/agents/bulk_upgrade`, +}; +export const AGENT_API_ROUTES_7_9 = { + CHECKIN_PATTERN: `${FLEET_API_ROOT_7_9}/agents/{agentId}/checkin`, + ACKS_PATTERN: `${FLEET_API_ROOT_7_9}/agents/{agentId}/acks`, + ENROLL_PATTERN: `${FLEET_API_ROOT_7_9}/agents/enroll`, }; export const ENROLLMENT_API_KEY_ROUTES = { - CREATE_PATTERN: `${FLEET_API_ROOT}/enrollment-api-keys`, - LIST_PATTERN: `${FLEET_API_ROOT}/enrollment-api-keys`, - INFO_PATTERN: `${FLEET_API_ROOT}/enrollment-api-keys/{keyId}`, - DELETE_PATTERN: `${FLEET_API_ROOT}/enrollment-api-keys/{keyId}`, + CREATE_PATTERN: `${API_ROOT}/enrollment-api-keys`, + LIST_PATTERN: `${API_ROOT}/enrollment-api-keys`, + INFO_PATTERN: `${API_ROOT}/enrollment-api-keys/{keyId}`, + DELETE_PATTERN: `${API_ROOT}/enrollment-api-keys/{keyId}`, }; -// Fleet setup API routes -export const FLEET_SETUP_API_ROUTES = { - INFO_PATTERN: `${FLEET_API_ROOT}/setup`, - CREATE_PATTERN: `${FLEET_API_ROOT}/setup`, +// Agents setup API routes +export const AGENTS_SETUP_API_ROUTES = { + INFO_PATTERN: `${API_ROOT}/agents/setup`, + CREATE_PATTERN: `${API_ROOT}/agents/setup`, }; export const SETUP_API_ROUTE = `${API_ROOT}/setup`; -export const INSTALL_SCRIPT_API_ROUTES = `${FLEET_API_ROOT}/install/{osType}`; +export const INSTALL_SCRIPT_API_ROUTES = `${API_ROOT}/install/{osType}`; diff --git a/x-pack/plugins/ingest_manager/common/openapi/spec_oas3.json b/x-pack/plugins/ingest_manager/common/openapi/spec_oas3.json index 329137b063e66..69974a87434a1 100644 --- a/x-pack/plugins/ingest_manager/common/openapi/spec_oas3.json +++ b/x-pack/plugins/ingest_manager/common/openapi/spec_oas3.json @@ -12,7 +12,7 @@ }, "servers": [ { - "url": "http://localhost:5601/api/ingest_manager", + "url": "http://localhost:5601/api/fleet", "description": "local" } ], @@ -1280,9 +1280,9 @@ ] } }, - "/fleet/setup": { + "/agents/setup": { "get": { - "summary": "Fleet setup - Info", + "summary": "Agents setup - Info", "tags": [], "responses": { "200": { @@ -1314,7 +1314,7 @@ } } }, - "operationId": "get-fleet-setup", + "operationId": "get-agents-setup", "security": [ { "basicAuth": [] @@ -1322,8 +1322,8 @@ ] }, "post": { - "summary": "Fleet setup - Create", - "operationId": "post-fleet-setup", + "summary": "Agents setup - Create", + "operationId": "post-agents-setup", "responses": { "200": { "description": "OK", diff --git a/x-pack/plugins/ingest_manager/common/services/routes.ts b/x-pack/plugins/ingest_manager/common/services/routes.ts index c709794f2ce55..f35b6b3f7de6a 100644 --- a/x-pack/plugins/ingest_manager/common/services/routes.ts +++ b/x-pack/plugins/ingest_manager/common/services/routes.ts @@ -9,7 +9,7 @@ import { PACKAGE_POLICY_API_ROUTES, AGENT_POLICY_API_ROUTES, DATA_STREAM_API_ROUTES, - FLEET_SETUP_API_ROUTES, + AGENTS_SETUP_API_ROUTES, AGENT_API_ROUTES, ENROLLMENT_API_KEY_ROUTES, SETUP_API_ROUTE, @@ -121,8 +121,8 @@ export const dataStreamRouteService = { }; export const fleetSetupRouteService = { - getFleetSetupPath: () => FLEET_SETUP_API_ROUTES.INFO_PATTERN, - postFleetSetupPath: () => FLEET_SETUP_API_ROUTES.CREATE_PATTERN, + getFleetSetupPath: () => AGENTS_SETUP_API_ROUTES.INFO_PATTERN, + postFleetSetupPath: () => AGENTS_SETUP_API_ROUTES.CREATE_PATTERN, }; export const agentRouteService = { diff --git a/x-pack/plugins/ingest_manager/dev_docs/api/agents_acks.md b/x-pack/plugins/ingest_manager/dev_docs/api/agents_acks.md index d5bf4d2c2e236..f4924ac55fa18 100644 --- a/x-pack/plugins/ingest_manager/dev_docs/api/agents_acks.md +++ b/x-pack/plugins/ingest_manager/dev_docs/api/agents_acks.md @@ -5,7 +5,7 @@ Acknowledge actions received during checkin ## Request -`POST /api/ingest_manager/fleet/agents/{agentId}/acks` +`POST /api/fleet/agents/{agentId}/acks` ## Headers @@ -22,7 +22,7 @@ Acknowledge actions received during checkin ## Example ```js -POST /api/ingest_manager/fleet/agents/a4937110-e53e-11e9-934f-47a8e38a522c/acks +POST /api/fleet/agents/a4937110-e53e-11e9-934f-47a8e38a522c/acks Authorization: ApiKey VALID_ACCESS_API_KEY { "action_ids": ["action-1", "action-2"] diff --git a/x-pack/plugins/ingest_manager/dev_docs/api/agents_checkin.md b/x-pack/plugins/ingest_manager/dev_docs/api/agents_checkin.md index aa3e4b1335ecd..7d7cdeaecaccb 100644 --- a/x-pack/plugins/ingest_manager/dev_docs/api/agents_checkin.md +++ b/x-pack/plugins/ingest_manager/dev_docs/api/agents_checkin.md @@ -5,7 +5,7 @@ Report current state of a Fleet agent. ## Request -`POST /api/ingest_manager/fleet/agents/{agentId}/checkin` +`POST /api/fleet/agents/{agentId}/checkin` ## Headers @@ -24,7 +24,7 @@ Report current state of a Fleet agent. ## Example ```js -POST /api/ingest_manager/fleet/agents/a4937110-e53e-11e9-934f-47a8e38a522c/checkin +POST /api/fleet/agents/a4937110-e53e-11e9-934f-47a8e38a522c/checkin Authorization: ApiKey VALID_ACCESS_API_KEY { "events": [{ diff --git a/x-pack/plugins/ingest_manager/dev_docs/api/agents_enroll.md b/x-pack/plugins/ingest_manager/dev_docs/api/agents_enroll.md index b32e6873c60e5..977b3029371ba 100644 --- a/x-pack/plugins/ingest_manager/dev_docs/api/agents_enroll.md +++ b/x-pack/plugins/ingest_manager/dev_docs/api/agents_enroll.md @@ -4,7 +4,7 @@ Enroll agent ## Request -`POST /api/ingest_manager/fleet/agents/enroll` +`POST /api/fleet/agents/enroll` ## Headers @@ -25,7 +25,7 @@ Enroll agent ## Example ```js -POST /api/ingest_manager/fleet/agents/enroll +POST /api/fleet/agents/enroll Authorization: ApiKey VALID_API_KEY { "type": "PERMANENT", diff --git a/x-pack/plugins/ingest_manager/dev_docs/api/agents_list.md b/x-pack/plugins/ingest_manager/dev_docs/api/agents_list.md index fdb54411f8610..dcc832ee65b0b 100644 --- a/x-pack/plugins/ingest_manager/dev_docs/api/agents_list.md +++ b/x-pack/plugins/ingest_manager/dev_docs/api/agents_list.md @@ -2,7 +2,7 @@ ## Request -`GET /api/ingest_manager/fleet/agents` +`GET /api/fleet/agents` ## Query @@ -18,5 +18,5 @@ ## Example ```js -GET /api/ingest_manager/fleet/agents?kuery=fleet-agents.last_checkin:2019-10-01T13:42:54.323Z +GET /api/fleet/agents?kuery=fleet-agents.last_checkin:2019-10-01T13:42:54.323Z ``` diff --git a/x-pack/plugins/ingest_manager/dev_docs/api/agents_unenroll.md b/x-pack/plugins/ingest_manager/dev_docs/api/agents_unenroll.md index 13b0aadd7689d..fbf8122ec70f3 100644 --- a/x-pack/plugins/ingest_manager/dev_docs/api/agents_unenroll.md +++ b/x-pack/plugins/ingest_manager/dev_docs/api/agents_unenroll.md @@ -4,7 +4,7 @@ Unenroll an agent ## Request -`POST /api/ingest_manager/fleet/agents/unenroll` +`POST /api/fleet/agents/unenroll` ## Request body @@ -20,7 +20,7 @@ Unenroll an agent ## Example ```js -POST /api/ingest_manager/fleet/agents/enroll +POST /api/fleet/agents/enroll { "ids": ['agent1'], } diff --git a/x-pack/plugins/ingest_manager/dev_docs/api/epm.md b/x-pack/plugins/ingest_manager/dev_docs/api/epm.md index 12fecc928419b..90b636a5a92a1 100644 --- a/x-pack/plugins/ingest_manager/dev_docs/api/epm.md +++ b/x-pack/plugins/ingest_manager/dev_docs/api/epm.md @@ -8,17 +8,17 @@ The Package Manager offers an API. Here an example on how they can be used. List installed packages: ``` -curl localhost:5601/api/ingest_manager/epm/packages +curl localhost:5601/api/fleet/epm/packages ``` Install a package: ``` -curl -X POST localhost:5601/api/ingest_manager/epm/packages/iptables-1.0.4 +curl -X POST localhost:5601/api/fleet/epm/packages/iptables-1.0.4 ``` Delete a package: ``` -curl -X DELETE localhost:5601/api/ingest_manager/epm/packages/iptables-1.0.4 +curl -X DELETE localhost:5601/api/fleet/epm/packages/iptables-1.0.4 ``` diff --git a/x-pack/plugins/ingest_manager/dev_docs/api_integration_tests.md b/x-pack/plugins/ingest_manager/dev_docs/api_integration_tests.md index 612d94d01a2d0..1f4ea89efdf77 100644 --- a/x-pack/plugins/ingest_manager/dev_docs/api_integration_tests.md +++ b/x-pack/plugins/ingest_manager/dev_docs/api_integration_tests.md @@ -1,32 +1,36 @@ # API integration tests Many API integration tests for Ingest Manager trigger at some point a connection to the package registry, and retrieval of some packages. If these connections are made to a package registry deployment outside of Kibana CI, these tests can fail at any time for two reasons: -* the deployed registry is temporarily unavailable -* the packages served by the registry do not match the expectation of the code under test + +- the deployed registry is temporarily unavailable +- the packages served by the registry do not match the expectation of the code under test For that reason, we run a dockerized version of the package registry in Kibana CI. For this to work, our tests must run against a custom test configuration and be kept in a custom directory, `x-pack/test/ingest_manager_api_integration`. ## How to run the tests locally Usually, having the test server and the test runner in two different shells is most efficient, as it is possible to keep the server running and only rerun the test runner as often as needed. To do so, in one shell in the main `kibana` directory, run: + ``` $ export INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345 $ yarn test:ftr:server --config x-pack/test/ingest_manager_api_integration/config.ts ``` In another shell in the same directory, run + ``` $ export INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345 $ yarn test:ftr:runner --config x-pack/test/ingest_manager_api_integration/config.ts ``` However, it is also possible to **alternatively** run everything in one go, again from the main `kibana` directory: + ``` $ export INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345 $ yarn test:ftr --config x-pack/test/ingest_manager_api_integration/config.ts ``` -Port `12345` is used as an example here, it can be anything, but the environment variable has to be present for the tests to run at all. +Port `12345` is used as an example here, it can be anything, but the environment variable has to be present for the tests to run at all. ## DockerServers service setup @@ -50,9 +54,9 @@ The main configuration for the `DockerServers` service for our tests can be foun './apis/fixtures/test_packages' )}:/registry/packages/test-packages`, ]; - ``` +``` - `-v` mounts local paths into the docker image. The first one puts a custom configuration file into the correct place in the docker container, the second one mounts a directory containing additional packages. +`-v` mounts local paths into the docker image. The first one puts a custom configuration file into the correct place in the docker container, the second one mounts a directory containing additional packages. ### Specify the docker image to use @@ -82,7 +86,7 @@ Also, not every developer has `docker` installed on their workstation, so it mus it('fetches a .json search file', async function () { if (server.enabled) { await supertest - .get('/api/ingest_manager/epm/packages/filetest/0.1.0/kibana/search/sample_search.json') + .get('/api/fleet/epm/packages/filetest/0.1.0/kibana/search/sample_search.json') .set('kbn-xsrf', 'xxx') .expect('Content-Type', 'application/json; charset=utf-8') .expect(200); @@ -104,7 +108,7 @@ If the tests are skipped in this way, they are marked in the test summary as `pe │ warn disabling tests because DockerServers service is not enabled, set INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT to run them └-> lists all packages from the registry └-> "after all" hook -[...] +[...] │ │1 passing (233ms) │6 pending diff --git a/x-pack/plugins/ingest_manager/dev_docs/fleet_agents_interactions_detailed.md b/x-pack/plugins/ingest_manager/dev_docs/fleet_agents_interactions_detailed.md index 52a1dde37cd07..834b1dc6afb1a 100644 --- a/x-pack/plugins/ingest_manager/dev_docs/fleet_agents_interactions_detailed.md +++ b/x-pack/plugins/ingest_manager/dev_docs/fleet_agents_interactions_detailed.md @@ -40,7 +40,7 @@ When an agent checkin fleet: This is really similar to the checkin (same auth mecanism) and it's used for agent to acknowlege action received during checkin. -An agent can acknowledge one or multiple actions by calling `POST /api/ingest_manager/fleet/agents/{agentId}/acks` +An agent can acknowledge one or multiple actions by calling `POST /api/fleet/agents/{agentId}/acks` ## Other interactions diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/components/agent_policy_delete_provider.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/components/agent_policy_delete_provider.tsx index 15f71689ecdfa..fa211f4ec6236 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/components/agent_policy_delete_provider.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/components/agent_policy_delete_provider.tsx @@ -93,7 +93,7 @@ export const AgentPolicyDeleteProvider: React.FunctionComponent = ({ chil } setIsLoadingAgentsCount(true); const { data } = await sendRequest<{ total: number }>({ - path: `/api/ingest_manager/fleet/agents`, + path: `/api/fleet/agents`, method: 'get', query: { kuery: `${AGENT_SAVED_OBJECT_TYPE}.policy_id : ${agentPolicyToCheck}`, diff --git a/x-pack/plugins/ingest_manager/scripts/dev_agent/script.ts b/x-pack/plugins/ingest_manager/scripts/dev_agent/script.ts index 47108508ec68a..18ce12794776a 100644 --- a/x-pack/plugins/ingest_manager/scripts/dev_agent/script.ts +++ b/x-pack/plugins/ingest_manager/scripts/dev_agent/script.ts @@ -79,7 +79,7 @@ async function checkin(kibanaURL: string, agent: Agent, log: ToolingLog) { }, ], }; - const res = await fetch(`${kibanaURL}/api/ingest_manager/fleet/agents/${agent.id}/checkin`, { + const res = await fetch(`${kibanaURL}/api/fleet/agents/${agent.id}/checkin`, { method: 'POST', body: JSON.stringify(body), headers: { @@ -116,7 +116,7 @@ async function enroll(kibanaURL: string, apiKey: string, log: ToolingLog): Promi }, }, }; - const res = await fetch(`${kibanaURL}/api/ingest_manager/fleet/agents/enroll`, { + const res = await fetch(`${kibanaURL}/api/fleet/agents/enroll`, { method: 'POST', body: JSON.stringify(body), headers: { diff --git a/x-pack/plugins/ingest_manager/server/constants/index.ts b/x-pack/plugins/ingest_manager/server/constants/index.ts index c69ee7e4b6092..b1d7318ff5107 100644 --- a/x-pack/plugins/ingest_manager/server/constants/index.ts +++ b/x-pack/plugins/ingest_manager/server/constants/index.ts @@ -23,8 +23,9 @@ export { DATA_STREAM_API_ROUTES, PACKAGE_POLICY_API_ROUTES, AGENT_API_ROUTES, + AGENT_API_ROUTES_7_9, AGENT_POLICY_API_ROUTES, - FLEET_SETUP_API_ROUTES, + AGENTS_SETUP_API_ROUTES, ENROLLMENT_API_KEY_ROUTES, INSTALL_SCRIPT_API_ROUTES, OUTPUT_API_ROUTES, diff --git a/x-pack/plugins/ingest_manager/server/integration_tests/router.test.ts b/x-pack/plugins/ingest_manager/server/integration_tests/router.test.ts index 60ef6851bd996..46b10ff381a60 100644 --- a/x-pack/plugins/ingest_manager/server/integration_tests/router.test.ts +++ b/x-pack/plugins/ingest_manager/server/integration_tests/router.test.ts @@ -43,19 +43,19 @@ describe('ingestManager', () => { afterAll(async () => await root.shutdown()); it('does not have agent policy api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/agent_policies').expect(404); + await kbnTestServer.request.get(root, '/api/fleet/agent_policies').expect(404); }); it('does not have package policies api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/package_policies').expect(404); + await kbnTestServer.request.get(root, '/api/fleet/package_policies').expect(404); }); it('does not have EPM api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/epm/packages').expect(404); + await kbnTestServer.request.get(root, '/api/fleet/epm/packages').expect(404); }); it('does not have Fleet api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/fleet/setup').expect(404); + await kbnTestServer.request.get(root, '/api/fleet/agents/setup').expect(404); }); }); @@ -76,19 +76,19 @@ describe('ingestManager', () => { afterAll(async () => await root.shutdown()); it('has agent policy api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/agent_policies').expect(200); + await kbnTestServer.request.get(root, '/api/fleet/agent_policies').expect(200); }); it('has package policies api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/package_policies').expect(200); + await kbnTestServer.request.get(root, '/api/fleet/package_policies').expect(200); }); it('does not have EPM api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/epm/packages').expect(404); + await kbnTestServer.request.get(root, '/api/fleet/epm/packages').expect(404); }); it('does not have Fleet api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/fleet/setup').expect(404); + await kbnTestServer.request.get(root, '/api/fleet/agents/setup').expect(404); }); }); @@ -115,19 +115,19 @@ describe('ingestManager', () => { afterAll(async () => await root.shutdown()); it('has agent policy api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/agent_policies').expect(200); + await kbnTestServer.request.get(root, '/api/fleet/agent_policies').expect(200); }); it('has package policies api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/package_policies').expect(200); + await kbnTestServer.request.get(root, '/api/fleet/package_policies').expect(200); }); it('does have EPM api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/epm/packages').expect(500); + await kbnTestServer.request.get(root, '/api/fleet/epm/packages').expect(500); }); it('does not have Fleet api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/fleet/setup').expect(404); + await kbnTestServer.request.get(root, '/api/fleet/agents/setup').expect(404); }); }); @@ -149,19 +149,19 @@ describe('ingestManager', () => { afterAll(async () => await root.shutdown()); it('has agent policy api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/agent_policies').expect(200); + await kbnTestServer.request.get(root, '/api/fleet/agent_policies').expect(200); }); it('has package policies api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/package_policies').expect(200); + await kbnTestServer.request.get(root, '/api/fleet/package_policies').expect(200); }); it('does not have EPM api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/epm/packages').expect(404); + await kbnTestServer.request.get(root, '/api/fleet/epm/packages').expect(404); }); it('does have Fleet api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/fleet/setup').expect(200); + await kbnTestServer.request.get(root, '/api/fleet/agents/setup').expect(200); }); }); @@ -184,19 +184,19 @@ describe('ingestManager', () => { afterAll(async () => await root.shutdown()); it('has agent policy api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/agent_policies').expect(200); + await kbnTestServer.request.get(root, '/api/fleet/agent_policies').expect(200); }); it('has package policies api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/package_policies').expect(200); + await kbnTestServer.request.get(root, '/api/fleet/package_policies').expect(200); }); it('does have EPM api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/epm/packages').expect(500); + await kbnTestServer.request.get(root, '/api/fleet/epm/packages').expect(500); }); it('does have Fleet api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/fleet/setup').expect(200); + await kbnTestServer.request.get(root, '/api/fleet/agents/setup').expect(200); }); }); }); diff --git a/x-pack/plugins/ingest_manager/server/routes/agent/index.ts b/x-pack/plugins/ingest_manager/server/routes/agent/index.ts index ea8981bbfbad5..f7b0c536d1a0d 100644 --- a/x-pack/plugins/ingest_manager/server/routes/agent/index.ts +++ b/x-pack/plugins/ingest_manager/server/routes/agent/index.ts @@ -14,6 +14,7 @@ import Ajv from 'ajv'; import { PLUGIN_ID, AGENT_API_ROUTES, + AGENT_API_ROUTES_7_9, LIMITED_CONCURRENCY_ROUTE_TAG, AGENT_POLLING_REQUEST_TIMEOUT_MARGIN_MS, } from '../../constants'; @@ -141,6 +142,28 @@ export const registerRoutes = (router: IRouter, config: IngestManagerConfigType) }, postAgentCheckinHandler ); + // BWC for agent <= 7.9 + router.post( + { + path: AGENT_API_ROUTES_7_9.CHECKIN_PATTERN, + validate: { + params: makeValidator(PostAgentCheckinRequestParamsJSONSchema), + body: makeValidator(PostAgentCheckinRequestBodyJSONSchema), + }, + options: { + tags: [], + // If the timeout is too short, do not set socket idle timeout and rely on Kibana global socket timeout + ...(pollingRequestTimeout && pollingRequestTimeout > AGENT_POLLING_REQUEST_TIMEOUT_MARGIN_MS + ? { + timeout: { + idleSocket: pollingRequestTimeout, + }, + } + : {}), + }, + }, + postAgentCheckinHandler + ); // Agent enrollment router.post( @@ -153,6 +176,17 @@ export const registerRoutes = (router: IRouter, config: IngestManagerConfigType) }, postAgentEnrollHandler ); + // BWC for agent <= 7.9 + router.post( + { + path: AGENT_API_ROUTES_7_9.ENROLL_PATTERN, + validate: { + body: makeValidator(PostAgentEnrollRequestBodyJSONSchema), + }, + options: { tags: [LIMITED_CONCURRENCY_ROUTE_TAG] }, + }, + postAgentEnrollHandler + ); // Agent acks router.post( @@ -173,6 +207,25 @@ export const registerRoutes = (router: IRouter, config: IngestManagerConfigType) saveAgentEvents: AgentService.saveAgentEvents, }) ); + // BWC for agent <= 7.9 + router.post( + { + path: AGENT_API_ROUTES_7_9.ACKS_PATTERN, + validate: { + params: makeValidator(PostAgentAcksRequestParamsJSONSchema), + body: makeValidator(PostAgentAcksRequestBodyJSONSchema), + }, + options: { tags: [LIMITED_CONCURRENCY_ROUTE_TAG] }, + }, + postAgentAcksHandlerBuilder({ + acknowledgeAgentActions: AgentService.acknowledgeAgentActions, + authenticateAgentWithAccessToken: AgentService.authenticateAgentWithAccessToken, + getSavedObjectsClientContract: appContextService.getInternalUserSOClient.bind( + appContextService + ), + saveAgentEvents: AgentService.saveAgentEvents, + }) + ); // Agent actions router.post( diff --git a/x-pack/plugins/ingest_manager/server/routes/setup/handlers.test.ts b/x-pack/plugins/ingest_manager/server/routes/setup/handlers.test.ts index ce826e78c454d..56c2eab385291 100644 --- a/x-pack/plugins/ingest_manager/server/routes/setup/handlers.test.ts +++ b/x-pack/plugins/ingest_manager/server/routes/setup/handlers.test.ts @@ -31,7 +31,7 @@ describe('ingestManagerSetupHandler', () => { response = httpServerMock.createResponseFactory(); request = httpServerMock.createKibanaRequest({ method: 'post', - path: '/api/ingest_manager/setup', + path: '/api/fleet/setup', }); // prevents `Logger not set.` and other appContext errors appContextService.start(createAppContextStartContractMock()); diff --git a/x-pack/plugins/ingest_manager/server/routes/setup/index.ts b/x-pack/plugins/ingest_manager/server/routes/setup/index.ts index fe51abec45b23..b71e9983f494f 100644 --- a/x-pack/plugins/ingest_manager/server/routes/setup/index.ts +++ b/x-pack/plugins/ingest_manager/server/routes/setup/index.ts @@ -5,7 +5,7 @@ */ import { IRouter } from 'src/core/server'; -import { PLUGIN_ID, FLEET_SETUP_API_ROUTES, SETUP_API_ROUTE } from '../../constants'; +import { PLUGIN_ID, AGENTS_SETUP_API_ROUTES, SETUP_API_ROUTE } from '../../constants'; import { IngestManagerConfigType } from '../../../common'; import { getFleetStatusHandler, @@ -30,7 +30,7 @@ export const registerIngestManagerSetupRoute = (router: IRouter) => { export const registerCreateFleetSetupRoute = (router: IRouter) => { router.post( { - path: FLEET_SETUP_API_ROUTES.CREATE_PATTERN, + path: AGENTS_SETUP_API_ROUTES.CREATE_PATTERN, validate: PostFleetSetupRequestSchema, options: { tags: [`access:${PLUGIN_ID}-all`] }, }, @@ -41,7 +41,7 @@ export const registerCreateFleetSetupRoute = (router: IRouter) => { export const registerGetFleetStatusRoute = (router: IRouter) => { router.get( { - path: FLEET_SETUP_API_ROUTES.INFO_PATTERN, + path: AGENTS_SETUP_API_ROUTES.INFO_PATTERN, validate: false, options: { tags: [`access:${PLUGIN_ID}-read`] }, }, diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.test.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.test.ts index 1441aec86e12e..00e7b0ca51ecf 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.test.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.test.ts @@ -24,7 +24,7 @@ describe('ingest service', () => { describe('sendGetEndpointSpecificPackagePolicies()', () => { it('auto adds kuery to api request', async () => { await sendGetEndpointSpecificPackagePolicies(http); - expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/package_policies', { + expect(http.get).toHaveBeenCalledWith('/api/fleet/package_policies', { query: { kuery: `${PACKAGE_POLICY_SAVED_OBJECT_TYPE}.package.name: endpoint`, }, @@ -34,7 +34,7 @@ describe('ingest service', () => { await sendGetEndpointSpecificPackagePolicies(http, { query: { kuery: 'someValueHere', page: 1, perPage: 10 }, }); - expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/package_policies', { + expect(http.get).toHaveBeenCalledWith('/api/fleet/package_policies', { query: { kuery: `someValueHere and ${PACKAGE_POLICY_SAVED_OBJECT_TYPE}.package.name: endpoint`, perPage: 10, @@ -47,11 +47,11 @@ describe('ingest service', () => { describe('sendGetPackagePolicy()', () => { it('builds correct API path', async () => { await sendGetPackagePolicy(http, '123'); - expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/package_policies/123', undefined); + expect(http.get).toHaveBeenCalledWith('/api/fleet/package_policies/123', undefined); }); it('supports http options', async () => { await sendGetPackagePolicy(http, '123', { query: { page: 1 } }); - expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/package_policies/123', { + expect(http.get).toHaveBeenCalledWith('/api/fleet/package_policies/123', { query: { page: 1, }, @@ -65,7 +65,7 @@ describe('ingest service', () => { Promise.resolve(policyListApiPathHandlers()[INGEST_API_EPM_PACKAGES]()) ); await sendGetEndpointSecurityPackage(http); - expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/epm/packages', { + expect(http.get).toHaveBeenCalledWith('/api/fleet/epm/packages', { query: { category: 'security' }, }); }); diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.ts index 48ee6e4f67ad0..204dfe437815e 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.ts @@ -19,12 +19,11 @@ import { import { GetPolicyListResponse, GetPolicyResponse, UpdatePolicyResponse } from '../../../types'; import { NewPolicyData } from '../../../../../../../common/endpoint/types'; -const INGEST_API_ROOT = `/api/ingest_manager`; +const INGEST_API_ROOT = `/api/fleet`; export const INGEST_API_PACKAGE_POLICIES = `${INGEST_API_ROOT}/package_policies`; export const INGEST_API_AGENT_POLICIES = `${INGEST_API_ROOT}/agent_policies`; -const INGEST_API_FLEET = `${INGEST_API_ROOT}/fleet`; -const INGEST_API_FLEET_AGENT_STATUS = `${INGEST_API_FLEET}/agent-status`; -export const INGEST_API_FLEET_AGENTS = `${INGEST_API_FLEET}/agents`; +const INGEST_API_FLEET_AGENT_STATUS = `${INGEST_API_ROOT}/agent-status`; +export const INGEST_API_FLEET_AGENTS = `${INGEST_API_ROOT}/agents`; export const INGEST_API_EPM_PACKAGES = `${INGEST_API_ROOT}/epm/packages`; const INGEST_API_DELETE_PACKAGE_POLICY = `${INGEST_API_PACKAGE_POLICIES}/delete`; diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_details.test.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_details.test.tsx index f75d086df9eb4..abc9a2cbd027c 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_details.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_details.test.tsx @@ -87,7 +87,7 @@ describe('Policy Details', () => { const [path] = args; if (typeof path === 'string') { // GET datasouce - if (path === '/api/ingest_manager/package_policies/1') { + if (path === '/api/fleet/package_policies/1') { asyncActions = asyncActions.then(async (): Promise => sleep()); return Promise.resolve({ item: policyPackagePolicy, @@ -96,7 +96,7 @@ describe('Policy Details', () => { } // GET Agent status for agent policy - if (path === '/api/ingest_manager/fleet/agent-status') { + if (path === '/api/fleet/agent-status') { asyncActions = asyncActions.then(async () => sleep()); return Promise.resolve({ results: { events: 0, total: 5, online: 3, error: 1, offline: 1 }, @@ -203,7 +203,7 @@ describe('Policy Details', () => { asyncActions = asyncActions.then(async () => sleep()); const [path] = args; if (typeof path === 'string') { - if (path === '/api/ingest_manager/package_policies/1') { + if (path === '/api/fleet/package_policies/1') { return Promise.resolve({ item: policyPackagePolicy, success: true, @@ -248,7 +248,7 @@ describe('Policy Details', () => { // API should be called await asyncActions; - expect(http.put.mock.calls[0][0]).toEqual(`/api/ingest_manager/package_policies/1`); + expect(http.put.mock.calls[0][0]).toEqual(`/api/fleet/package_policies/1`); policyView.update(); // Toast notification should be shown diff --git a/x-pack/plugins/security_solution/scripts/endpoint/resolver_generator_script.ts b/x-pack/plugins/security_solution/scripts/endpoint/resolver_generator_script.ts index 1c2c4a857451b..9fa2257afd411 100644 --- a/x-pack/plugins/security_solution/scripts/endpoint/resolver_generator_script.ts +++ b/x-pack/plugins/security_solution/scripts/endpoint/resolver_generator_script.ts @@ -11,7 +11,7 @@ import { KbnClient, ToolingLog } from '@kbn/dev-utils'; import { AxiosResponse } from 'axios'; import { indexHostsAndAlerts } from '../../common/endpoint/index_data'; import { ANCESTRY_LIMIT } from '../../common/endpoint/generate_data'; -import { FLEET_SETUP_API_ROUTES, SETUP_API_ROUTE } from '../../../ingest_manager/common/constants'; +import { AGENTS_SETUP_API_ROUTES, SETUP_API_ROUTE } from '../../../ingest_manager/common/constants'; import { CreateFleetSetupResponse, PostIngestSetupResponse, @@ -60,7 +60,7 @@ async function doIngestSetup(kbnClient: KbnClient) { // Setup Fleet try { const setupResponse = (await kbnClient.request({ - path: FLEET_SETUP_API_ROUTES.CREATE_PATTERN, + path: AGENTS_SETUP_API_ROUTES.CREATE_PATTERN, method: 'POST', })) as AxiosResponse; diff --git a/x-pack/test/ingest_manager_api_integration/apis/agent_policy/agent_policy.ts b/x-pack/test/ingest_manager_api_integration/apis/agent_policy/agent_policy.ts index 71e2bbc4e4c0a..7dfef77f001ab 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/agent_policy/agent_policy.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/agent_policy/agent_policy.ts @@ -12,10 +12,10 @@ export default function ({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); describe('ingest_manager_agent_policies', () => { - describe('POST /api/ingest_manager/agent_policies', () => { + describe('POST /api/fleet/agent_policies', () => { it('should work with valid values', async () => { await supertest - .post(`/api/ingest_manager/agent_policies`) + .post(`/api/fleet/agent_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'TEST', @@ -26,7 +26,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return a 400 with an empty namespace', async () => { await supertest - .post(`/api/ingest_manager/agent_policies`) + .post(`/api/fleet/agent_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'TEST', @@ -37,7 +37,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return a 400 with an invalid namespace', async () => { await supertest - .post(`/api/ingest_manager/agent_policies`) + .post(`/api/fleet/agent_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'TEST', @@ -47,7 +47,7 @@ export default function ({ getService }: FtrProviderContext) { }); }); - describe('POST /api/ingest_manager/agent_policies/{agentPolicyId}/copy', () => { + describe('POST /api/fleet/agent_policies/{agentPolicyId}/copy', () => { before(async () => { await esArchiver.loadIfNeeded('fleet/agents'); }); @@ -61,7 +61,7 @@ export default function ({ getService }: FtrProviderContext) { const { body: { item }, } = await supertest - .post(`/api/ingest_manager/agent_policies/${TEST_POLICY_ID}/copy`) + .post(`/api/fleet/agent_policies/${TEST_POLICY_ID}/copy`) .set('kbn-xsrf', 'xxxx') .send({ name: 'Copied policy', @@ -84,7 +84,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return a 404 with invalid source policy', async () => { await supertest - .post(`/api/ingest_manager/agent_policies/INVALID_POLICY_ID/copy`) + .post(`/api/fleet/agent_policies/INVALID_POLICY_ID/copy`) .set('kbn-xsrf', 'xxxx') .send({ name: 'Copied policy', @@ -95,7 +95,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return a 400 with invalid payload', async () => { await supertest - .post(`/api/ingest_manager/agent_policies/${TEST_POLICY_ID}/copy`) + .post(`/api/fleet/agent_policies/${TEST_POLICY_ID}/copy`) .set('kbn-xsrf', 'xxxx') .send({}) .expect(400); @@ -103,7 +103,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return a 400 with invalid name', async () => { await supertest - .post(`/api/ingest_manager/agent_policies/${TEST_POLICY_ID}/copy`) + .post(`/api/fleet/agent_policies/${TEST_POLICY_ID}/copy`) .set('kbn-xsrf', 'xxxx') .send({ name: '', diff --git a/x-pack/test/ingest_manager_api_integration/apis/epm/bulk_upgrade.ts b/x-pack/test/ingest_manager_api_integration/apis/epm/bulk_upgrade.ts index bafcb79a419c2..7c07fd47a66af 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/epm/bulk_upgrade.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/epm/bulk_upgrade.ts @@ -18,7 +18,7 @@ export default function (providerContext: FtrProviderContext) { const supertest = getService('supertest'); const deletePackage = async (pkgkey: string) => { - await supertest.delete(`/api/ingest_manager/epm/packages/${pkgkey}`).set('kbn-xsrf', 'xxxx'); + await supertest.delete(`/api/fleet/epm/packages/${pkgkey}`).set('kbn-xsrf', 'xxxx'); }; describe('bulk package upgrade api', async () => { @@ -27,7 +27,7 @@ export default function (providerContext: FtrProviderContext) { describe('bulk package upgrade with a package already installed', async () => { beforeEach(async () => { await supertest - .post(`/api/ingest_manager/epm/packages/multiple_versions-0.1.0`) + .post(`/api/fleet/epm/packages/multiple_versions-0.1.0`) .set('kbn-xsrf', 'xxxx') .send({ force: true }) .expect(200); @@ -39,14 +39,11 @@ export default function (providerContext: FtrProviderContext) { }); it('should return 400 if no packages are requested for upgrade', async function () { - await supertest - .post(`/api/ingest_manager/epm/packages/_bulk`) - .set('kbn-xsrf', 'xxxx') - .expect(400); + await supertest.post(`/api/fleet/epm/packages/_bulk`).set('kbn-xsrf', 'xxxx').expect(400); }); it('should return 200 and an array for upgrading a package', async function () { const { body }: { body: BulkInstallPackagesResponse } = await supertest - .post(`/api/ingest_manager/epm/packages/_bulk`) + .post(`/api/fleet/epm/packages/_bulk`) .set('kbn-xsrf', 'xxxx') .send({ packages: ['multiple_versions'] }) .expect(200); @@ -58,7 +55,7 @@ export default function (providerContext: FtrProviderContext) { }); it('should return an error for packages that do not exist', async function () { const { body }: { body: BulkInstallPackagesResponse } = await supertest - .post(`/api/ingest_manager/epm/packages/_bulk`) + .post(`/api/fleet/epm/packages/_bulk`) .set('kbn-xsrf', 'xxxx') .send({ packages: ['multiple_versions', 'blahblah'] }) .expect(200); @@ -74,7 +71,7 @@ export default function (providerContext: FtrProviderContext) { }); it('should upgrade multiple packages', async function () { const { body }: { body: BulkInstallPackagesResponse } = await supertest - .post(`/api/ingest_manager/epm/packages/_bulk`) + .post(`/api/fleet/epm/packages/_bulk`) .set('kbn-xsrf', 'xxxx') .send({ packages: ['multiple_versions', 'overrides'] }) .expect(200); @@ -98,7 +95,7 @@ export default function (providerContext: FtrProviderContext) { it('should return 200 and an array for upgrading a package', async function () { const { body }: { body: BulkInstallPackagesResponse } = await supertest - .post(`/api/ingest_manager/epm/packages/_bulk`) + .post(`/api/fleet/epm/packages/_bulk`) .set('kbn-xsrf', 'xxxx') .send({ packages: ['multiple_versions'] }) .expect(200); diff --git a/x-pack/test/ingest_manager_api_integration/apis/epm/data_stream.ts b/x-pack/test/ingest_manager_api_integration/apis/epm/data_stream.ts index 68a4812d4af40..5da9b5e3031b2 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/epm/data_stream.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/epm/data_stream.ts @@ -21,11 +21,11 @@ export default function (providerContext: FtrProviderContext) { const metricsTemplateName = `metrics-${pkgName}.test_metrics`; const uninstallPackage = async (pkg: string) => { - await supertest.delete(`/api/ingest_manager/epm/packages/${pkg}`).set('kbn-xsrf', 'xxxx'); + await supertest.delete(`/api/fleet/epm/packages/${pkg}`).set('kbn-xsrf', 'xxxx'); }; const installPackage = async (pkg: string) => { await supertest - .post(`/api/ingest_manager/epm/packages/${pkg}`) + .post(`/api/fleet/epm/packages/${pkg}`) .set('kbn-xsrf', 'xxxx') .send({ force: true }); }; diff --git a/x-pack/test/ingest_manager_api_integration/apis/epm/file.ts b/x-pack/test/ingest_manager_api_integration/apis/epm/file.ts index 3f99f91394d2c..ab89fceeb5b49 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/epm/file.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/epm/file.ts @@ -17,9 +17,7 @@ export default function ({ getService }: FtrProviderContext) { it('fetches a .png screenshot image', async function () { if (server.enabled) { await supertest - .get( - '/api/ingest_manager/epm/packages/filetest/0.1.0/img/screenshots/metricbeat_dashboard.png' - ) + .get('/api/fleet/epm/packages/filetest/0.1.0/img/screenshots/metricbeat_dashboard.png') .set('kbn-xsrf', 'xxx') .expect('Content-Type', 'image/png') .expect(200); @@ -31,7 +29,7 @@ export default function ({ getService }: FtrProviderContext) { it('fetches an .svg icon image', async function () { if (server.enabled) { await supertest - .get('/api/ingest_manager/epm/packages/filetest/0.1.0/img/logo.svg') + .get('/api/fleet/epm/packages/filetest/0.1.0/img/logo.svg') .set('kbn-xsrf', 'xxx') .expect('Content-Type', 'image/svg+xml') .expect(200); @@ -44,7 +42,7 @@ export default function ({ getService }: FtrProviderContext) { if (server.enabled) { await supertest .get( - '/api/ingest_manager/epm/packages/filetest/0.1.0/kibana/visualization/sample_visualization.json' + '/api/fleet/epm/packages/filetest/0.1.0/kibana/visualization/sample_visualization.json' ) .set('kbn-xsrf', 'xxx') .expect('Content-Type', 'application/json; charset=utf-8') @@ -57,9 +55,7 @@ export default function ({ getService }: FtrProviderContext) { it('fetches a .json kibana dashboard file', async function () { if (server.enabled) { await supertest - .get( - '/api/ingest_manager/epm/packages/filetest/0.1.0/kibana/dashboard/sample_dashboard.json' - ) + .get('/api/fleet/epm/packages/filetest/0.1.0/kibana/dashboard/sample_dashboard.json') .set('kbn-xsrf', 'xxx') .expect('Content-Type', 'application/json; charset=utf-8') .expect(200); @@ -71,7 +67,7 @@ export default function ({ getService }: FtrProviderContext) { it('fetches a .json search file', async function () { if (server.enabled) { await supertest - .get('/api/ingest_manager/epm/packages/filetest/0.1.0/kibana/search/sample_search.json') + .get('/api/fleet/epm/packages/filetest/0.1.0/kibana/search/sample_search.json') .set('kbn-xsrf', 'xxx') .expect('Content-Type', 'application/json; charset=utf-8') .expect(200); @@ -85,7 +81,7 @@ export default function ({ getService }: FtrProviderContext) { // it('fetches an .json index pattern file', async function () { // if (server.enabled) { // await supertest - // .get('/api/ingest_manager/epm/packages/filetest/0.1.0/kibana/index-pattern/sample-*.json') + // .get('/api/fleet/epm/packages/filetest/0.1.0/kibana/index-pattern/sample-*.json') // .set('kbn-xsrf', 'xxx') // .expect('Content-Type', 'application/json; charset=utf-8') // .expect(200); diff --git a/x-pack/test/ingest_manager_api_integration/apis/epm/get.ts b/x-pack/test/ingest_manager_api_integration/apis/epm/get.ts index 382bd6beb2e2f..c6de3a7f2b9dc 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/epm/get.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/epm/get.ts @@ -16,7 +16,7 @@ export default function ({ getService }: FtrProviderContext) { describe('EPM - get', () => { it('returns a 500 for a package key without a proper name', async function () { if (server.enabled) { - await supertest.get('/api/ingest_manager/epm/packages/-0.1.0').expect(500); + await supertest.get('/api/fleet/epm/packages/-0.1.0').expect(500); } else { warnAndSkipTest(this, log); } @@ -24,7 +24,7 @@ export default function ({ getService }: FtrProviderContext) { it('returns a 500 for a package key without a proper semver version', async function () { if (server.enabled) { - await supertest.get('/api/ingest_manager/epm/packages/endpoint-0.1.0.1.2.3').expect(500); + await supertest.get('/api/fleet/epm/packages/endpoint-0.1.0.1.2.3').expect(500); } else { warnAndSkipTest(this, log); } diff --git a/x-pack/test/ingest_manager_api_integration/apis/epm/install_by_upload.ts b/x-pack/test/ingest_manager_api_integration/apis/epm/install_by_upload.ts index 7fa0e0f38179a..4ad9501f3936f 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/epm/install_by_upload.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/epm/install_by_upload.ts @@ -49,7 +49,7 @@ export default function (providerContext: FtrProviderContext) { const server = dockerServers.get('registry'); const deletePackage = async (pkgkey: string) => { - await supertest.delete(`/api/ingest_manager/epm/packages/${pkgkey}`).set('kbn-xsrf', 'xxxx'); + await supertest.delete(`/api/fleet/epm/packages/${pkgkey}`).set('kbn-xsrf', 'xxxx'); }; describe('installs packages from direct upload', async () => { @@ -64,7 +64,7 @@ export default function (providerContext: FtrProviderContext) { it('should install a tar archive correctly', async function () { const buf = fs.readFileSync(testPkgArchiveTgz); const res = await supertest - .post(`/api/ingest_manager/epm/packages`) + .post(`/api/fleet/epm/packages`) .set('kbn-xsrf', 'xxxx') .type('application/gzip') .send(buf) @@ -75,7 +75,7 @@ export default function (providerContext: FtrProviderContext) { it('should install a zip archive correctly', async function () { const buf = fs.readFileSync(testPkgArchiveZip); const res = await supertest - .post(`/api/ingest_manager/epm/packages`) + .post(`/api/fleet/epm/packages`) .set('kbn-xsrf', 'xxxx') .type('application/zip') .send(buf) @@ -86,7 +86,7 @@ export default function (providerContext: FtrProviderContext) { it('should throw an error if the archive is zip but content type is gzip', async function () { const buf = fs.readFileSync(testPkgArchiveZip); const res = await supertest - .post(`/api/ingest_manager/epm/packages`) + .post(`/api/fleet/epm/packages`) .set('kbn-xsrf', 'xxxx') .type('application/gzip') .send(buf) @@ -99,7 +99,7 @@ export default function (providerContext: FtrProviderContext) { it('should throw an error if the archive is tar.gz but content type is zip', async function () { const buf = fs.readFileSync(testPkgArchiveTgz); const res = await supertest - .post(`/api/ingest_manager/epm/packages`) + .post(`/api/fleet/epm/packages`) .set('kbn-xsrf', 'xxxx') .type('application/zip') .send(buf) @@ -112,7 +112,7 @@ export default function (providerContext: FtrProviderContext) { it('should throw an error if the archive contains two top-level directories', async function () { const buf = fs.readFileSync(testPkgArchiveInvalidTwoToplevels); const res = await supertest - .post(`/api/ingest_manager/epm/packages`) + .post(`/api/fleet/epm/packages`) .set('kbn-xsrf', 'xxxx') .type('application/zip') .send(buf) @@ -125,7 +125,7 @@ export default function (providerContext: FtrProviderContext) { it('should throw an error if the archive does not contain a manifest', async function () { const buf = fs.readFileSync(testPkgArchiveInvalidNoManifest); const res = await supertest - .post(`/api/ingest_manager/epm/packages`) + .post(`/api/fleet/epm/packages`) .set('kbn-xsrf', 'xxxx') .type('application/zip') .send(buf) @@ -138,7 +138,7 @@ export default function (providerContext: FtrProviderContext) { it('should throw an error if the archive manifest contains invalid YAML', async function () { const buf = fs.readFileSync(testPkgArchiveInvalidManifestInvalidYaml); const res = await supertest - .post(`/api/ingest_manager/epm/packages`) + .post(`/api/fleet/epm/packages`) .set('kbn-xsrf', 'xxxx') .type('application/zip') .send(buf) @@ -151,7 +151,7 @@ export default function (providerContext: FtrProviderContext) { it('should throw an error if the archive manifest misses a mandatory field', async function () { const buf = fs.readFileSync(testPkgArchiveInvalidManifestMissingField); const res = await supertest - .post(`/api/ingest_manager/epm/packages`) + .post(`/api/fleet/epm/packages`) .set('kbn-xsrf', 'xxxx') .type('application/zip') .send(buf) @@ -164,7 +164,7 @@ export default function (providerContext: FtrProviderContext) { it('should throw an error if the toplevel directory name does not match the package key', async function () { const buf = fs.readFileSync(testPkgArchiveInvalidToplevelMismatch); const res = await supertest - .post(`/api/ingest_manager/epm/packages`) + .post(`/api/fleet/epm/packages`) .set('kbn-xsrf', 'xxxx') .type('application/zip') .send(buf) diff --git a/x-pack/test/ingest_manager_api_integration/apis/epm/install_overrides.ts b/x-pack/test/ingest_manager_api_integration/apis/epm/install_overrides.ts index c75c51f6a5000..a710ca4085cda 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/epm/install_overrides.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/epm/install_overrides.ts @@ -18,7 +18,7 @@ export default function ({ getService }: FtrProviderContext) { const server = dockerServers.get('registry'); const deletePackage = async (pkgkey: string) => { - await supertest.delete(`/api/ingest_manager/epm/packages/${pkgkey}`).set('kbn-xsrf', 'xxxx'); + await supertest.delete(`/api/fleet/epm/packages/${pkgkey}`).set('kbn-xsrf', 'xxxx'); }; describe('installs packages that include settings and mappings overrides', async () => { @@ -32,7 +32,7 @@ export default function ({ getService }: FtrProviderContext) { it('should install the overrides package correctly', async function () { if (server.enabled) { let { body } = await supertest - .post(`/api/ingest_manager/epm/packages/${mappingsPackage}`) + .post(`/api/fleet/epm/packages/${mappingsPackage}`) .set('kbn-xsrf', 'xxxx') .expect(200); diff --git a/x-pack/test/ingest_manager_api_integration/apis/epm/install_prerelease.ts b/x-pack/test/ingest_manager_api_integration/apis/epm/install_prerelease.ts index a641a105c66e0..f01a025f7b075 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/epm/install_prerelease.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/epm/install_prerelease.ts @@ -16,7 +16,7 @@ export default function ({ getService }: FtrProviderContext) { const server = dockerServers.get('registry'); const deletePackage = async (pkgkey: string) => { - await supertest.delete(`/api/ingest_manager/epm/packages/${pkgkey}`).set('kbn-xsrf', 'xxxx'); + await supertest.delete(`/api/fleet/epm/packages/${pkgkey}`).set('kbn-xsrf', 'xxxx'); }; describe('installs package that has a prerelease version', async () => { @@ -30,7 +30,7 @@ export default function ({ getService }: FtrProviderContext) { it('should install the package correctly', async function () { if (server.enabled) { await supertest - .post(`/api/ingest_manager/epm/packages/${testPackage}`) + .post(`/api/fleet/epm/packages/${testPackage}`) .set('kbn-xsrf', 'xxxx') .expect(200); } else { diff --git a/x-pack/test/ingest_manager_api_integration/apis/epm/install_remove_assets.ts b/x-pack/test/ingest_manager_api_integration/apis/epm/install_remove_assets.ts index 0b27498103f2d..96663f1b3fb12 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/epm/install_remove_assets.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/epm/install_remove_assets.ts @@ -20,11 +20,11 @@ export default function (providerContext: FtrProviderContext) { const metricsTemplateName = `metrics-${pkgName}.test_metrics`; const uninstallPackage = async (pkg: string) => { - await supertest.delete(`/api/ingest_manager/epm/packages/${pkg}`).set('kbn-xsrf', 'xxxx'); + await supertest.delete(`/api/fleet/epm/packages/${pkg}`).set('kbn-xsrf', 'xxxx'); }; const installPackage = async (pkg: string) => { await supertest - .post(`/api/ingest_manager/epm/packages/${pkg}`) + .post(`/api/fleet/epm/packages/${pkg}`) .set('kbn-xsrf', 'xxxx') .send({ force: true }); }; diff --git a/x-pack/test/ingest_manager_api_integration/apis/epm/install_update.ts b/x-pack/test/ingest_manager_api_integration/apis/epm/install_update.ts index bdcd202d8c46d..af64d83a8a139 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/epm/install_update.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/epm/install_update.ts @@ -18,7 +18,7 @@ export default function (providerContext: FtrProviderContext) { const supertest = getService('supertest'); const deletePackage = async (pkgkey: string) => { - await supertest.delete(`/api/ingest_manager/epm/packages/${pkgkey}`).set('kbn-xsrf', 'xxxx'); + await supertest.delete(`/api/fleet/epm/packages/${pkgkey}`).set('kbn-xsrf', 'xxxx'); }; describe('installing and updating scenarios', async () => { @@ -29,7 +29,7 @@ export default function (providerContext: FtrProviderContext) { it('should return 404 if package does not exist', async function () { await supertest - .post(`/api/ingest_manager/epm/packages/nonexistent-0.1.0`) + .post(`/api/fleet/epm/packages/nonexistent-0.1.0`) .set('kbn-xsrf', 'xxxx') .expect(404); let res; @@ -45,7 +45,7 @@ export default function (providerContext: FtrProviderContext) { }); it('should return 400 if trying to install an out-of-date package', async function () { await supertest - .post(`/api/ingest_manager/epm/packages/multiple_versions-0.1.0`) + .post(`/api/fleet/epm/packages/multiple_versions-0.1.0`) .set('kbn-xsrf', 'xxxx') .expect(400); let res; @@ -61,26 +61,26 @@ export default function (providerContext: FtrProviderContext) { }); it('should return 200 if trying to force install an out-of-date package', async function () { await supertest - .post(`/api/ingest_manager/epm/packages/multiple_versions-0.1.0`) + .post(`/api/fleet/epm/packages/multiple_versions-0.1.0`) .set('kbn-xsrf', 'xxxx') .send({ force: true }) .expect(200); }); it('should return 200 if trying to reinstall an out-of-date package', async function () { await supertest - .post(`/api/ingest_manager/epm/packages/multiple_versions-0.1.0`) + .post(`/api/fleet/epm/packages/multiple_versions-0.1.0`) .set('kbn-xsrf', 'xxxx') .expect(200); }); it('should return 400 if trying to update to an out-of-date package', async function () { await supertest - .post(`/api/ingest_manager/epm/packages/multiple_versions-0.2.0`) + .post(`/api/fleet/epm/packages/multiple_versions-0.2.0`) .set('kbn-xsrf', 'xxxx') .expect(400); }); it('should return 200 if trying to force update to an out-of-date package', async function () { await supertest - .post(`/api/ingest_manager/epm/packages/multiple_versions-0.2.0`) + .post(`/api/fleet/epm/packages/multiple_versions-0.2.0`) .set('kbn-xsrf', 'xxxx') .send({ force: true }) .expect(200); @@ -99,20 +99,20 @@ export default function (providerContext: FtrProviderContext) { }, }); await supertest - .post(`/api/ingest_manager/epm/packages/multiple_versions-0.2.0`) + .post(`/api/fleet/epm/packages/multiple_versions-0.2.0`) .set('kbn-xsrf', 'xxxx') .expect(200); }); it('should return 200 if trying to update to the latest package', async function () { await supertest - .post(`/api/ingest_manager/epm/packages/multiple_versions-0.3.0`) + .post(`/api/fleet/epm/packages/multiple_versions-0.3.0`) .set('kbn-xsrf', 'xxxx') .expect(200); await deletePackage('multiple_versions-0.3.0'); }); it('should return 200 if trying to install the latest package', async function () { await supertest - .post(`/api/ingest_manager/epm/packages/multiple_versions-0.3.0`) + .post(`/api/fleet/epm/packages/multiple_versions-0.3.0`) .set('kbn-xsrf', 'xxxx') .expect(200); }); diff --git a/x-pack/test/ingest_manager_api_integration/apis/epm/list.ts b/x-pack/test/ingest_manager_api_integration/apis/epm/list.ts index 732696433279f..4d22aad749239 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/epm/list.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/epm/list.ts @@ -25,7 +25,7 @@ export default function (providerContext: FtrProviderContext) { it('lists all packages from the registry', async function () { const fetchPackageList = async () => { const response = await supertest - .get('/api/ingest_manager/epm/packages') + .get('/api/fleet/epm/packages') .set('kbn-xsrf', 'xxx') .expect(200); return response.body; @@ -37,7 +37,7 @@ export default function (providerContext: FtrProviderContext) { it('lists all limited packages from the registry', async function () { const fetchLimitedPackageList = async () => { const response = await supertest - .get('/api/ingest_manager/epm/packages/limited') + .get('/api/fleet/epm/packages/limited') .set('kbn-xsrf', 'xxx') .expect(200); return response.body; diff --git a/x-pack/test/ingest_manager_api_integration/apis/epm/package_install_complete.ts b/x-pack/test/ingest_manager_api_integration/apis/epm/package_install_complete.ts index dc311c9db1913..6b43c9d74c6bf 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/epm/package_install_complete.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/epm/package_install_complete.ts @@ -22,7 +22,7 @@ export default function (providerContext: FtrProviderContext) { describe('package install', async () => { before(async () => { await supertest - .post(`/api/ingest_manager/epm/packages/${pkgName}-0.1.0`) + .post(`/api/fleet/epm/packages/${pkgName}-0.1.0`) .set('kbn-xsrf', 'xxxx') .send({ force: true }); }); @@ -32,7 +32,7 @@ export default function (providerContext: FtrProviderContext) { id: pkgName, }); const installStartedAtBeforeSetup = packageBeforeSetup.attributes.install_started_at; - await supertest.post(`/api/ingest_manager/setup`).set('kbn-xsrf', 'xxx').send(); + await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send(); const packageAfterSetup = await kibanaServer.savedObjects.get({ type: PACKAGES_SAVED_OBJECT_TYPE, id: pkgName, @@ -51,7 +51,7 @@ export default function (providerContext: FtrProviderContext) { install_started_at: previousInstallDate, }, }); - await supertest.post(`/api/ingest_manager/setup`).set('kbn-xsrf', 'xxx').send(); + await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send(); const packageAfterSetup = await kibanaServer.savedObjects.get({ type: PACKAGES_SAVED_OBJECT_TYPE, id: pkgName, @@ -71,7 +71,7 @@ export default function (providerContext: FtrProviderContext) { install_started_at: previousInstallDate, }, }); - await supertest.post(`/api/ingest_manager/setup`).set('kbn-xsrf', 'xxx').send(); + await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send(); const packageAfterSetup = await kibanaServer.savedObjects.get({ type: PACKAGES_SAVED_OBJECT_TYPE, id: pkgName, @@ -82,18 +82,18 @@ export default function (providerContext: FtrProviderContext) { }); after(async () => { await supertest - .delete(`/api/ingest_manager/epm/packages/multiple_versions-0.1.0`) + .delete(`/api/fleet/epm/packages/multiple_versions-0.1.0`) .set('kbn-xsrf', 'xxxx'); }); }); describe('package update', async () => { before(async () => { await supertest - .post(`/api/ingest_manager/epm/packages/${pkgName}-0.1.0`) + .post(`/api/fleet/epm/packages/${pkgName}-0.1.0`) .set('kbn-xsrf', 'xxxx') .send({ force: true }); await supertest - .post(`/api/ingest_manager/epm/packages/${pkgName}-0.2.0`) + .post(`/api/fleet/epm/packages/${pkgName}-0.2.0`) .set('kbn-xsrf', 'xxxx') .send({ force: true }); }); @@ -103,7 +103,7 @@ export default function (providerContext: FtrProviderContext) { id: pkgName, }); const installStartedAtBeforeSetup = packageBeforeSetup.attributes.install_started_at; - await supertest.post(`/api/ingest_manager/setup`).set('kbn-xsrf', 'xxx').send(); + await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send(); const packageAfterSetup = await kibanaServer.savedObjects.get({ type: PACKAGES_SAVED_OBJECT_TYPE, id: pkgName, @@ -124,7 +124,7 @@ export default function (providerContext: FtrProviderContext) { install_version: pkgUpdateVersion, // set version back }, }); - await supertest.post(`/api/ingest_manager/setup`).set('kbn-xsrf', 'xxx').send(); + await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send(); const packageAfterSetup = await kibanaServer.savedObjects.get({ type: PACKAGES_SAVED_OBJECT_TYPE, id: pkgName, @@ -147,7 +147,7 @@ export default function (providerContext: FtrProviderContext) { version: pkgVersion, // set version back }, }); - await supertest.post(`/api/ingest_manager/setup`).set('kbn-xsrf', 'xxx').send(); + await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send(); const packageAfterSetup = await kibanaServer.savedObjects.get({ type: PACKAGES_SAVED_OBJECT_TYPE, id: pkgName, @@ -159,7 +159,7 @@ export default function (providerContext: FtrProviderContext) { }); after(async () => { await supertest - .delete(`/api/ingest_manager/epm/packages/multiple_versions-0.1.0`) + .delete(`/api/fleet/epm/packages/multiple_versions-0.1.0`) .set('kbn-xsrf', 'xxxx'); }); }); diff --git a/x-pack/test/ingest_manager_api_integration/apis/epm/setup.ts b/x-pack/test/ingest_manager_api_integration/apis/epm/setup.ts index da06f49dd6139..15cff79475f08 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/epm/setup.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/epm/setup.ts @@ -20,23 +20,23 @@ export default function (providerContext: FtrProviderContext) { const oldEndpointVersion = '0.13.0'; beforeEach(async () => { await supertest - .post(`/api/ingest_manager/epm/packages/endpoint-${oldEndpointVersion}`) + .post(`/api/fleet/epm/packages/endpoint-${oldEndpointVersion}`) .set('kbn-xsrf', 'xxxx') .send({ force: true }) .expect(200); }); it('upgrades the endpoint package from 0.13.0 to the latest version available', async function () { let { body }: { body: GetInfoResponse } = await supertest - .get(`/api/ingest_manager/epm/packages/endpoint-${oldEndpointVersion}`) + .get(`/api/fleet/epm/packages/endpoint-${oldEndpointVersion}`) .expect(200); const latestEndpointVersion = body.response.latestVersion; log.info(`Endpoint package latest version: ${latestEndpointVersion}`); // make sure we're actually doing an upgrade expect(latestEndpointVersion).not.eql(oldEndpointVersion); - await supertest.post(`/api/ingest_manager/setup`).set('kbn-xsrf', 'xxxx').expect(200); + await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxxx').expect(200); ({ body } = await supertest - .get(`/api/ingest_manager/epm/packages/endpoint-${latestEndpointVersion}`) + .get(`/api/fleet/epm/packages/endpoint-${latestEndpointVersion}`) .expect(200)); expect(body.response).to.have.property('savedObject'); expect((body.response as Installed).savedObject.attributes.install_version).to.eql( diff --git a/x-pack/test/ingest_manager_api_integration/apis/epm/update_assets.ts b/x-pack/test/ingest_manager_api_integration/apis/epm/update_assets.ts index 8608756c37f54..90dce92a2c6b5 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/epm/update_assets.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/epm/update_assets.ts @@ -23,11 +23,11 @@ export default function (providerContext: FtrProviderContext) { const metricsTemplateName = `metrics-${pkgName}.test_metrics`; const uninstallPackage = async (pkg: string) => { - await supertest.delete(`/api/ingest_manager/epm/packages/${pkg}`).set('kbn-xsrf', 'xxxx'); + await supertest.delete(`/api/fleet/epm/packages/${pkg}`).set('kbn-xsrf', 'xxxx'); }; const installPackage = async (pkg: string) => { await supertest - .post(`/api/ingest_manager/epm/packages/${pkg}`) + .post(`/api/fleet/epm/packages/${pkg}`) .set('kbn-xsrf', 'xxxx') .send({ force: true }); }; diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/acks.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/acks.ts index b119e6d58dc35..119efa92d2327 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/acks.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/acks.ts @@ -50,7 +50,7 @@ export default function (providerContext: FtrProviderContext) { it('should return a 401 if this a not a valid acks access', async () => { await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/acks`) + .post(`/api/fleet/agents/agent1/acks`) .set('kbn-xsrf', 'xx') .set('Authorization', 'ApiKey NOT_A_VALID_TOKEN') .send({ @@ -61,7 +61,7 @@ export default function (providerContext: FtrProviderContext) { it('should return a 200 if this a valid acks request', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/acks`) + .post(`/api/fleet/agents/agent1/acks`) .set('kbn-xsrf', 'xx') .set( 'Authorization', @@ -92,7 +92,7 @@ export default function (providerContext: FtrProviderContext) { .expect(200); expect(apiResponse.action).to.be('acks'); const { body: eventResponse } = await supertest - .get(`/api/ingest_manager/fleet/agents/agent1/events`) + .get(`/api/fleet/agents/agent1/events`) .set('kbn-xsrf', 'xx') .set( 'Authorization', @@ -121,7 +121,7 @@ export default function (providerContext: FtrProviderContext) { it('should return a 400 when request event list contains event for another agent id', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/acks`) + .post(`/api/fleet/agents/agent1/acks`) .set('kbn-xsrf', 'xx') .set( 'Authorization', @@ -148,7 +148,7 @@ export default function (providerContext: FtrProviderContext) { it('should return a 400 when request event list contains action that does not belong to agent current actions', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/acks`) + .post(`/api/fleet/agents/agent1/acks`) .set('kbn-xsrf', 'xx') .set( 'Authorization', @@ -182,7 +182,7 @@ export default function (providerContext: FtrProviderContext) { it('should return a 400 when request event list contains action types that are not allowed for acknowledgement', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/acks`) + .post(`/api/fleet/agents/agent1/acks`) .set('kbn-xsrf', 'xx') .set( 'Authorization', @@ -209,7 +209,7 @@ export default function (providerContext: FtrProviderContext) { it('ack upgrade should update fleet-agent SO', async () => { const { body: actionRes } = await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/actions`) + .post(`/api/fleet/agents/agent1/actions`) .set('kbn-xsrf', 'xx') .set( 'Authorization', @@ -224,7 +224,7 @@ export default function (providerContext: FtrProviderContext) { .expect(200); const actionId = actionRes.item.id; await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/acks`) + .post(`/api/fleet/agents/agent1/acks`) .set('kbn-xsrf', 'xx') .set( 'Authorization', diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/actions.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/actions.ts index f5a647593ef52..df0de51aa2611 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/actions.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/actions.ts @@ -22,7 +22,7 @@ export default function (providerContext: FtrProviderContext) { it('should return a 200 if this a valid actions request', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/actions`) + .post(`/api/fleet/agents/agent1/actions`) .set('kbn-xsrf', 'xx') .send({ action: { @@ -38,7 +38,7 @@ export default function (providerContext: FtrProviderContext) { it('should return a 400 when request does not have type information', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/actions`) + .post(`/api/fleet/agents/agent1/actions`) .set('kbn-xsrf', 'xx') .send({ action: { @@ -54,7 +54,7 @@ export default function (providerContext: FtrProviderContext) { it('should return a 404 when agent does not exist', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/agents/agent100/actions`) + .post(`/api/fleet/agents/agent100/actions`) .set('kbn-xsrf', 'xx') .send({ action: { diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/checkin.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/checkin.ts index fbfc94a0840b0..a8e811548ef27 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/checkin.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/checkin.ts @@ -53,7 +53,7 @@ export default function (providerContext: FtrProviderContext) { it('should return a 401 if this a not a valid checkin access', async () => { await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/checkin`) + .post(`/api/fleet/agents/agent1/checkin`) .set('kbn-xsrf', 'xx') .set('Authorization', 'ApiKey NOT_A_VALID_TOKEN') .send({ @@ -64,7 +64,7 @@ export default function (providerContext: FtrProviderContext) { it('should return a 400 if for a malformed request payload', async () => { await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/checkin`) + .post(`/api/fleet/agents/agent1/checkin`) .set('kbn-xsrf', 'xx') .set( 'Authorization', @@ -79,7 +79,7 @@ export default function (providerContext: FtrProviderContext) { it('should return a 200 if this a valid checkin access', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/checkin`) + .post(`/api/fleet/agents/agent1/checkin`) .set('kbn-xsrf', 'xx') .set( 'Authorization', diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/complete_flow.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/complete_flow.ts index a59b3ff0890f7..80b831f875d17 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/complete_flow.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/complete_flow.ts @@ -35,14 +35,172 @@ export default function (providerContext: FtrProviderContext) { // Get enrollment token const { body: enrollmentApiKeysResponse } = await supertest - .get(`/api/ingest_manager/fleet/enrollment-api-keys`) + .get(`/api/fleet/enrollment-api-keys`) .expect(200); expect(enrollmentApiKeysResponse.list).length(1); const { body: enrollmentApiKeyResponse } = await supertest - .get( - `/api/ingest_manager/fleet/enrollment-api-keys/${enrollmentApiKeysResponse.list[0].id}` - ) + .get(`/api/fleet/enrollment-api-keys/${enrollmentApiKeysResponse.list[0].id}`) + .expect(200); + + expect(enrollmentApiKeyResponse.item).to.have.key('api_key'); + const enrollmentAPIToken = enrollmentApiKeyResponse.item.api_key; + // Enroll agent + const { body: enrollmentResponse } = await supertestWithoutAuth + .post(`/api/fleet/agents/enroll`) + .set('kbn-xsrf', 'xxx') + .set('Authorization', `ApiKey ${enrollmentAPIToken}`) + .send({ + type: 'PERMANENT', + metadata: { + local: { + elastic: { agent: { version: kibanaVersion } }, + }, + user_provided: {}, + }, + }) + .expect(200); + + const agentAccessAPIKey = enrollmentResponse.item.access_api_key; + + // Agent checkin + const { body: checkinApiResponse } = await supertestWithoutAuth + .post(`/api/fleet/agents/${enrollmentResponse.item.id}/checkin`) + .set('kbn-xsrf', 'xx') + .set('Authorization', `ApiKey ${agentAccessAPIKey}`) + .send({ + events: [], + }) + .expect(200); + + expect(checkinApiResponse.actions).length(1); + expect(checkinApiResponse.actions[0].type).be('POLICY_CHANGE'); + const policyChangeAction = checkinApiResponse.actions[0]; + const defaultOutputApiKey = policyChangeAction.data.policy.outputs.default.api_key; + + // Ack actions + await supertestWithoutAuth + .post(`/api/fleet/agents/${enrollmentResponse.item.id}/acks`) + .set('Authorization', `ApiKey ${agentAccessAPIKey}`) + .set('kbn-xsrf', 'xx') + + .send({ + events: [ + { + type: 'ACTION_RESULT', + subtype: 'ACKNOWLEDGED', + timestamp: '2019-01-04T14:32:03.36764-05:00', + action_id: policyChangeAction.id, + agent_id: enrollmentResponse.item.id, + message: 'hello', + payload: 'payload', + }, + ], + }) + .expect(200); + + // Second agent checkin + const { body: secondCheckinApiResponse } = await supertestWithoutAuth + .post(`/api/fleet/agents/${enrollmentResponse.item.id}/checkin`) + .set('kbn-xsrf', 'xx') + .set('Authorization', `ApiKey ${agentAccessAPIKey}`) + .send({ + events: [], + }) + .expect(200); + expect(secondCheckinApiResponse.actions).length(0); + + // Get agent + const { body: getAgentApiResponse } = await supertest + .get(`/api/fleet/agents/${enrollmentResponse.item.id}`) + .expect(200); + + expect(getAgentApiResponse.item.packages).to.contain( + 'system', + "Agent should run the 'system' package" + ); + + // Unenroll agent + await supertest + .post(`/api/fleet/agents/${enrollmentResponse.item.id}/unenroll`) + .set('kbn-xsrf', 'xx') + .expect(200); + + // Checkin after unenrollment + const { body: checkinAfterUnenrollResponse } = await supertestWithoutAuth + .post(`/api/fleet/agents/${enrollmentResponse.item.id}/checkin`) + .set('kbn-xsrf', 'xx') + .set('Authorization', `ApiKey ${agentAccessAPIKey}`) + .send({ + events: [], + }) + .expect(200); + + expect(checkinAfterUnenrollResponse.actions).length(1); + expect(checkinAfterUnenrollResponse.actions[0].type).be('UNENROLL'); + const unenrollAction = checkinAfterUnenrollResponse.actions[0]; + + // ack unenroll actions + await supertestWithoutAuth + .post(`/api/fleet/agents/${enrollmentResponse.item.id}/acks`) + .set('Authorization', `ApiKey ${agentAccessAPIKey}`) + .set('kbn-xsrf', 'xx') + .send({ + events: [ + { + type: 'ACTION_RESULT', + subtype: 'ACKNOWLEDGED', + timestamp: '2019-01-04T14:32:03.36764-05:00', + action_id: unenrollAction.id, + agent_id: enrollmentResponse.item.id, + message: 'hello', + payload: 'payload', + }, + ], + }) + .expect(200); + + // Checkin after unenrollment acknowledged + await supertestWithoutAuth + .post(`/api/fleet/agents/${enrollmentResponse.item.id}/checkin`) + .set('kbn-xsrf', 'xx') + .set('Authorization', `ApiKey ${agentAccessAPIKey}`) + .send({ + events: [], + }) + .expect(401); + + // very api key are invalidated + const { + body: { api_keys: accessAPIKeys }, + } = await esClient.security.getApiKey({ + id: Buffer.from(agentAccessAPIKey, 'base64').toString('utf8').split(':')[0], + }); + expect(accessAPIKeys).length(1); + expect(accessAPIKeys[0].invalidated).eql(true); + + const { + body: { api_keys: outputAPIKeys }, + } = await esClient.security.getApiKey({ + id: defaultOutputApiKey.split(':')[0], + }); + expect(outputAPIKeys).length(1); + expect(outputAPIKeys[0].invalidated).eql(true); + }); + + // BWC for agent <= 7.9 + it('should work with 7.9 APIs', async () => { + const kibanaVersionAccessor = kibanaServer.version; + const kibanaVersion = await kibanaVersionAccessor.get(); + + // Get enrollment token + const { body: enrollmentApiKeysResponse } = await supertest + .get(`/api/fleet/enrollment-api-keys`) + .expect(200); + + expect(enrollmentApiKeysResponse.list).length(1); + const { body: enrollmentApiKeyResponse } = await supertest + .get(`/api/fleet/enrollment-api-keys/${enrollmentApiKeysResponse.list[0].id}`) .expect(200); expect(enrollmentApiKeyResponse.item).to.have.key('api_key'); @@ -114,7 +272,7 @@ export default function (providerContext: FtrProviderContext) { // Get agent const { body: getAgentApiResponse } = await supertest - .get(`/api/ingest_manager/fleet/agents/${enrollmentResponse.item.id}`) + .get(`/api/fleet/agents/${enrollmentResponse.item.id}`) .expect(200); expect(getAgentApiResponse.item.packages).to.contain( @@ -124,7 +282,7 @@ export default function (providerContext: FtrProviderContext) { // Unenroll agent await supertest - .post(`/api/ingest_manager/fleet/agents/${enrollmentResponse.item.id}/unenroll`) + .post(`/api/fleet/agents/${enrollmentResponse.item.id}/unenroll`) .set('kbn-xsrf', 'xx') .expect(200); diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/delete.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/delete.ts index 65fbdabe8bd79..908112643fee7 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/delete.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/delete.ts @@ -62,7 +62,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return a 404 if user lacks fleet-write permissions', async () => { const { body: apiResponse } = await supertest - .delete(`/api/ingest_manager/fleet/agents/agent1`) + .delete(`/api/fleet/agents/agent1`) .auth(users.fleet_user.username, users.fleet_user.password) .set('kbn-xsrf', 'xx') .expect(404); @@ -74,7 +74,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return a 404 if there is no agent to delete', async () => { await supertest - .delete(`/api/ingest_manager/fleet/agents/i-do-not-exist`) + .delete(`/api/fleet/agents/i-do-not-exist`) .auth(users.fleet_admin.username, users.fleet_admin.password) .set('kbn-xsrf', 'xx') .expect(404); @@ -82,7 +82,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return a 200 after deleting an agent', async () => { const { body: apiResponse } = await supertest - .delete(`/api/ingest_manager/fleet/agents/agent1`) + .delete(`/api/fleet/agents/agent1`) .auth(users.fleet_admin.username, users.fleet_admin.password) .set('kbn-xsrf', 'xx') .expect(200); diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/enroll.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/enroll.ts index eef0d3beb69d0..c47099e620144 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/enroll.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/enroll.ts @@ -59,7 +59,7 @@ export default function (providerContext: FtrProviderContext) { it('should not allow to enroll an agent with a invalid enrollment', async () => { await supertest - .post(`/api/ingest_manager/fleet/agents/enroll`) + .post(`/api/fleet/agents/enroll`) .set('kbn-xsrf', 'xxx') .set('Authorization', 'ApiKey NOTAVALIDKEY') .send({ @@ -76,7 +76,7 @@ export default function (providerContext: FtrProviderContext) { it('should not allow to enroll an agent with a shared id if it already exists ', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/agents/enroll`) + .post(`/api/fleet/agents/enroll`) .set('kbn-xsrf', 'xxx') .set( 'authorization', @@ -98,7 +98,7 @@ export default function (providerContext: FtrProviderContext) { it('should not allow to enroll an agent with a version > kibana', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/agents/enroll`) + .post(`/api/fleet/agents/enroll`) .set('kbn-xsrf', 'xxx') .set( 'authorization', @@ -120,7 +120,7 @@ export default function (providerContext: FtrProviderContext) { it('should allow to enroll an agent with a valid enrollment token', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/agents/enroll`) + .post(`/api/fleet/agents/enroll`) .set('kbn-xsrf', 'xxx') .set( 'Authorization', @@ -141,7 +141,7 @@ export default function (providerContext: FtrProviderContext) { it('when enrolling an agent it should generate an access api key with limited privileges', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/agents/enroll`) + .post(`/api/fleet/agents/enroll`) .set('kbn-xsrf', 'xxx') .set( 'Authorization', diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/events.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/events.ts index 29680653bba5c..bed4fbcbe370b 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/events.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/events.ts @@ -22,7 +22,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return a 200 and the events for a given agent', async () => { const { body: apiResponse } = await supertest - .get(`/api/ingest_manager/fleet/agents/agent1/events`) + .get(`/api/fleet/agents/agent1/events`) .expect(200); expect(apiResponse).to.have.keys(['list', 'total', 'page']); expect(apiResponse.total).to.be(2); @@ -35,13 +35,13 @@ export default function ({ getService }: FtrProviderContext) { it('should return a 400 when given an invalid "kuery" value', async () => { await supertest - .get(`/api/ingest_manager/fleet/agents/agent1/events?kuery=m`) // missing saved object type + .get(`/api/fleet/agents/agent1/events?kuery=m`) // missing saved object type .expect(400); }); it('should accept a valid "kuery" value', async () => { const filter = encodeURIComponent('fleet-agent-events.subtype : "STOPPED"'); const { body: apiResponse } = await supertest - .get(`/api/ingest_manager/fleet/agents/agent1/events?kuery=${filter}`) + .get(`/api/fleet/agents/agent1/events?kuery=${filter}`) .expect(200); expect(apiResponse).to.have.keys(['list', 'total', 'page']); diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/list.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/list.ts index 0c6c39dde0547..e55c570b32936 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/list.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/list.ts @@ -74,7 +74,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return the list of agents when requesting as a user with fleet write permissions', async () => { const { body: apiResponse } = await supertest - .get(`/api/ingest_manager/fleet/agents`) + .get(`/api/fleet/agents`) .auth(users.fleet_admin.username, users.fleet_admin.password) .expect(200); @@ -83,7 +83,7 @@ export default function ({ getService }: FtrProviderContext) { }); it('should return the list of agents when requesting as a user with fleet read permissions', async () => { const { body: apiResponse } = await supertest - .get(`/api/ingest_manager/fleet/agents`) + .get(`/api/fleet/agents`) .auth(users.fleet_user.username, users.fleet_user.password) .expect(200); expect(apiResponse).to.have.keys('page', 'total', 'list'); @@ -91,20 +91,20 @@ export default function ({ getService }: FtrProviderContext) { }); it('should not return the list of agents when requesting as a user without fleet permissions', async () => { await supertest - .get(`/api/ingest_manager/fleet/agents`) + .get(`/api/fleet/agents`) .auth(users.kibana_basic_user.username, users.kibana_basic_user.password) .expect(404); }); it('should return a 400 when given an invalid "kuery" value', async () => { await supertest - .get(`/api/ingest_manager/fleet/agents?kuery=m`) // missing saved object type + .get(`/api/fleet/agents?kuery=m`) // missing saved object type .auth(users.fleet_user.username, users.fleet_user.password) .expect(400); }); it('should accept a valid "kuery" value', async () => { const filter = encodeURIComponent('fleet-agents.shared_id : "agent2_filebeat"'); const { body: apiResponse } = await supertest - .get(`/api/ingest_manager/fleet/agents?kuery=${filter}`) + .get(`/api/fleet/agents?kuery=${filter}`) .auth(users.fleet_user.username, users.fleet_user.password) .expect(200); diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/reassign.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/reassign.ts index f3e24fab1dc2a..251f6a9bd695b 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/reassign.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/reassign.ts @@ -23,21 +23,19 @@ export default function (providerContext: FtrProviderContext) { it('should allow to reassign single agent', async () => { await supertest - .put(`/api/ingest_manager/fleet/agents/agent1/reassign`) + .put(`/api/fleet/agents/agent1/reassign`) .set('kbn-xsrf', 'xxx') .send({ policy_id: 'policy2', }) .expect(200); - const { body } = await supertest - .get(`/api/ingest_manager/fleet/agents/agent1`) - .set('kbn-xsrf', 'xxx'); + const { body } = await supertest.get(`/api/fleet/agents/agent1`).set('kbn-xsrf', 'xxx'); expect(body.item.policy_id).to.eql('policy2'); }); it('should throw an error for invalid policy id for single reassign', async () => { await supertest - .put(`/api/ingest_manager/fleet/agents/agent1/reassign`) + .put(`/api/fleet/agents/agent1/reassign`) .set('kbn-xsrf', 'xxx') .send({ policy_id: 'INVALID_ID', @@ -47,7 +45,7 @@ export default function (providerContext: FtrProviderContext) { it('should allow to reassign multiple agents by id', async () => { await supertest - .post(`/api/ingest_manager/fleet/agents/bulk_reassign`) + .post(`/api/fleet/agents/bulk_reassign`) .set('kbn-xsrf', 'xxx') .send({ agents: ['agent2', 'agent3'], @@ -55,8 +53,8 @@ export default function (providerContext: FtrProviderContext) { }) .expect(200); const [agent2data, agent3data] = await Promise.all([ - supertest.get(`/api/ingest_manager/fleet/agents/agent2`).set('kbn-xsrf', 'xxx'), - supertest.get(`/api/ingest_manager/fleet/agents/agent3`).set('kbn-xsrf', 'xxx'), + supertest.get(`/api/fleet/agents/agent2`).set('kbn-xsrf', 'xxx'), + supertest.get(`/api/fleet/agents/agent3`).set('kbn-xsrf', 'xxx'), ]); expect(agent2data.body.item.policy_id).to.eql('policy2'); expect(agent3data.body.item.policy_id).to.eql('policy2'); @@ -64,16 +62,14 @@ export default function (providerContext: FtrProviderContext) { it('should allow to reassign multiple agents by kuery', async () => { await supertest - .post(`/api/ingest_manager/fleet/agents/bulk_reassign`) + .post(`/api/fleet/agents/bulk_reassign`) .set('kbn-xsrf', 'xxx') .send({ agents: 'fleet-agents.active: true', policy_id: 'policy2', }) .expect(200); - const { body } = await supertest - .get(`/api/ingest_manager/fleet/agents`) - .set('kbn-xsrf', 'xxx'); + const { body } = await supertest.get(`/api/fleet/agents`).set('kbn-xsrf', 'xxx'); expect(body.total).to.eql(4); body.list.forEach((agent: any) => { expect(agent.policy_id).to.eql('policy2'); @@ -82,7 +78,7 @@ export default function (providerContext: FtrProviderContext) { it('should throw an error for invalid policy id for bulk reassign', async () => { await supertest - .post(`/api/ingest_manager/fleet/agents/bulk_reassign`) + .post(`/api/fleet/agents/bulk_reassign`) .set('kbn-xsrf', 'xxx') .send({ agents: ['agent2', 'agent3'], diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/services.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/services.ts index 70d59ecc0b0da..7539fcf37a3de 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/services.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/services.ts @@ -33,9 +33,9 @@ export function getEsClientForAPIKey({ getService }: FtrProviderContext, esApiKe export function setupIngest({ getService }: FtrProviderContext) { before(async () => { - await getService('supertest').post(`/api/ingest_manager/setup`).set('kbn-xsrf', 'xxx').send(); + await getService('supertest').post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send(); await getService('supertest') - .post(`/api/ingest_manager/fleet/setup`) + .post(`/api/fleet/agents/setup`) .set('kbn-xsrf', 'xxx') .send({ forceRecreate: true }); }); diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/unenroll.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/unenroll.ts index ce5dfd7714ab2..05702a6dcb1ce 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/unenroll.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/unenroll.ts @@ -66,7 +66,7 @@ export default function (providerContext: FtrProviderContext) { it('should allow to unenroll single agent', async () => { await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/unenroll`) + .post(`/api/fleet/agents/agent1/unenroll`) .set('kbn-xsrf', 'xxx') .send({ force: true, @@ -76,7 +76,7 @@ export default function (providerContext: FtrProviderContext) { it('should invalidate related API keys', async () => { await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/unenroll`) + .post(`/api/fleet/agents/agent1/unenroll`) .set('kbn-xsrf', 'xxx') .send({ force: true, @@ -98,15 +98,15 @@ export default function (providerContext: FtrProviderContext) { it('should allow to unenroll multiple agents by id', async () => { await supertest - .post(`/api/ingest_manager/fleet/agents/bulk_unenroll`) + .post(`/api/fleet/agents/bulk_unenroll`) .set('kbn-xsrf', 'xxx') .send({ agents: ['agent2', 'agent3'], }) .expect(200); const [agent2data, agent3data] = await Promise.all([ - supertest.get(`/api/ingest_manager/fleet/agents/agent2`).set('kbn-xsrf', 'xxx'), - supertest.get(`/api/ingest_manager/fleet/agents/agent3`).set('kbn-xsrf', 'xxx'), + supertest.get(`/api/fleet/agents/agent2`).set('kbn-xsrf', 'xxx'), + supertest.get(`/api/fleet/agents/agent3`).set('kbn-xsrf', 'xxx'), ]); expect(typeof agent2data.body.item.unenrollment_started_at).to.eql('string'); expect(agent2data.body.item.active).to.eql(true); @@ -116,7 +116,7 @@ export default function (providerContext: FtrProviderContext) { it('should allow to unenroll multiple agents by kuery', async () => { await supertest - .post(`/api/ingest_manager/fleet/agents/bulk_unenroll`) + .post(`/api/fleet/agents/bulk_unenroll`) .set('kbn-xsrf', 'xxx') .send({ agents: 'fleet-agents.active: true', @@ -124,9 +124,7 @@ export default function (providerContext: FtrProviderContext) { }) .expect(200); - const { body } = await supertest - .get(`/api/ingest_manager/fleet/agents`) - .set('kbn-xsrf', 'xxx'); + const { body } = await supertest.get(`/api/fleet/agents`).set('kbn-xsrf', 'xxx'); expect(body.total).to.eql(0); }); }); diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/upgrade.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/upgrade.ts index ed0d6ff97e986..ea254cb5f3861 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/upgrade.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/agents/upgrade.ts @@ -37,7 +37,7 @@ export default function (providerContext: FtrProviderContext) { }, }); await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/upgrade`) + .post(`/api/fleet/agents/agent1/upgrade`) .set('kbn-xsrf', 'xxx') .send({ version: kibanaVersion, @@ -45,9 +45,7 @@ export default function (providerContext: FtrProviderContext) { }) .expect(200); - const res = await supertest - .get(`/api/ingest_manager/fleet/agents/agent1`) - .set('kbn-xsrf', 'xxx'); + const res = await supertest.get(`/api/fleet/agents/agent1`).set('kbn-xsrf', 'xxx'); expect(typeof res.body.item.upgrade_started_at).to.be('string'); }); it('should respond 200 to upgrade agent and update the agent SO without source_uri', async () => { @@ -60,15 +58,13 @@ export default function (providerContext: FtrProviderContext) { }, }); await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/upgrade`) + .post(`/api/fleet/agents/agent1/upgrade`) .set('kbn-xsrf', 'xxx') .send({ version: kibanaVersion, }) .expect(200); - const res = await supertest - .get(`/api/ingest_manager/fleet/agents/agent1`) - .set('kbn-xsrf', 'xxx'); + const res = await supertest.get(`/api/fleet/agents/agent1`).set('kbn-xsrf', 'xxx'); expect(typeof res.body.item.upgrade_started_at).to.be('string'); }); @@ -76,7 +72,7 @@ export default function (providerContext: FtrProviderContext) { const kibanaVersion = await kibanaServer.version.get(); const higherVersion = semver.inc(kibanaVersion, 'patch'); await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/upgrade`) + .post(`/api/fleet/agents/agent1/upgrade`) .set('kbn-xsrf', 'xxx') .send({ version: higherVersion, @@ -86,14 +82,11 @@ export default function (providerContext: FtrProviderContext) { }); it('should respond 400 if trying to upgrade an agent that is unenrolling', async () => { const kibanaVersion = await kibanaServer.version.get(); + await supertest.post(`/api/fleet/agents/agent1/unenroll`).set('kbn-xsrf', 'xxx').send({ + force: true, + }); await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/unenroll`) - .set('kbn-xsrf', 'xxx') - .send({ - force: true, - }); - await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/upgrade`) + .post(`/api/fleet/agents/agent1/upgrade`) .set('kbn-xsrf', 'xxx') .send({ version: kibanaVersion, @@ -108,7 +101,7 @@ export default function (providerContext: FtrProviderContext) { attributes: { unenrolled_at: new Date().toISOString() }, }); await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/upgrade`) + .post(`/api/fleet/agents/agent1/upgrade`) .set('kbn-xsrf', 'xxx') .send({ version: kibanaVersion, @@ -132,7 +125,7 @@ export default function (providerContext: FtrProviderContext) { const kibanaVersion = await kibanaServer.version.get(); await supertest - .post(`/api/ingest_manager/fleet/agents/bulk_upgrade`) + .post(`/api/fleet/agents/bulk_upgrade`) .set('kbn-xsrf', 'xxx') .send({ version: kibanaVersion, @@ -141,8 +134,8 @@ export default function (providerContext: FtrProviderContext) { .expect(200); const [agent1data, agent2data] = await Promise.all([ - supertest.get(`/api/ingest_manager/fleet/agents/agent1`).set('kbn-xsrf', 'xxx'), - supertest.get(`/api/ingest_manager/fleet/agents/agent2`).set('kbn-xsrf', 'xxx'), + supertest.get(`/api/fleet/agents/agent1`).set('kbn-xsrf', 'xxx'), + supertest.get(`/api/fleet/agents/agent2`).set('kbn-xsrf', 'xxx'), ]); expect(typeof agent1data.body.item.upgrade_started_at).to.be('string'); expect(typeof agent2data.body.item.upgrade_started_at).to.be('string'); @@ -151,7 +144,7 @@ export default function (providerContext: FtrProviderContext) { it('should allow to upgrade multiple agents by kuery', async () => { const kibanaVersion = await kibanaServer.version.get(); await supertest - .post(`/api/ingest_manager/fleet/agents/bulk_upgrade`) + .post(`/api/fleet/agents/bulk_upgrade`) .set('kbn-xsrf', 'xxx') .send({ agents: 'fleet-agents.active: true', @@ -159,8 +152,8 @@ export default function (providerContext: FtrProviderContext) { }) .expect(200); const [agent1data, agent2data] = await Promise.all([ - supertest.get(`/api/ingest_manager/fleet/agents/agent1`).set('kbn-xsrf', 'xxx'), - supertest.get(`/api/ingest_manager/fleet/agents/agent2`).set('kbn-xsrf', 'xxx'), + supertest.get(`/api/fleet/agents/agent1`).set('kbn-xsrf', 'xxx'), + supertest.get(`/api/fleet/agents/agent2`).set('kbn-xsrf', 'xxx'), ]); expect(typeof agent1data.body.item.upgrade_started_at).to.be('string'); expect(typeof agent2data.body.item.upgrade_started_at).to.be('string'); @@ -168,22 +161,19 @@ export default function (providerContext: FtrProviderContext) { it('should not upgrade an unenrolling agent during bulk_upgrade', async () => { const kibanaVersion = await kibanaServer.version.get(); + await supertest.post(`/api/fleet/agents/agent1/unenroll`).set('kbn-xsrf', 'xxx').send({ + force: true, + }); await supertest - .post(`/api/ingest_manager/fleet/agents/agent1/unenroll`) - .set('kbn-xsrf', 'xxx') - .send({ - force: true, - }); - await supertest - .post(`/api/ingest_manager/fleet/agents/bulk_upgrade`) + .post(`/api/fleet/agents/bulk_upgrade`) .set('kbn-xsrf', 'xxx') .send({ agents: ['agent1', 'agent2'], version: kibanaVersion, }); const [agent1data, agent2data] = await Promise.all([ - supertest.get(`/api/ingest_manager/fleet/agents/agent1`).set('kbn-xsrf', 'xxx'), - supertest.get(`/api/ingest_manager/fleet/agents/agent2`).set('kbn-xsrf', 'xxx'), + supertest.get(`/api/fleet/agents/agent1`).set('kbn-xsrf', 'xxx'), + supertest.get(`/api/fleet/agents/agent2`).set('kbn-xsrf', 'xxx'), ]); expect(typeof agent1data.body.item.upgrade_started_at).to.be('undefined'); expect(typeof agent2data.body.item.upgrade_started_at).to.be('string'); @@ -196,15 +186,15 @@ export default function (providerContext: FtrProviderContext) { attributes: { unenrolled_at: new Date().toISOString() }, }); await supertest - .post(`/api/ingest_manager/fleet/agents/bulk_upgrade`) + .post(`/api/fleet/agents/bulk_upgrade`) .set('kbn-xsrf', 'xxx') .send({ agents: ['agent1', 'agent2'], version: kibanaVersion, }); const [agent1data, agent2data] = await Promise.all([ - supertest.get(`/api/ingest_manager/fleet/agents/agent1`).set('kbn-xsrf', 'xxx'), - supertest.get(`/api/ingest_manager/fleet/agents/agent2`).set('kbn-xsrf', 'xxx'), + supertest.get(`/api/fleet/agents/agent1`).set('kbn-xsrf', 'xxx'), + supertest.get(`/api/fleet/agents/agent2`).set('kbn-xsrf', 'xxx'), ]); expect(typeof agent1data.body.item.upgrade_started_at).to.be('undefined'); expect(typeof agent2data.body.item.upgrade_started_at).to.be('string'); diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/enrollment_api_keys/crud.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/enrollment_api_keys/crud.ts index b3519e0ccc2a3..22f7c9d8572a1 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/enrollment_api_keys/crud.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/enrollment_api_keys/crud.ts @@ -33,7 +33,7 @@ export default function (providerContext: FtrProviderContext) { describe('GET /fleet/enrollment-api-keys', async () => { it('should list existing api keys', async () => { const { body: apiResponse } = await supertest - .get(`/api/ingest_manager/fleet/enrollment-api-keys`) + .get(`/api/fleet/enrollment-api-keys`) .expect(200); expect(apiResponse.total).to.be(3); @@ -44,7 +44,7 @@ export default function (providerContext: FtrProviderContext) { describe('GET /fleet/enrollment-api-keys/{id}', async () => { it('should allow to retrieve existing api keys', async () => { const { body: apiResponse } = await supertest - .get(`/api/ingest_manager/fleet/enrollment-api-keys/${ENROLLMENT_KEY_ID}`) + .get(`/api/fleet/enrollment-api-keys/${ENROLLMENT_KEY_ID}`) .expect(200); expect(apiResponse.item).to.have.keys('id', 'api_key_id', 'name'); @@ -56,7 +56,7 @@ export default function (providerContext: FtrProviderContext) { let esApiKeyId: string; before(async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/enrollment-api-keys`) + .post(`/api/fleet/enrollment-api-keys`) .set('kbn-xsrf', 'xxx') .send({ policy_id: 'policy1', @@ -68,7 +68,7 @@ export default function (providerContext: FtrProviderContext) { it('should invalide an existing api keys', async () => { await supertest - .delete(`/api/ingest_manager/fleet/enrollment-api-keys/${keyId}`) + .delete(`/api/fleet/enrollment-api-keys/${keyId}`) .set('kbn-xsrf', 'xxx') .expect(200); @@ -84,7 +84,7 @@ export default function (providerContext: FtrProviderContext) { describe('POST /fleet/enrollment-api-keys', () => { it('should not accept bad parameters', async () => { await supertest - .post(`/api/ingest_manager/fleet/enrollment-api-keys`) + .post(`/api/fleet/enrollment-api-keys`) .set('kbn-xsrf', 'xxx') .send({ raoul: 'raoul', @@ -94,7 +94,7 @@ export default function (providerContext: FtrProviderContext) { it('should not allow to create an enrollment api key for a non existing agent policy', async () => { await supertest - .post(`/api/ingest_manager/fleet/enrollment-api-keys`) + .post(`/api/fleet/enrollment-api-keys`) .set('kbn-xsrf', 'xxx') .send({ policy_id: 'idonotexistspolicy', @@ -104,7 +104,7 @@ export default function (providerContext: FtrProviderContext) { it('should allow to create an enrollment api key with an agent policy', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/enrollment-api-keys`) + .post(`/api/fleet/enrollment-api-keys`) .set('kbn-xsrf', 'xxx') .send({ policy_id: 'policy1', @@ -116,7 +116,7 @@ export default function (providerContext: FtrProviderContext) { it('should create an ES ApiKey with limited privileges', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/enrollment-api-keys`) + .post(`/api/fleet/enrollment-api-keys`) .set('kbn-xsrf', 'xxx') .send({ policy_id: 'policy1', diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/install.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/install.ts index 98758ae3ac65e..ada445edf4970 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/install.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/install.ts @@ -16,13 +16,11 @@ export default function (providerContext: FtrProviderContext) { setupIngest(providerContext); it('should return a 400 if we try download an install script for a not supported OS', async () => { - await supertest.get(`/api/ingest_manager/fleet/install/gameboy`).expect(400); + await supertest.get(`/api/fleet/install/gameboy`).expect(400); }); it('should return an install script for a supported OS', async () => { - const { text: apiResponse } = await supertest - .get(`/api/ingest_manager/fleet/install/macos`) - .expect(200); + const { text: apiResponse } = await supertest.get(`/api/fleet/install/macos`).expect(200); expect(apiResponse).match(/^#!\/bin\/sh/); }); }); diff --git a/x-pack/test/ingest_manager_api_integration/apis/fleet/setup.ts b/x-pack/test/ingest_manager_api_integration/apis/fleet/setup.ts index 64c014dc6fb3d..f6cc7be534f6f 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/fleet/setup.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/fleet/setup.ts @@ -38,7 +38,7 @@ export default function (providerContext: FtrProviderContext) { it('should create a fleet_enroll user and role', async () => { const { body: apiResponse } = await supertest - .post(`/api/ingest_manager/fleet/setup`) + .post(`/api/fleet/agents/setup`) .set('kbn-xsrf', 'xxxx') .expect(200); @@ -79,13 +79,13 @@ export default function (providerContext: FtrProviderContext) { }); it('should not create or update the fleet_enroll user if called multiple times', async () => { - await supertest.post(`/api/ingest_manager/fleet/setup`).set('kbn-xsrf', 'xxxx').expect(200); + await supertest.post(`/api/fleet/agents/setup`).set('kbn-xsrf', 'xxxx').expect(200); const { body: userResponseFirstTime } = await es.security.getUser({ username: 'fleet_enroll', }); - await supertest.post(`/api/ingest_manager/fleet/setup`).set('kbn-xsrf', 'xxxx').expect(200); + await supertest.post(`/api/fleet/agents/setup`).set('kbn-xsrf', 'xxxx').expect(200); const { body: userResponseSecondTime } = await es.security.getUser({ username: 'fleet_enroll', @@ -97,14 +97,14 @@ export default function (providerContext: FtrProviderContext) { }); it('should create or update the fleet_enroll user if called multiple times with forceRecreate flag', async () => { - await supertest.post(`/api/ingest_manager/fleet/setup`).set('kbn-xsrf', 'xxxx').expect(200); + await supertest.post(`/api/fleet/agents/setup`).set('kbn-xsrf', 'xxxx').expect(200); const { body: userResponseFirstTime } = await es.security.getUser({ username: 'fleet_enroll', }); await supertest - .post(`/api/ingest_manager/fleet/setup`) + .post(`/api/fleet/agents/setup`) .set('kbn-xsrf', 'xxxx') .send({ forceRecreate: true, diff --git a/x-pack/test/ingest_manager_api_integration/apis/package_policy/create.ts b/x-pack/test/ingest_manager_api_integration/apis/package_policy/create.ts index e5ffe62663a95..ebe42411da038 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/package_policy/create.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/package_policy/create.ts @@ -22,7 +22,7 @@ export default function ({ getService }: FtrProviderContext) { before(async function () { const { body: agentPolicyResponse } = await supertest - .post(`/api/ingest_manager/agent_policies`) + .post(`/api/fleet/agent_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'Test policy', @@ -34,7 +34,7 @@ export default function ({ getService }: FtrProviderContext) { it('should work with valid values', async function () { if (server.enabled) { await supertest - .post(`/api/ingest_manager/package_policies`) + .post(`/api/fleet/package_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'filetest-1', @@ -59,7 +59,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return a 400 with an empty namespace', async function () { if (server.enabled) { await supertest - .post(`/api/ingest_manager/package_policies`) + .post(`/api/fleet/package_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'filetest-1', @@ -84,7 +84,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return a 400 with an invalid namespace', async function () { if (server.enabled) { await supertest - .post(`/api/ingest_manager/package_policies`) + .post(`/api/fleet/package_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'filetest-1', @@ -102,7 +102,7 @@ export default function ({ getService }: FtrProviderContext) { }) .expect(400); await supertest - .post(`/api/ingest_manager/package_policies`) + .post(`/api/fleet/package_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'filetest-1', @@ -128,7 +128,7 @@ export default function ({ getService }: FtrProviderContext) { it('should not allow multiple limited packages on the same agent policy', async function () { if (server.enabled) { await supertest - .post(`/api/ingest_manager/package_policies`) + .post(`/api/fleet/package_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'endpoint-1', @@ -146,7 +146,7 @@ export default function ({ getService }: FtrProviderContext) { }) .expect(200); await supertest - .post(`/api/ingest_manager/package_policies`) + .post(`/api/fleet/package_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'endpoint-2', @@ -171,7 +171,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return a 500 if there is another package policy with the same name', async function () { if (server.enabled) { await supertest - .post(`/api/ingest_manager/package_policies`) + .post(`/api/fleet/package_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'same-name-test-1', @@ -189,7 +189,7 @@ export default function ({ getService }: FtrProviderContext) { }) .expect(200); await supertest - .post(`/api/ingest_manager/package_policies`) + .post(`/api/fleet/package_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'same-name-test-1', diff --git a/x-pack/test/ingest_manager_api_integration/apis/package_policy/get.ts b/x-pack/test/ingest_manager_api_integration/apis/package_policy/get.ts index 53a400d2fd9eb..dacc1859b33f6 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/package_policy/get.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/package_policy/get.ts @@ -27,7 +27,7 @@ export default function (providerContext: FtrProviderContext) { return; } const { body: agentPolicyResponse } = await supertest - .post(`/api/ingest_manager/agent_policies`) + .post(`/api/fleet/agent_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'Test policy', @@ -36,7 +36,7 @@ export default function (providerContext: FtrProviderContext) { agentPolicyId = agentPolicyResponse.item.id; const { body: packagePolicyResponse } = await supertest - .post(`/api/ingest_manager/package_policies`) + .post(`/api/fleet/package_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'filetest-1', @@ -61,24 +61,24 @@ export default function (providerContext: FtrProviderContext) { } await supertest - .post(`/api/ingest_manager/agent_policies/delete`) + .post(`/api/fleet/agent_policies/delete`) .set('kbn-xsrf', 'xxxx') .send({ agentPolicyId }) .expect(200); await supertest - .post(`/api/ingest_manager/package_policies/delete`) + .post(`/api/fleet/package_policies/delete`) .set('kbn-xsrf', 'xxxx') .send({ packagePolicyIds: [packagePolicyId] }) .expect(200); }); it('should succeed with a valid id', async function () { - await supertest.get(`/api/ingest_manager/package_policies/${packagePolicyId}`).expect(200); + await supertest.get(`/api/fleet/package_policies/${packagePolicyId}`).expect(200); }); it('should return a 404 with an invalid id', async function () { - await supertest.get(`/api/ingest_manager/package_policies/IS_NOT_PRESENT`).expect(404); + await supertest.get(`/api/fleet/package_policies/IS_NOT_PRESENT`).expect(404); }); }); } diff --git a/x-pack/test/ingest_manager_api_integration/apis/package_policy/update.ts b/x-pack/test/ingest_manager_api_integration/apis/package_policy/update.ts index 3c4cb93ee3ff3..c1a5d1f041ce5 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/package_policy/update.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/package_policy/update.ts @@ -28,7 +28,7 @@ export default function (providerContext: FtrProviderContext) { return; } const { body: agentPolicyResponse } = await supertest - .post(`/api/ingest_manager/agent_policies`) + .post(`/api/fleet/agent_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'Test policy', @@ -37,7 +37,7 @@ export default function (providerContext: FtrProviderContext) { agentPolicyId = agentPolicyResponse.item.id; const { body: packagePolicyResponse } = await supertest - .post(`/api/ingest_manager/package_policies`) + .post(`/api/fleet/package_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'filetest-1', @@ -56,7 +56,7 @@ export default function (providerContext: FtrProviderContext) { packagePolicyId = packagePolicyResponse.item.id; const { body: packagePolicyResponse2 } = await supertest - .post(`/api/ingest_manager/package_policies`) + .post(`/api/fleet/package_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'filetest-2', @@ -77,7 +77,7 @@ export default function (providerContext: FtrProviderContext) { it('should work with valid values', async function () { await supertest - .put(`/api/ingest_manager/package_policies/${packagePolicyId}`) + .put(`/api/fleet/package_policies/${packagePolicyId}`) .set('kbn-xsrf', 'xxxx') .send({ name: 'filetest-1', @@ -98,7 +98,7 @@ export default function (providerContext: FtrProviderContext) { it('should return a 500 if there is another package policy with the same name', async function () { await supertest - .put(`/api/ingest_manager/package_policies/${packagePolicyId2}`) + .put(`/api/fleet/package_policies/${packagePolicyId2}`) .set('kbn-xsrf', 'xxxx') .send({ name: 'filetest-1', diff --git a/x-pack/test/ingest_manager_api_integration/apis/settings/update.ts b/x-pack/test/ingest_manager_api_integration/apis/settings/update.ts index 4340cd4832307..0156e90b677d1 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/settings/update.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/settings/update.ts @@ -22,7 +22,7 @@ export default function (providerContext: FtrProviderContext) { it("should bump all agent policy's revision", async function () { const { body: testPolicy1PostRes } = await supertest - .post(`/api/ingest_manager/agent_policies`) + .post(`/api/fleet/agent_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'test', @@ -30,7 +30,7 @@ export default function (providerContext: FtrProviderContext) { namespace: 'default', }); const { body: testPolicy2PostRes } = await supertest - .post(`/api/ingest_manager/agent_policies`) + .post(`/api/fleet/agent_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'test2', @@ -38,7 +38,7 @@ export default function (providerContext: FtrProviderContext) { namespace: 'default', }); await supertest - .put(`/api/ingest_manager/settings`) + .put(`/api/fleet/settings`) .set('kbn-xsrf', 'xxxx') .send({ kibana_urls: ['http://localhost:1232/abc', 'http://localhost:1232/abc'] }); @@ -56,7 +56,7 @@ export default function (providerContext: FtrProviderContext) { it('should create agent actions', async function () { const { body: testPolicyRes } = await supertest - .post(`/api/ingest_manager/agent_policies`) + .post(`/api/fleet/agent_policies`) .set('kbn-xsrf', 'xxxx') .send({ name: 'test', @@ -65,7 +65,7 @@ export default function (providerContext: FtrProviderContext) { }); await supertest - .put(`/api/ingest_manager/settings`) + .put(`/api/fleet/settings`) .set('kbn-xsrf', 'xxxx') .send({ kibana_urls: ['http://localhost:1232/abc', 'http://localhost:1232/abc'] }); diff --git a/x-pack/test/ingest_manager_api_integration/apis/setup.ts b/x-pack/test/ingest_manager_api_integration/apis/setup.ts index daf0c8937715f..c496813d86223 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/setup.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/setup.ts @@ -13,7 +13,7 @@ export default function (providerContext: FtrProviderContext) { const es = getService('es'); describe('ingest manager setup', async () => { before(async () => { - await supertest.post(`/api/ingest_manager/setup`).set('kbn-xsrf', 'xxx').send(); + await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send(); }); it('should have installed placeholder indices', async function () { diff --git a/x-pack/test/security_solution_endpoint/services/endpoint_policy.ts b/x-pack/test/security_solution_endpoint/services/endpoint_policy.ts index 349aa0bc3a9ea..7fc51f5c8e39c 100644 --- a/x-pack/test/security_solution_endpoint/services/endpoint_policy.ts +++ b/x-pack/test/security_solution_endpoint/services/endpoint_policy.ts @@ -19,7 +19,7 @@ import { import { factory as policyConfigFactory } from '../../../plugins/security_solution/common/endpoint/models/policy_config'; import { Immutable } from '../../../plugins/security_solution/common/endpoint/types'; -const INGEST_API_ROOT = '/api/ingest_manager'; +const INGEST_API_ROOT = '/api/fleet'; const INGEST_API_AGENT_POLICIES = `${INGEST_API_ROOT}/agent_policies`; const INGEST_API_AGENT_POLICIES_DELETE = `${INGEST_API_AGENT_POLICIES}/delete`; const INGEST_API_PACKAGE_POLICIES = `${INGEST_API_ROOT}/package_policies`; diff --git a/x-pack/test/security_solution_endpoint_api_int/apis/artifacts/index.ts b/x-pack/test/security_solution_endpoint_api_int/apis/artifacts/index.ts index 17a4182fe9371..9ce4b3a149dd2 100644 --- a/x-pack/test/security_solution_endpoint_api_int/apis/artifacts/index.ts +++ b/x-pack/test/security_solution_endpoint_api_int/apis/artifacts/index.ts @@ -23,21 +23,19 @@ export default function (providerContext: FtrProviderContext) { await esArchiver.load('endpoint/artifacts/api_feature', { useCreate: true }); const { body: enrollmentApiKeysResponse } = await supertest - .get(`/api/ingest_manager/fleet/enrollment-api-keys`) + .get(`/api/fleet/enrollment-api-keys`) .expect(200); expect(enrollmentApiKeysResponse.list).length(2); const { body: enrollmentApiKeyResponse } = await supertest - .get( - `/api/ingest_manager/fleet/enrollment-api-keys/${enrollmentApiKeysResponse.list[0].id}` - ) + .get(`/api/fleet/enrollment-api-keys/${enrollmentApiKeysResponse.list[0].id}`) .expect(200); expect(enrollmentApiKeyResponse.item).to.have.key('api_key'); const enrollmentAPIToken = enrollmentApiKeyResponse.item.api_key; // 2. Enroll agent const { body: enrollmentResponse } = await supertestWithoutAuth - .post(`/api/ingest_manager/fleet/agents/enroll`) + .post(`/api/fleet/agents/enroll`) .set('kbn-xsrf', 'xxx') .set('Authorization', `ApiKey ${enrollmentAPIToken}`) .send({