Skip to content

Commit b310f92

Browse files
committed
EMT-451: some more clean up
1 parent 866b3e2 commit b310f92

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,6 @@ const noUnenrolledEndpoint = () =>
2525

2626
describe('test find all unenrolled HostId', () => {
2727
let mockScopedClient: jest.Mocked<IScopedClusterClient>;
28-
const expectedAllUnenrolledHostQuery = {
29-
index: metadataMirrorIndexPattern,
30-
scroll: '10s',
31-
body: {
32-
size: 1000,
33-
_source: ['host.id'],
34-
query: {
35-
bool: {
36-
filter: {
37-
term: {
38-
'Endpoint.status': EndpointStatus.unenrolled,
39-
},
40-
},
41-
},
42-
},
43-
},
44-
};
4528

4629
it('can find all hits with scroll', async () => {
4730
const firstHostId = '1fdca33f-799f-49f4-939c-ea4383c77671';
@@ -74,9 +57,23 @@ describe('test find all unenrolled HostId', () => {
7457
.mockImplementationOnce(noUnenrolledEndpoint);
7558
const hostIds = await findAllUnenrolledHostIds(mockScopedClient);
7659

77-
expect(mockScopedClient.callAsCurrentUser.mock.calls[0][1]).toEqual(
78-
expectedAllUnenrolledHostQuery
79-
);
60+
expect(mockScopedClient.callAsCurrentUser.mock.calls[0][1]).toEqual({
61+
index: metadataMirrorIndexPattern,
62+
scroll: '30s',
63+
body: {
64+
size: 1000,
65+
_source: ['host.id'],
66+
query: {
67+
bool: {
68+
filter: {
69+
term: {
70+
'Endpoint.status': EndpointStatus.unenrolled,
71+
},
72+
},
73+
},
74+
},
75+
},
76+
});
8077
expect(hostIds).toEqual([
8178
{ host: { id: firstEndpointHostId } },
8279
{ host: { id: secondEndpointHostId } },
@@ -94,6 +91,9 @@ describe('test find unenrolled endpoint host id by hostId', () => {
9491
Promise.resolve(createSearchResponse(firstEndpointHostId, 'initialScrollId'))
9592
);
9693
const endpointHostId = await findUnenrolledHostByHostId(mockScopedClient, firstEndpointHostId);
94+
expect(mockScopedClient.callAsCurrentUser.mock.calls[0][1]?.index).toEqual(
95+
metadataMirrorIndexPattern
96+
);
9797
expect(mockScopedClient.callAsCurrentUser.mock.calls[0][1]?.body).toEqual({
9898
size: 1,
9999
_source: ['host.id'],

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { SearchResponse } from 'elasticsearch';
99
import { metadataMirrorIndexPattern } from '../../../../../common/endpoint/constants';
1010
import { EndpointStatus } from '../../../../../common/endpoint/types';
1111

12-
const KEEPALIVE = '10s';
12+
const KEEPALIVE = '30s';
1313
const SIZE = 1000;
1414

1515
export interface HostId {

0 commit comments

Comments
 (0)