Skip to content

Commit

Permalink
[Uptime] Update TLS settings (elastic#64111)
Browse files Browse the repository at this point in the history
* Refactor settings form event handling and modify certs fields.

* Fix/improve broken types/unit/integration/api tests.

* Modify default expiration threshold.

* Rename test vars.

* Implement PR feedback.

* Refresh snapshots, fix broken tests/types.

* Remove unnecessary state spreading.

* Add type for settings field errors.

* Refresh test snapshots.

* Improve punctuation.
  • Loading branch information
justinkambic committed Apr 24, 2020
1 parent c973796 commit 5822fee
Show file tree
Hide file tree
Showing 25 changed files with 381 additions and 335 deletions.
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/uptime/common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export { CHART_FORMAT_LIMITS } from './chart_format_limits';
export { CLIENT_DEFAULTS } from './client_defaults';
export { CONTEXT_DEFAULTS } from './context_defaults';
export * from './capabilities';
export * from './settings_defaults';
export { PLUGIN } from './plugin';
export { QUERY, STATES } from './query';
export * from './ui';
Expand Down
15 changes: 15 additions & 0 deletions x-pack/legacy/plugins/uptime/common/constants/settings_defaults.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { DynamicSettings } from '../runtime_types';

export const DYNAMIC_SETTINGS_DEFAULTS: DynamicSettings = {
heartbeatIndices: 'heartbeat-8*',
certThresholds: {
expiration: 30,
age: 365,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@

import * as t from 'io-ts';

export const CertificatesStatesThresholdType = t.interface({
warningState: t.number,
errorState: t.number,
export const CertStateThresholdsType = t.type({
age: t.number,
expiration: t.number,
});

export const DynamicSettingsType = t.intersection([
t.type({
heartbeatIndices: t.string,
}),
t.partial({
certificatesThresholds: CertificatesStatesThresholdType,
}),
]);
export const DynamicSettingsType = t.type({
heartbeatIndices: t.string,
certThresholds: CertStateThresholdsType,
});

export const DynamicSettingsSaveType = t.intersection([
t.type({
Expand All @@ -31,12 +27,4 @@ export const DynamicSettingsSaveType = t.intersection([

export type DynamicSettings = t.TypeOf<typeof DynamicSettingsType>;
export type DynamicSettingsSaveResponse = t.TypeOf<typeof DynamicSettingsSaveType>;
export type CertificatesStatesThreshold = t.TypeOf<typeof CertificatesStatesThresholdType>;

export const defaultDynamicSettings: DynamicSettings = {
heartbeatIndices: 'heartbeat-7*',
certificatesThresholds: {
errorState: 7,
warningState: 30,
},
};
export type CertStateThresholds = t.TypeOf<typeof CertStateThresholdsType>;

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

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 @@ -13,12 +13,13 @@ describe('CertificateForm', () => {
expect(
shallowWithRouter(
<CertificateExpirationForm
loading={false}
onChange={jest.fn()}
formFields={{
heartbeatIndices: 'heartbeat-8*',
certificatesThresholds: { errorState: 7, warningState: 36 },
certThresholds: { expiration: 7, age: 36 },
}}
fieldErrors={{}}
fieldErrors={null}
isDisabled={false}
/>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ describe('CertificateForm', () => {
expect(
shallowWithRouter(
<IndicesForm
loading={false}
onChange={jest.fn()}
formFields={{
heartbeatIndices: 'heartbeat-8*',
certificatesThresholds: { errorState: 7, warningState: 36 },
certThresholds: { expiration: 7, age: 36 },
}}
fieldErrors={{}}
fieldErrors={null}
isDisabled={false}
/>
)
Expand Down
Loading

0 comments on commit 5822fee

Please sign in to comment.