Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Apr 29, 2020
1 parent a7245ae commit 7ac98c7
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 77 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React from 'react';
import { EuiToolTip } from '@elastic/eui';
import { CertMonitor } from '../../../common/runtime_types';
import { MonitorPageLink } from '../../../../../../plugins/uptime/public/components/common/monitor_page_link';
import { MonitorPageLink } from '../common/monitor_page_link';

interface Props {
monitors: CertMonitor[];
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ import moment from 'moment';
import styled from 'styled-components';
import { EuiIcon, EuiText, EuiToolTip } from '@elastic/eui';
import { Cert } from '../../../../common/runtime_types';
import { CERT_STATUS, useCertStatus } from '../../../../../../legacy/plugins/uptime/public/hooks';
import {
EXPIRED,
EXPIRES_SOON,
} from '../../../../../../legacy/plugins/uptime/public/components/certificates/translations';
import { CERT_STATUS, useCertStatus } from '../../../hooks';
import { EXPIRED, EXPIRES_SOON } from '../../certificates/translations';

interface Props {
cert: Cert;
Expand Down
15 changes: 4 additions & 11 deletions x-pack/plugins/uptime/public/pages/certificates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,17 @@ import {
EuiSpacer,
} from '@elastic/eui';
import React, { useContext, useEffect, useState } from 'react';
import { FormattedMessage } from '@kbn/i18n/target/types/react';
import { useUptimeTelemetry, UptimePage } from '../../../../legacy/plugins/uptime/public/hooks';
import { FormattedMessage } from '@kbn/i18n/react';
import { useTrackPageview } from '../../../observability/public';
import { PageHeader } from './page_header';
import { useBreadcrumbs } from '../hooks/use_breadcrumbs';
import {
CertificateList,
CertSort,
CertificateSearch,
} from '../../../../legacy/plugins/uptime/public/components/certificates';
import { OVERVIEW_ROUTE, SETTINGS_ROUTE } from '../../common/constants';
import { getDynamicSettings } from '../state/actions/dynamic_settings';
import {
certificatesSelector,
getCertificatesAction,
} from '../../../../legacy/plugins/uptime/public/state/certificates/certificates';
import { UptimeRefreshContext } from '../contexts';
import * as labels from './translations';
import { UptimePage, useUptimeTelemetry } from '../hooks';
import { certificatesSelector, getCertificatesAction } from '../state/certificates/certificates';
import { CertificateList, CertificateSearch, CertSort } from '../components/certificates';

const DEFAULT_PAGE_SIZE = 10;
const LOCAL_STORAGE_KEY = 'xpack.uptime.certList.pageSize';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ describe('getCerts', () => {
name: 'Real World Test',
id: 'real-world-test',
},
url: {
full: 'https://fullurl.com',
},
},
fields: {
'tls.server.hash.sha256': [
Expand Down Expand Up @@ -111,6 +114,7 @@ describe('getCerts', () => {
Object {
"id": "real-world-test",
"name": "Real World Test",
"url": undefined,
},
],
"sha1": "b7b4b89ef0d0caf39d223736f0fdbb03c7b426f1",
Expand Down Expand Up @@ -150,6 +154,7 @@ describe('getCerts', () => {
"includes": Array [
"monitor.id",
"monitor.name",
"url.full",
],
},
"collapse": Object {
Expand Down Expand Up @@ -184,31 +189,16 @@ describe('getCerts', () => {
"minimum_should_match": 1,
"should": Array [
Object {
"wildcard": Object {
"tls.server.issuer": Object {
"value": "*my_common_name*",
},
},
},
Object {
"wildcard": Object {
"tls.server.x509.issuer.common_name": Object {
"value": "*my_common_name*",
},
},
},
Object {
"wildcard": Object {
"monitor.id": Object {
"value": "*my_common_name*",
},
},
},
Object {
"wildcard": Object {
"monitor.name": Object {
"value": "*my_common_name*",
},
"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",
},
},
],
Expand All @@ -217,7 +207,7 @@ describe('getCerts', () => {
"size": 30,
"sort": Array [
Object {
"tls.certificate_not_valid_after": Object {
"undefined": Object {
"order": "desc",
},
},
Expand Down
7 changes: 3 additions & 4 deletions x-pack/plugins/uptime/server/lib/requests/get_certs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export const getCerts: UMElasticsearchQueryFn<GetCertsParams, CertResult> = asyn
sortBy,
direction,
}) => {
const searchWrapper = `*${search}*`;
const sort = SortFields[sortBy];
const sort = SortFields[sortBy as keyof SortFields];

const params: any = {
index: dynamicSettings.heartbeatIndices,
Expand Down Expand Up @@ -97,7 +96,7 @@ export const getCerts: UMElasticsearchQueryFn<GetCertsParams, CertResult> = asyn
params.body.query.bool.should = [
{
multi_match: {
query: searchWrapper,
query: search,
type: 'phrase_prefix',
fields: [
'monitor.id.text',
Expand Down Expand Up @@ -128,7 +127,7 @@ export const getCerts: UMElasticsearchQueryFn<GetCertsParams, CertResult> = asyn
const monitors = hit.inner_hits.monitors.hits.hits.map((monitor: any) => ({
name: monitor._source?.monitor.name,
id: monitor._source?.monitor.id,
url: monitor._source?.url.full,
url: monitor._source?.url?.full,
}));

return {
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/uptime/server/rest_api/certs/certs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*/

import { schema } from '@kbn/config-schema';
import { UMServerLibs } from '../lib/lib';
import { UMRestApiRouteFactory } from '.';
import { API_URLS } from '../../common/constants';
import { API_URLS } from '../../../common/constants';
import { UMServerLibs } from '../../lib/lib';
import { UMRestApiRouteFactory } from '../types';

const DEFAULT_INDEX = 0;
const DEFAULT_SIZE = 25;
Expand Down

0 comments on commit 7ac98c7

Please sign in to comment.