Skip to content

Commit

Permalink
Enable conditional routes. Adjust integration tests
Browse files Browse the repository at this point in the history
EPM routes currently return a 500 for these tests. For now they `.expect(500)` when enabled and `.expect(404)` when disabled. We can look into the issue and get them to `.expect(200)` in later tests.
  • Loading branch information
John Schulz committed Feb 21, 2020
1 parent aa10fee commit 1f27d34
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ describe('ingestManager', () => {
});

it('does not have EPM api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/epm').expect(404);
await kbnTestServer.request.get(root, '/api/ingest_manager/epm/list').expect(404);
});

it('does not have Fleet api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/fleet').expect(404);
await kbnTestServer.request.get(root, '/api/ingest_manager/fleet/setup').expect(404);
});
});

Expand Down Expand Up @@ -82,11 +82,6 @@ describe('ingestManager', () => {
});
});

// For now, only the manager routes (/agent_configs & /datasources) are added
// EPM and ingest will be conditionally added when we enable these lines
// https://github.com/jfsiii/kibana/blob/f73b54ebb7e0f6fc00efd8a6800a01eb2d9fb772/x-pack/plugins/ingest_manager/server/plugin.ts#L84
// adding tests to confirm the Fleet & EPM routes are never added

describe('manager and EPM; no Fleet', () => {
let root: ReturnType<typeof kbnTestServer.createRoot>;
beforeAll(async () => {
Expand All @@ -111,8 +106,8 @@ describe('ingestManager', () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/datasources').expect(200);
});

it('does not have EPM api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/epm/list').expect(404);
it('does have EPM api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/epm/list').expect(500);
});

it('does not have Fleet api', async () => {
Expand All @@ -125,7 +120,6 @@ describe('ingestManager', () => {
beforeAll(async () => {
const ingestManagerConfig = {
enabled: true,
epm: { enabled: true },
fleet: { enabled: true },
};
root = createXPackRoot({
Expand All @@ -149,8 +143,8 @@ describe('ingestManager', () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/epm/list').expect(404);
});

it('does not have Fleet api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/fleet/setup').expect(404);
it('does have Fleet api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/fleet/setup').expect(200);
});
});

Expand Down Expand Up @@ -179,12 +173,12 @@ describe('ingestManager', () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/datasources').expect(200);
});

it('does not have EPM api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/epm/list').expect(404);
it('does have EPM api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/epm/list').expect(500);
});

it('does not have Fleet api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/fleet/setup').expect(404);
it('does have Fleet api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/fleet/setup').expect(200);
});
});
});
23 changes: 14 additions & 9 deletions x-pack/plugins/ingest_manager/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,22 @@ export class IngestManagerPlugin implements Plugin {
// Register routes
registerAgentConfigRoutes(router);
registerDatasourceRoutes(router);
registerAgentRoutes(router);
registerEnrollmentApiKeyRoutes(router);
registerInstallScriptRoutes({
router,
serverInfo: core.http.getServerInfo(),
basePath: core.http.basePath,
});

// Conditional routes
if (config.epm.enabled) registerEPMRoutes(router);
if (config.fleet.enabled) registerFleetSetupRoutes(router);
if (config.epm.enabled) {
registerEPMRoutes(router);
}

if (config.fleet.enabled) {
registerFleetSetupRoutes(router);
registerAgentRoutes(router);
registerEnrollmentApiKeyRoutes(router);
registerInstallScriptRoutes({
router,
serverInfo: core.http.getServerInfo(),
basePath: core.http.basePath,
});
}
}

public async start(
Expand Down

0 comments on commit 1f27d34

Please sign in to comment.