[ENDPOINT] Added unerolling status for host. (#72303)
* Added unerolling status for host. * Added unenrolling status to frontend tests.
This commit is contained in:
parent
54c3644757
commit
d744d18b19
|
@ -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<{
|
||||
|
|
|
@ -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<
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
@ -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();
|
||||
|
@ -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 () => {
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -35,6 +35,7 @@ interface MetadataRequestContext {
|
|||
const HOST_STATUS_MAPPING = new Map<AgentStatus, HostStatus>([
|
||||
['online', HostStatus.ONLINE],
|
||||
['offline', HostStatus.OFFLINE],
|
||||
['unenrolling', HostStatus.UNENROLLING],
|
||||
]);
|
||||
|
||||
/**
|
||||
|
|
|
@ -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({
|
||||
|
@ -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({
|
||||
|
|
Loading…
Reference in a new issue