Skip to content

Commit

Permalink
upadte
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Nov 2, 2020
1 parent 659f57a commit 0d23236
Showing 1 changed file with 93 additions and 8 deletions.
101 changes: 93 additions & 8 deletions x-pack/plugins/uptime/server/lib/requests/__tests__/get_certs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { elasticsearchServiceMock } from '../../../../../../../src/core/server/m

describe('getCerts', () => {
let mockHits: any;
let mockCallES: jest.Mock<any, any>;

beforeEach(() => {
mockHits = [
Expand Down Expand Up @@ -80,12 +79,6 @@ describe('getCerts', () => {
},
},
];
mockCallES = jest.fn();
mockCallES.mockImplementation(() => ({
hits: {
hits: mockHits,
},
}));
});

it('parses query result and returns expected values', async () => {
Expand Down Expand Up @@ -136,6 +129,98 @@ describe('getCerts', () => {
"total": 0,
}
`);
expect(mockCallES.mock.calls).toMatchInlineSnapshot(`Array []`);
expect(mockEsClient.search.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
Object {
"body": Object {
"_source": Array [
"monitor.id",
"monitor.name",
"tls.server.x509.issuer.common_name",
"tls.server.x509.subject.common_name",
"tls.server.hash.sha1",
"tls.server.hash.sha256",
"tls.server.x509.not_after",
"tls.server.x509.not_before",
],
"aggs": Object {
"total": Object {
"cardinality": Object {
"field": "tls.server.hash.sha256",
},
},
},
"collapse": Object {
"field": "tls.server.hash.sha256",
"inner_hits": Object {
"_source": Object {
"includes": Array [
"monitor.id",
"monitor.name",
"url.full",
],
},
"collapse": Object {
"field": "monitor.id",
},
"name": "monitors",
"sort": Array [
Object {
"monitor.id": "asc",
},
],
},
},
"from": 30,
"query": Object {
"bool": Object {
"filter": Array [
Object {
"exists": Object {
"field": "tls.server",
},
},
Object {
"range": Object {
"monitor.timespan": Object {
"gte": "now-2d",
"lte": "now+1h",
},
},
},
],
"minimum_should_match": 1,
"should": Array [
Object {
"multi_match": Object {
"fields": Array [
"monitor.id.text",
"monitor.name.text",
"url.full.text",
"tls.server.x509.subject.common_name.text",
"tls.server.x509.issuer.common_name.text",
],
"query": "my_common_name",
"type": "phrase_prefix",
},
},
],
},
},
"size": 30,
"sort": Array [
Object {
"tls.server.x509.not_after": Object {
"order": "desc",
},
},
],
},
"index": "heartbeat*",
},
],
]
`);
});
});

0 comments on commit 0d23236

Please sign in to comment.