Skip to content

Commit

Permalink
Add tests to cover all permutations of flags (A, AB, AC, ABC)
Browse files Browse the repository at this point in the history
  • Loading branch information
John Schulz committed Feb 13, 2020
1 parent 27defb2 commit 3fb86a1
Showing 1 changed file with 109 additions and 5 deletions.
114 changes: 109 additions & 5 deletions x-pack/plugins/ingest_manager/server/integration_tests/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('ingestManager', () => {

afterAll(async () => await root.shutdown());

it('does not have agent config API', async () => {
it('does not have agent config api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/agent_configs').expect(404);
});

Expand All @@ -50,7 +50,77 @@ describe('ingestManager', () => {
});
});

describe('manager enabled (no EPM, no Fleet)', () => {
describe('manager only (no EPM, no Fleet)', () => {
let root: ReturnType<typeof kbnTestServer.createRoot>;
beforeAll(async () => {
const ingestManagerConfig = {
enabled: true,
};
root = createXPackRoot({
ingestManager: ingestManagerConfig,
});
await root.setup();
await root.start();
}, 30000);

afterAll(async () => await root.shutdown());

it('has agent config api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/agent_configs').expect(200);
});

it('has datasources api', async () => {
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 not have Fleet api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/fleet/setup').expect(404);
});
});

// 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 () => {
const ingestManagerConfig = {
enabled: true,
epm: { enabled: true },
};
root = createXPackRoot({
ingestManager: ingestManagerConfig,
});
await root.setup();
await root.start();
}, 30000);

afterAll(async () => await root.shutdown());

it('has agent config api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/agent_configs').expect(200);
});

it('has datasources api', async () => {
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 not have Fleet api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/fleet/setup').expect(404);
});
});

describe('manager and Fleet; no EPM)', () => {
let root: ReturnType<typeof kbnTestServer.createRoot>;
beforeAll(async () => {
const ingestManagerConfig = {
Expand All @@ -67,7 +137,7 @@ describe('ingestManager', () => {

afterAll(async () => await root.shutdown());

it('has agent config API', async () => {
it('has agent config api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/agent_configs').expect(200);
});

Expand All @@ -76,11 +146,45 @@ 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);
});
});

describe('all flags enabled: manager, EPM, and Fleet)', () => {
let root: ReturnType<typeof kbnTestServer.createRoot>;
beforeAll(async () => {
const ingestManagerConfig = {
enabled: true,
epm: { enabled: true },
fleet: { enabled: true },
};
root = createXPackRoot({
ingestManager: ingestManagerConfig,
});
await root.setup();
await root.start();
}, 30000);

afterAll(async () => await root.shutdown());

it('has agent config api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/agent_configs').expect(200);
});

it('has datasources api', async () => {
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 not have Fleet api', async () => {
await kbnTestServer.request.get(root, '/api/ingest_manager/fleet/setup').expect(404);
});
});
});

0 comments on commit 3fb86a1

Please sign in to comment.