-
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.
prevent delete flag to update from UI when preconfigured
- Loading branch information
1 parent
6fe1fc2
commit 147c2d4
Showing
13 changed files
with
303 additions
and
35 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
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
71 changes: 71 additions & 0 deletions
71
...ck/plugins/fleet/server/services/preconfiguration/delete_unenrolled_agent_setting.test.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,71 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { settingsService } from '..'; | ||
|
||
import { ensureDeleteUnenrolledAgentsSetting } from './delete_unenrolled_agent_setting'; | ||
|
||
jest.mock('..', () => ({ | ||
settingsService: { | ||
getSettingsOrUndefined: jest.fn(), | ||
saveSettings: jest.fn(), | ||
}, | ||
})); | ||
|
||
describe('delete_unenrolled_agent_setting', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should update settings with delete_unenrolled_agents enabled', async () => { | ||
await ensureDeleteUnenrolledAgentsSetting({} as any, true); | ||
|
||
expect(settingsService.saveSettings).toHaveBeenCalledWith( | ||
expect.anything(), | ||
{ delete_unenrolled_agents: { enabled: true, is_preconfigured: true } }, | ||
{ fromSetup: true } | ||
); | ||
}); | ||
|
||
it('should update settings with delete_unenrolled_agents disabled', async () => { | ||
await ensureDeleteUnenrolledAgentsSetting({} as any, false); | ||
|
||
expect(settingsService.saveSettings).toHaveBeenCalledWith( | ||
expect.anything(), | ||
{ delete_unenrolled_agents: { enabled: false, is_preconfigured: true } }, | ||
{ fromSetup: true } | ||
); | ||
}); | ||
|
||
it('should update settings when previously preconfigured', async () => { | ||
(settingsService.getSettingsOrUndefined as jest.Mock).mockResolvedValue({ | ||
delete_unenrolled_agents: { | ||
enabled: false, | ||
is_preconfigured: true, | ||
}, | ||
}); | ||
await ensureDeleteUnenrolledAgentsSetting({} as any); | ||
|
||
expect(settingsService.saveSettings).toHaveBeenCalledWith( | ||
expect.anything(), | ||
{ delete_unenrolled_agents: { enabled: false, is_preconfigured: false } }, | ||
{ fromSetup: true } | ||
); | ||
}); | ||
|
||
it('should not update settings when previously not preconfigured', async () => { | ||
(settingsService.getSettingsOrUndefined as jest.Mock).mockResolvedValue({ | ||
delete_unenrolled_agents: { | ||
enabled: false, | ||
is_preconfigured: false, | ||
}, | ||
}); | ||
await ensureDeleteUnenrolledAgentsSetting({} as any); | ||
|
||
expect(settingsService.saveSettings).not.toHaveBeenCalled(); | ||
}); | ||
}); |
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
Oops, something went wrong.