Skip to content

Commit

Permalink
[Fleet] Fix invalid permission entry if the elastic agent package is …
Browse files Browse the repository at this point in the history
…not installed (elastic#125447) (elastic#125529)

(cherry picked from commit d383bda)

Co-authored-by: Nicolas Chaulet <[email protected]>
  • Loading branch information
kibanamachine and nchaulet authored Feb 14, 2022
1 parent c975b6d commit 3434852
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ describe('getMonitoringPermissions', () => {
);
expect(permissions).toMatchSnapshot();
});

it('should an empty valid permission entry if neither metrics and logs are enabled', async () => {
const permissions = await getMonitoringPermissions(
savedObjectsClientMock.create(),
{ logs: false, metrics: false },
'testnamespace123'
);
expect(permissions).toEqual({ _elastic_agent_monitoring: { indices: [] } });
});
});

describe('With elastic agent package installed', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ function buildDefault(enabled: { logs: boolean; metrics: boolean }, namespace: s
);
}

if (names.length === 0) {
return {
_elastic_agent_monitoring: {
indices: [],
},
};
}

return {
_elastic_agent_monitoring: {
indices: [
Expand Down

0 comments on commit 3434852

Please sign in to comment.