Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENDPOINT] Added unerolling status for host. #72303

Merged
merged 3 commits into from
Jul 20, 2020
Merged
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
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}}"
efreeti marked this conversation as resolved.
Show resolved Hide resolved
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());
efreeti marked this conversation as resolved.
Show resolved Hide resolved

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