Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class AgentConfigService {
throw new Error('Agent configuration not found');
}

const defaultConfigId = await this.getDefaultAgentConfigId(soClient);
const { id: defaultConfigId } = await this.ensureDefaultAgentConfig(soClient);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it's the perfect solution, as it's going to eventually create the default config outside of the setup (not sure of the side effect of this)

What do you think of catching 404 of the previous call?

something like

try {
  const defaultConfigId = await this.getDefaultAgentConfigId(soClient);

  if (id === defaultConfigId) {
      throw new Error('The default agent configuration cannot be deleted');	      throw new Error('The default agent configuration cannot be deleted');
    }	    }
} catch (err) {
  // implement real test here :) 
  if (err !== 404) { throw err; }
}

if (id === defaultConfigId) {
throw new Error('The default agent configuration cannot be deleted');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ export default function ({ getService }: FtrProviderContext) {
});
});

describe('POST /api/ingest_manager/agent_configs/delete', () => {
it('should delete a config', async () => {
const { body: apiResponse } = await supertest
.post(`/api/ingest_manager/agent_configs`)
.set('kbn-xsrf', 'xxxx')
.send({
name: 'asdfasf',
namespace: 'asfdasdfasdf',
})
.expect(200);

await supertest
.post(`/api/ingest_manager/agent_configs/delete`)
.set('kbn-xsrf', 'xxxx')
.send({ agentConfigId: apiResponse.item.id })
.expect(200);
});
});
describe('POST /api/ingest_manager/agent_configs/{agentConfigId}/copy', () => {
before(async () => {
await esArchiver.loadIfNeeded('fleet/agents');
Expand Down