mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
This commit allows users to save uptime settings when they've got the advanced setting to inspect ES queries turned on. Previously, it was not possible to save these settings because the UI would not strip out the unnecessary `_inspect` field from the response and thus would send it as part of the configurations to change, which would then get refused because of this unexpected field. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Lucas F. da Costa <lucas@lucasfcosta.com>
This commit is contained in:
parent
b733af73aa
commit
40e06e6de4
4 changed files with 50 additions and 3 deletions
|
@ -7,7 +7,7 @@
|
|||
|
||||
import * as t from 'io-ts';
|
||||
|
||||
export const DynamicSettingsType = t.type({
|
||||
export const DynamicSettingsType = t.strict({
|
||||
heartbeatIndices: t.string,
|
||||
certAgeThreshold: t.number,
|
||||
certExpirationThreshold: t.number,
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { omit } from 'lodash';
|
||||
import { apiService } from './utils';
|
||||
import { getDynamicSettings } from './dynamic_settings';
|
||||
import { HttpSetup } from 'src/core/public';
|
||||
import { DynamicSettings } from '../../../common/runtime_types/dynamic_settings';
|
||||
|
||||
describe('Dynamic Settings API', () => {
|
||||
let fetchMock: jest.SpyInstance<Partial<unknown>>;
|
||||
const defaultResponse: DynamicSettings & { _inspect: never[] } = {
|
||||
heartbeatIndices: 'heartbeat-8*',
|
||||
certAgeThreshold: 1,
|
||||
certExpirationThreshold: 1337,
|
||||
defaultConnectors: [],
|
||||
_inspect: [],
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
apiService.http = {
|
||||
get: jest.fn(),
|
||||
fetch: jest.fn(),
|
||||
} as unknown as HttpSetup;
|
||||
|
||||
apiService.addInspectorRequest = jest.fn();
|
||||
|
||||
fetchMock = jest.spyOn(apiService.http, 'fetch');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('omits the _inspect prop on the response as decoding', async () => {
|
||||
fetchMock.mockReturnValue(new Promise((r) => r(defaultResponse)));
|
||||
|
||||
const resp = await getDynamicSettings();
|
||||
|
||||
expect(resp).toEqual(omit(defaultResponse, ['_inspect']));
|
||||
});
|
||||
});
|
|
@ -18,7 +18,7 @@ import {
|
|||
} from '../../common/translations';
|
||||
import { API_URLS } from '../../common/constants';
|
||||
|
||||
export const createGetDynamicSettingsRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({
|
||||
export const createGetDynamicSettingsRoute: UMRestApiRouteFactory = (_libs: UMServerLibs) => ({
|
||||
method: 'GET',
|
||||
path: API_URLS.DYNAMIC_SETTINGS,
|
||||
validate: false,
|
||||
|
@ -46,7 +46,7 @@ export const validateCertsValues = (
|
|||
}
|
||||
};
|
||||
|
||||
export const createPostDynamicSettingsRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({
|
||||
export const createPostDynamicSettingsRoute: UMRestApiRouteFactory = (_libs: UMServerLibs) => ({
|
||||
method: 'POST',
|
||||
path: API_URLS.DYNAMIC_SETTINGS,
|
||||
validate: {
|
||||
|
|
|
@ -16,6 +16,7 @@ import {
|
|||
DYNAMIC_SETTINGS_DEFAULTS,
|
||||
API_URLS,
|
||||
} from '../../../../../plugins/uptime/common/constants';
|
||||
|
||||
export default function ({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue