Skip to content

Commit

Permalink
[ENDPOINT] Added unerolling status for host. (#72303) (#72465)
Browse files Browse the repository at this point in the history
* Added unerolling status for host.

* Added unenrolling status to frontend tests.
  • Loading branch information
efreeti authored Jul 20, 2020
1 parent 722fb29 commit 340c51a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
5 changes: 5 additions & 0 deletions x-pack/plugins/security_solution/common/endpoint/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,11 @@ export enum HostStatus {
* Host is offline as indicated by its checkin status during the last checkin window
*/
OFFLINE = 'offline',

/**
* Host is unenrolling as indicated by its checkin status during the last checkin window
*/
UNENROLLING = 'unenrolling',
}

export type HostInfo = Immutable<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const HOST_STATUS_TO_HEALTH_COLOR = Object.freeze<
[HostStatus.ERROR]: 'danger',
[HostStatus.ONLINE]: 'success',
[HostStatus.OFFLINE]: 'subdued',
[HostStatus.UNENROLLING]: 'warning',
});

export const POLICY_STATUS_TO_HEALTH_COLOR = Object.freeze<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,16 @@ describe('when on the hosts page', () => {
let firstPolicyID: string;
beforeEach(() => {
reactTestingLibrary.act(() => {
const hostListData = mockHostResultList({ total: 3 });
const hostListData = mockHostResultList({ total: 4 });
firstPolicyID = hostListData.hosts[0].metadata.Endpoint.policy.applied.id;
[HostStatus.ERROR, HostStatus.ONLINE, HostStatus.OFFLINE].forEach((status, index) => {
hostListData.hosts[index] = {
metadata: hostListData.hosts[index].metadata,
host_status: status,
};
});
[HostStatus.ERROR, HostStatus.ONLINE, HostStatus.OFFLINE, HostStatus.UNENROLLING].forEach(
(status, index) => {
hostListData.hosts[index] = {
metadata: hostListData.hosts[index].metadata,
host_status: status,
};
}
);
hostListData.hosts.forEach((item, index) => {
generatedPolicyStatuses[index] = item.metadata.Endpoint.policy.applied.status;
});
Expand All @@ -134,12 +136,12 @@ describe('when on the hosts page', () => {
it('should display rows in the table', async () => {
const renderResult = render();
const rows = await renderResult.findAllByRole('row');
expect(rows).toHaveLength(4);
expect(rows).toHaveLength(5);
});
it('should show total', async () => {
const renderResult = render();
const total = await renderResult.findByTestId('hostListTableTotal');
expect(total.textContent).toEqual('3 Hosts');
expect(total.textContent).toEqual('4 Hosts');
});
it('should display correct status', async () => {
const renderResult = render();
Expand All @@ -157,6 +159,11 @@ describe('when on the hosts page', () => {
expect(
hostStatuses[2].querySelector('[data-euiicon-type][color="subdued"]')
).not.toBeNull();

expect(hostStatuses[3].textContent).toEqual('Unenrolling');
expect(
hostStatuses[3].querySelector('[data-euiicon-type][color="warning"]')
).not.toBeNull();
});

it('should display correct policy status', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export const HostList = () => {
>
<FormattedMessage
id="xpack.securitySolution.endpointList.hostStatusValue"
defaultMessage="{hostStatus, select, online {Online} error {Error} other {Offline}}"
defaultMessage="{hostStatus, select, online {Online} error {Error} unenrolling {Unenrolling} other {Offline}}"
values={{ hostStatus }}
/>
</EuiHealth>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface MetadataRequestContext {
const HOST_STATUS_MAPPING = new Map<AgentStatus, HostStatus>([
['online', HostStatus.ONLINE],
['offline', HostStatus.OFFLINE],
['unenrolling', HostStatus.UNENROLLING],
]);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ describe('test endpoint route', () => {
expect(result.host_status).toEqual(HostStatus.ERROR);
});

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

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

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

const mockRequest = httpServerMock.createKibanaRequest({
Expand Down

0 comments on commit 340c51a

Please sign in to comment.