Skip to content

Commit

Permalink
[Fleet] remove deprecated API endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Nov 4, 2024
1 parent 867b05e commit 64e54de
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 100 deletions.
5 changes: 0 additions & 5 deletions x-pack/plugins/fleet/common/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,6 @@ export const ENROLLMENT_API_KEY_ROUTES = {
LIST_PATTERN: `${API_ROOT}/enrollment_api_keys`,
INFO_PATTERN: `${API_ROOT}/enrollment_api_keys/{keyId}`,
DELETE_PATTERN: `${API_ROOT}/enrollment_api_keys/{keyId}`,
// deprecated since 8.0
CREATE_PATTERN_DEPRECATED: `${API_ROOT}/enrollment-api-keys`,
LIST_PATTERN_DEPRECATED: `${API_ROOT}/enrollment-api-keys`,
INFO_PATTERN_DEPRECATED: `${API_ROOT}/enrollment-api-keys/{keyId}`,
DELETE_PATTERN_DEPRECATED: `${API_ROOT}/enrollment-api-keys/{keyId}`,
};

export const UNINSTALL_TOKEN_ROUTES = {
Expand Down
68 changes: 0 additions & 68 deletions x-pack/plugins/fleet/server/routes/enrollment_api_key/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,72 +154,4 @@ export const registerRoutes = (router: FleetAuthzRouter) => {
},
postEnrollmentApiKeyHandler
);

router.versioned
.get({
path: ENROLLMENT_API_KEY_ROUTES.INFO_PATTERN_DEPRECATED,
fleetAuthz: {
fleet: { readEnrollmentTokens: true },
},
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
deprecated: true,
})
.addVersion(
{
version: API_VERSIONS.public.v1,
validate: { request: GetOneEnrollmentAPIKeyRequestSchema },
},
getOneEnrollmentApiKeyHandler
);

router.versioned
.delete({
path: ENROLLMENT_API_KEY_ROUTES.DELETE_PATTERN_DEPRECATED,
fleetAuthz: {
fleet: { allAgents: true },
},
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
deprecated: true,
})
.addVersion(
{
version: API_VERSIONS.public.v1,
validate: { request: DeleteEnrollmentAPIKeyRequestSchema },
},
deleteEnrollmentApiKeyHandler
);

router.versioned
.get({
path: ENROLLMENT_API_KEY_ROUTES.LIST_PATTERN_DEPRECATED,
fleetAuthz: {
fleet: { readEnrollmentTokens: true },
},
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
deprecated: true,
})
.addVersion(
{
version: API_VERSIONS.public.v1,
validate: { request: GetEnrollmentAPIKeysRequestSchema },
},
getEnrollmentApiKeysHandler
);

router.versioned
.post({
path: ENROLLMENT_API_KEY_ROUTES.CREATE_PATTERN_DEPRECATED,
fleetAuthz: {
fleet: { allAgents: true },
},
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
deprecated: true,
})
.addVersion(
{
version: API_VERSIONS.public.v1,
validate: { request: PostEnrollmentAPIKeyRequestSchema },
},
postEnrollmentApiKeyHandler
);
};
27 changes: 0 additions & 27 deletions x-pack/test/fleet_api_integration/apis/enrollment_api_keys/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,32 +285,5 @@ export default function (providerContext: FtrProviderContext) {
});
});
});

describe('deprecated API', () => {
let keyId: string;
before(async () => {
const { body: apiResponse } = await supertest
.post(`/api/fleet/enrollment-api-keys`)
.set('kbn-xsrf', 'xxx')
.send({
policy_id: 'policy1',
})
.expect(200);
keyId = apiResponse.item.id;
});

it('should get and delete with deprecated API', async () => {
await supertest.get(`/api/fleet/enrollment-api-keys`).set('kbn-xsrf', 'xxx').expect(200);
await supertest
.get(`/api/fleet/enrollment-api-keys/${ENROLLMENT_KEY_ID}`)
.set('kbn-xsrf', 'xxx')
.expect(200);

await supertest
.delete(`/api/fleet/enrollment-api-keys/${keyId}`)
.set('kbn-xsrf', 'xxx')
.expect(200);
});
});
});
}

0 comments on commit 64e54de

Please sign in to comment.