Skip to content

Commit 340c51a

Browse files
authored
[ENDPOINT] Added unerolling status for host. (#72303) (#72465)
* Added unerolling status for host. * Added unenrolling status to frontend tests.
1 parent 722fb29 commit 340c51a

File tree

6 files changed

+26
-12
lines changed

6 files changed

+26
-12
lines changed

x-pack/plugins/security_solution/common/endpoint/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@ export enum HostStatus {
419419
* Host is offline as indicated by its checkin status during the last checkin window
420420
*/
421421
OFFLINE = 'offline',
422+
423+
/**
424+
* Host is unenrolling as indicated by its checkin status during the last checkin window
425+
*/
426+
UNENROLLING = 'unenrolling',
422427
}
423428

424429
export type HostInfo = Immutable<{

x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/host_constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const HOST_STATUS_TO_HEALTH_COLOR = Object.freeze<
1515
[HostStatus.ERROR]: 'danger',
1616
[HostStatus.ONLINE]: 'success',
1717
[HostStatus.OFFLINE]: 'subdued',
18+
[HostStatus.UNENROLLING]: 'warning',
1819
});
1920

2021
export const POLICY_STATUS_TO_HEALTH_COLOR = Object.freeze<

x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.test.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,16 @@ describe('when on the hosts page', () => {
112112
let firstPolicyID: string;
113113
beforeEach(() => {
114114
reactTestingLibrary.act(() => {
115-
const hostListData = mockHostResultList({ total: 3 });
115+
const hostListData = mockHostResultList({ total: 4 });
116116
firstPolicyID = hostListData.hosts[0].metadata.Endpoint.policy.applied.id;
117-
[HostStatus.ERROR, HostStatus.ONLINE, HostStatus.OFFLINE].forEach((status, index) => {
118-
hostListData.hosts[index] = {
119-
metadata: hostListData.hosts[index].metadata,
120-
host_status: status,
121-
};
122-
});
117+
[HostStatus.ERROR, HostStatus.ONLINE, HostStatus.OFFLINE, HostStatus.UNENROLLING].forEach(
118+
(status, index) => {
119+
hostListData.hosts[index] = {
120+
metadata: hostListData.hosts[index].metadata,
121+
host_status: status,
122+
};
123+
}
124+
);
123125
hostListData.hosts.forEach((item, index) => {
124126
generatedPolicyStatuses[index] = item.metadata.Endpoint.policy.applied.status;
125127
});
@@ -134,12 +136,12 @@ describe('when on the hosts page', () => {
134136
it('should display rows in the table', async () => {
135137
const renderResult = render();
136138
const rows = await renderResult.findAllByRole('row');
137-
expect(rows).toHaveLength(4);
139+
expect(rows).toHaveLength(5);
138140
});
139141
it('should show total', async () => {
140142
const renderResult = render();
141143
const total = await renderResult.findByTestId('hostListTableTotal');
142-
expect(total.textContent).toEqual('3 Hosts');
144+
expect(total.textContent).toEqual('4 Hosts');
143145
});
144146
it('should display correct status', async () => {
145147
const renderResult = render();
@@ -157,6 +159,11 @@ describe('when on the hosts page', () => {
157159
expect(
158160
hostStatuses[2].querySelector('[data-euiicon-type][color="subdued"]')
159161
).not.toBeNull();
162+
163+
expect(hostStatuses[3].textContent).toEqual('Unenrolling');
164+
expect(
165+
hostStatuses[3].querySelector('[data-euiicon-type][color="warning"]')
166+
).not.toBeNull();
160167
});
161168

162169
it('should display correct policy status', async () => {

x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export const HostList = () => {
226226
>
227227
<FormattedMessage
228228
id="xpack.securitySolution.endpointList.hostStatusValue"
229-
defaultMessage="{hostStatus, select, online {Online} error {Error} other {Offline}}"
229+
defaultMessage="{hostStatus, select, online {Online} error {Error} unenrolling {Unenrolling} other {Offline}}"
230230
values={{ hostStatus }}
231231
/>
232232
</EuiHealth>

x-pack/plugins/security_solution/server/endpoint/routes/metadata/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ interface MetadataRequestContext {
3535
const HOST_STATUS_MAPPING = new Map<AgentStatus, HostStatus>([
3636
['online', HostStatus.ONLINE],
3737
['offline', HostStatus.OFFLINE],
38+
['unenrolling', HostStatus.UNENROLLING],
3839
]);
3940

4041
/**

x-pack/plugins/security_solution/server/endpoint/routes/metadata/metadata.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ describe('test endpoint route', () => {
335335
expect(result.host_status).toEqual(HostStatus.ERROR);
336336
});
337337

338-
it('should return a single endpoint with status error when status is not offline or online', async () => {
338+
it('should return a single endpoint with status error when status is not offline, online or enrolling', async () => {
339339
const response = createSearchResponse(new EndpointDocGenerator().generateHostMetadata());
340340

341341
const mockRequest = httpServerMock.createKibanaRequest({
@@ -368,7 +368,7 @@ describe('test endpoint route', () => {
368368
expect(result.host_status).toEqual(HostStatus.ERROR);
369369
});
370370

371-
it('should throw error when endpoint egent is not active', async () => {
371+
it('should throw error when endpoint agent is not active', async () => {
372372
const response = createSearchResponse(new EndpointDocGenerator().generateHostMetadata());
373373

374374
const mockRequest = httpServerMock.createKibanaRequest({

0 commit comments

Comments
 (0)