-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ingest Manager] API sends 404 when package config id is missing (#73212
) (#73659) * Add test to confirm missing config responds w/ 404 Currently failing with a 500 as in #66388 * Use after() to remove items added by test. The test initally failed with a 500 when the `after` was added. Debugging narrowed it down to a missing default config. getDefaultAgentConfigId errors if there isn't a default config. The config is added by `setupIngestManager` which _was_ always called during plugin#start but is no longer. We could add the setup call to the test/suite, but instead I changed AgentConfigService.delete to use ensureDefaultAgentConfig instead of getDefaultAgentConfigId. ensureDefaultAgentConfig adds one if it's missing. The check in delete is to make sure we don't delete the default config. We can still do that and now we add a config if it wasn't already there (which seems like A Good Thing) * Fix package config path in OpenApi spec * Return 404 if package config id is invalid/missing * Change test for error displayed text Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
d9dfd96
commit 8cd00dd
Showing
6 changed files
with
108 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
x-pack/test/ingest_manager_api_integration/apis/package_config/get.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; | ||
import { skipIfNoDockerRegistry } from '../../helpers'; | ||
|
||
export default function (providerContext: FtrProviderContext) { | ||
const { getService } = providerContext; | ||
const supertest = getService('supertest'); | ||
const dockerServers = getService('dockerServers'); | ||
|
||
const server = dockerServers.get('registry'); | ||
// use function () {} and not () => {} here | ||
// because `this` has to point to the Mocha context | ||
// see https://mochajs.org/#arrow-functions | ||
|
||
describe('Package Config - get by id', async function () { | ||
skipIfNoDockerRegistry(providerContext); | ||
let agentConfigId: string; | ||
let packageConfigId: string; | ||
|
||
before(async function () { | ||
if (!server.enabled) { | ||
return; | ||
} | ||
const { body: agentConfigResponse } = await supertest | ||
.post(`/api/ingest_manager/agent_configs`) | ||
.set('kbn-xsrf', 'xxxx') | ||
.send({ | ||
name: 'Test config', | ||
namespace: 'default', | ||
}); | ||
agentConfigId = agentConfigResponse.item.id; | ||
|
||
const { body: packageConfigResponse } = await supertest | ||
.post(`/api/ingest_manager/package_configs`) | ||
.set('kbn-xsrf', 'xxxx') | ||
.send({ | ||
name: 'filetest-1', | ||
description: '', | ||
namespace: 'default', | ||
config_id: agentConfigId, | ||
enabled: true, | ||
output_id: '', | ||
inputs: [], | ||
package: { | ||
name: 'filetest', | ||
title: 'For File Tests', | ||
version: '0.1.0', | ||
}, | ||
}); | ||
packageConfigId = packageConfigResponse.item.id; | ||
}); | ||
|
||
after(async function () { | ||
if (!server.enabled) { | ||
return; | ||
} | ||
|
||
await supertest | ||
.post(`/api/ingest_manager/agent_configs/delete`) | ||
.set('kbn-xsrf', 'xxxx') | ||
.send({ agentConfigId }) | ||
.expect(200); | ||
|
||
await supertest | ||
.post(`/api/ingest_manager/package_configs/delete`) | ||
.set('kbn-xsrf', 'xxxx') | ||
.send({ packageConfigIds: [packageConfigId] }) | ||
.expect(200); | ||
}); | ||
|
||
it('should succeed with a valid id', async function () { | ||
const { body: apiResponse } = await supertest | ||
.get(`/api/ingest_manager/package_configs/${packageConfigId}`) | ||
.expect(200); | ||
|
||
expect(apiResponse.success).to.be(true); | ||
}); | ||
|
||
it('should return a 404 with an invalid id', async function () { | ||
await supertest.get(`/api/ingest_manager/package_configs/IS_NOT_PRESENT`).expect(404); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters