mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
# Backport This will backport the following commits from `main` to `8.6`: - [[Uptime] Use absolute time instead of relative for TLS rule query (#145293)](https://github.com/elastic/kibana/pull/145293) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Justin Kambic","email":"jk@elastic.co"},"sourceCommit":{"committedDate":"2022-11-23T10:00:13Z","message":"[Uptime] Use absolute time instead of relative for TLS rule query (#145293)\n\nCo-authored-by: shahzad31 <shahzad.muhammad@elastic.co>\r\nResolves https://github.com/elastic/kibana/issues/144131","sha":"723485e9e5d01ac252ec55b0f0deff32cef49fc2","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:uptime","v8.6.0","v8.7.0"],"number":145293,"url":"https://github.com/elastic/kibana/pull/145293","mergeCommit":{"message":"[Uptime] Use absolute time instead of relative for TLS rule query (#145293)\n\nCo-authored-by: shahzad31 <shahzad.muhammad@elastic.co>\r\nResolves https://github.com/elastic/kibana/issues/144131","sha":"723485e9e5d01ac252ec55b0f0deff32cef49fc2"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/145293","number":145293,"mergeCommit":{"message":"[Uptime] Use absolute time instead of relative for TLS rule query (#145293)\n\nCo-authored-by: shahzad31 <shahzad.muhammad@elastic.co>\r\nResolves https://github.com/elastic/kibana/issues/144131","sha":"723485e9e5d01ac252ec55b0f0deff32cef49fc2"}}]}] BACKPORT--> Co-authored-by: Justin Kambic <jk@elastic.co>
This commit is contained in:
parent
c6e8c3423e
commit
91741d4ed8
2 changed files with 18 additions and 7 deletions
|
@ -4,7 +4,9 @@
|
|||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import DateMath from '@kbn/datemath';
|
||||
import { CertResult, GetCertsParams, Ping } from '../runtime_types';
|
||||
import { createEsQuery } from '../utils/es_search';
|
||||
|
||||
|
@ -24,6 +26,10 @@ export const DEFAULT_SIZE = 20;
|
|||
export const DEFAULT_FROM = 'now-20m';
|
||||
export const DEFAULT_TO = 'now';
|
||||
|
||||
function absoluteDate(relativeDate: string) {
|
||||
return DateMath.parse(relativeDate)?.valueOf() ?? relativeDate;
|
||||
}
|
||||
|
||||
export const getCertsRequestBody = ({
|
||||
pageIndex,
|
||||
search,
|
||||
|
@ -79,8 +85,8 @@ export const getCertsRequestBody = ({
|
|||
{
|
||||
range: {
|
||||
'monitor.timespan': {
|
||||
gte: from,
|
||||
lte: to,
|
||||
gte: absoluteDate(from),
|
||||
lte: absoluteDate(to),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -95,7 +101,7 @@ export const getCertsRequestBody = ({
|
|||
{
|
||||
range: {
|
||||
'tls.certificate_not_valid_before': {
|
||||
lte: notValidBefore,
|
||||
lte: absoluteDate(notValidBefore),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -106,7 +112,7 @@ export const getCertsRequestBody = ({
|
|||
{
|
||||
range: {
|
||||
'tls.certificate_not_valid_after': {
|
||||
lte: notValidAfter,
|
||||
lte: absoluteDate(notValidAfter),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import DateMath from '@kbn/datemath';
|
||||
import moment from 'moment';
|
||||
import { getCerts } from './get_certs';
|
||||
import { getUptimeESMockClient } from './test_helpers';
|
||||
|
||||
|
@ -82,6 +84,9 @@ describe('getCerts', () => {
|
|||
});
|
||||
|
||||
it('parses query result and returns expected values', async () => {
|
||||
const dateMathSpy = jest.spyOn(DateMath, 'parse');
|
||||
|
||||
dateMathSpy.mockReturnValue(moment(10000));
|
||||
const { esClient, uptimeEsClient } = getUptimeESMockClient();
|
||||
|
||||
esClient.search.mockResponseOnce({
|
||||
|
@ -178,8 +183,8 @@ describe('getCerts', () => {
|
|||
Object {
|
||||
"range": Object {
|
||||
"monitor.timespan": Object {
|
||||
"gte": "now-2d",
|
||||
"lte": "now+1h",
|
||||
"gte": 10000,
|
||||
"lte": 10000,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -190,7 +195,7 @@ describe('getCerts', () => {
|
|||
Object {
|
||||
"range": Object {
|
||||
"tls.certificate_not_valid_after": Object {
|
||||
"lte": "now+100d",
|
||||
"lte": 10000,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue