From 6220fae002425f4e955537c312d0e4e3c9d2bc2d Mon Sep 17 00:00:00 2001 From: Shahzad Date: Tue, 9 May 2023 13:15:46 +0200 Subject: [PATCH] Revert "[Synthetics] quote monitor name to prevent invalid yaml" (#157143) --- .../common/formatters/browser/formatters.ts | 6 ++--- .../common/formatters/common/formatters.ts | 18 ++++++------- .../format_synthetics_policy.test.ts | 24 +++++++++--------- .../common/formatters/formatting_utils.ts | 9 ------- .../common/formatters/http/formatters.ts | 16 +++++------- .../common/formatters/icmp/formatters.ts | 3 +-- .../common/formatters/tcp/formatters.ts | 14 +++++------ .../formatters/format_configs.test.ts | 18 ++++++------- .../synthetics_private_location.test.ts | 8 +++--- .../synthetics_private_location.ts | 7 +++--- .../add_monitor_private_location.ts | 4 +-- .../add_monitor_project_private_location.ts | 8 +++--- .../sample_data/test_browser_policy.ts | 8 +++--- .../synthetics/sample_data/test_policy.ts | 25 ++++++------------- .../test_project_monitor_policy.ts | 12 ++++----- 15 files changed, 78 insertions(+), 102 deletions(-) diff --git a/x-pack/plugins/synthetics/common/formatters/browser/formatters.ts b/x-pack/plugins/synthetics/common/formatters/browser/formatters.ts index 22ce128fc2ab0..9dfa027767851 100644 --- a/x-pack/plugins/synthetics/common/formatters/browser/formatters.ts +++ b/x-pack/plugins/synthetics/common/formatters/browser/formatters.ts @@ -38,9 +38,9 @@ export const browserFormatters: BrowserFormatMap = { [ConfigKey.SCREENSHOTS]: null, [ConfigKey.IGNORE_HTTPS_ERRORS]: null, [ConfigKey.PLAYWRIGHT_OPTIONS]: null, - [ConfigKey.TEXT_ASSERTION]: stringToJsonFormatter, - [ConfigKey.PORT]: stringToJsonFormatter, - [ConfigKey.URLS]: stringToJsonFormatter, + [ConfigKey.TEXT_ASSERTION]: null, + [ConfigKey.PORT]: null, + [ConfigKey.URLS]: null, [ConfigKey.METADATA]: objectToJsonFormatter, [ConfigKey.SOURCE_INLINE]: stringToJsonFormatter, [ConfigKey.SYNTHETICS_ARGS]: arrayToJsonFormatter, diff --git a/x-pack/plugins/synthetics/common/formatters/common/formatters.ts b/x-pack/plugins/synthetics/common/formatters/common/formatters.ts index 4db075420f859..3122bcdb46442 100644 --- a/x-pack/plugins/synthetics/common/formatters/common/formatters.ts +++ b/x-pack/plugins/synthetics/common/formatters/common/formatters.ts @@ -6,30 +6,30 @@ */ import { CommonFields, ConfigKey, SourceType } from '../../runtime_types/monitor_management'; -import { arrayToJsonFormatter, stringToJsonFormatter, FormatterFn } from '../formatting_utils'; +import { arrayToJsonFormatter, FormatterFn } from '../formatting_utils'; export type Formatter = null | FormatterFn; export type CommonFormatMap = Record; export const commonFormatters: CommonFormatMap = { - [ConfigKey.APM_SERVICE_NAME]: stringToJsonFormatter, - [ConfigKey.NAME]: stringToJsonFormatter, + [ConfigKey.APM_SERVICE_NAME]: null, + [ConfigKey.NAME]: null, [ConfigKey.LOCATIONS]: null, [ConfigKey.MONITOR_TYPE]: null, [ConfigKey.ENABLED]: null, [ConfigKey.ALERT_CONFIG]: null, [ConfigKey.CONFIG_ID]: null, - [ConfigKey.NAMESPACE]: stringToJsonFormatter, + [ConfigKey.NAMESPACE]: null, [ConfigKey.REVISION]: null, [ConfigKey.MONITOR_SOURCE_TYPE]: null, [ConfigKey.FORM_MONITOR_TYPE]: null, - [ConfigKey.JOURNEY_ID]: stringToJsonFormatter, - [ConfigKey.PROJECT_ID]: stringToJsonFormatter, - [ConfigKey.CUSTOM_HEARTBEAT_ID]: stringToJsonFormatter, - [ConfigKey.ORIGINAL_SPACE]: stringToJsonFormatter, + [ConfigKey.JOURNEY_ID]: null, + [ConfigKey.PROJECT_ID]: null, + [ConfigKey.CUSTOM_HEARTBEAT_ID]: null, + [ConfigKey.ORIGINAL_SPACE]: null, [ConfigKey.CONFIG_HASH]: null, - [ConfigKey.MONITOR_QUERY_ID]: stringToJsonFormatter, + [ConfigKey.MONITOR_QUERY_ID]: null, [ConfigKey.SCHEDULE]: (fields) => JSON.stringify( `@every ${fields[ConfigKey.SCHEDULE]?.number}${fields[ConfigKey.SCHEDULE]?.unit}` diff --git a/x-pack/plugins/synthetics/common/formatters/format_synthetics_policy.test.ts b/x-pack/plugins/synthetics/common/formatters/format_synthetics_policy.test.ts index 7c045f807e4ca..2706972456acd 100644 --- a/x-pack/plugins/synthetics/common/formatters/format_synthetics_policy.test.ts +++ b/x-pack/plugins/synthetics/common/formatters/format_synthetics_policy.test.ts @@ -354,7 +354,7 @@ describe('formatSyntheticsPolicy', () => { }, id: { type: 'text', - value: '"00bb3ceb-a242-4c7a-8405-8da963661374"', + value: '00bb3ceb-a242-4c7a-8405-8da963661374', }, ignore_https_errors: { type: 'bool', @@ -372,7 +372,7 @@ describe('formatSyntheticsPolicy', () => { }, name: { type: 'text', - value: '"Test HTTP Monitor 03"', + value: 'Test HTTP Monitor 03', }, origin: { type: 'text', @@ -401,7 +401,7 @@ describe('formatSyntheticsPolicy', () => { }, 'service.name': { type: 'text', - value: '"Local Service"', + value: '', }, 'source.inline.script': { type: 'yaml', @@ -532,7 +532,7 @@ describe('formatSyntheticsPolicy', () => { }, id: { type: 'text', - value: '"51ccd9d9-fc3f-4718-ba9d-b6ef80e73fc5"', + value: '51ccd9d9-fc3f-4718-ba9d-b6ef80e73fc5', }, location_name: { type: 'text', @@ -550,7 +550,7 @@ describe('formatSyntheticsPolicy', () => { }, name: { type: 'text', - value: '"Test Monitor"', + value: 'Test Monitor', }, origin: { type: 'text', @@ -558,11 +558,11 @@ describe('formatSyntheticsPolicy', () => { }, password: { type: 'password', - value: '"changeme"', + value: 'changeme', }, proxy_url: { type: 'text', - value: '"https://proxy.com"', + value: 'https://proxy.com', }, 'response.include_body': { type: 'text', @@ -582,7 +582,7 @@ describe('formatSyntheticsPolicy', () => { }, 'service.name': { type: 'text', - value: '"LocalService"', + value: 'LocalService', }, 'ssl.certificate': { type: 'yaml', @@ -622,11 +622,11 @@ describe('formatSyntheticsPolicy', () => { }, urls: { type: 'text', - value: '"https://www.google.com"', + value: 'https://www.google.com', }, username: { type: 'text', - value: '"admin"', + value: '', }, }, }, @@ -1110,7 +1110,7 @@ const browserConfig: any = { enabled: true, alert: { status: { enabled: true } }, schedule: { number: '3', unit: 'm' }, - 'service.name': 'Local Service', + 'service.name': '', config_id: '00bb3ceb-a242-4c7a-8405-8da963661374', tags: ['cookie-test', 'browser'], timeout: '16', @@ -1198,7 +1198,7 @@ const httpPolicy: any = { 'check.request.body': { type: 'text', value: '' }, 'check.request.headers': {}, 'check.request.method': 'GET', - username: 'admin', + username: '', 'ssl.certificate_authorities': '', 'ssl.certificate': '', 'ssl.key': '', diff --git a/x-pack/plugins/synthetics/common/formatters/formatting_utils.ts b/x-pack/plugins/synthetics/common/formatters/formatting_utils.ts index 2c69f551cbf7b..9013496b96eeb 100644 --- a/x-pack/plugins/synthetics/common/formatters/formatting_utils.ts +++ b/x-pack/plugins/synthetics/common/formatters/formatting_utils.ts @@ -61,15 +61,6 @@ export const stringToJsonFormatter: FormatterFn = (fields, key) => { return value ? JSON.stringify(value) : null; }; -export const stringifyString = (value?: string) => { - if (!value) return value; - try { - return JSON.stringify(value); - } catch (e) { - return value; - } -}; - export const replaceStringWithParams = ( value: string | boolean | {} | [], params: Record, diff --git a/x-pack/plugins/synthetics/common/formatters/http/formatters.ts b/x-pack/plugins/synthetics/common/formatters/http/formatters.ts index f485159d34596..437112939f283 100644 --- a/x-pack/plugins/synthetics/common/formatters/http/formatters.ts +++ b/x-pack/plugins/synthetics/common/formatters/http/formatters.ts @@ -9,11 +9,7 @@ import { tlsFormatters } from '../tls/formatters'; import { HTTPFields, ConfigKey } from '../../runtime_types/monitor_management'; import { Formatter, commonFormatters } from '../common/formatters'; -import { - stringToJsonFormatter, - arrayToJsonFormatter, - objectToJsonFormatter, -} from '../formatting_utils'; +import { arrayToJsonFormatter, objectToJsonFormatter } from '../formatting_utils'; export type HTTPFormatMap = Record; @@ -23,12 +19,12 @@ export const httpFormatters: HTTPFormatMap = { [ConfigKey.RESPONSE_BODY_INDEX]: null, [ConfigKey.RESPONSE_HEADERS_INDEX]: null, [ConfigKey.METADATA]: objectToJsonFormatter, - [ConfigKey.URLS]: stringToJsonFormatter, - [ConfigKey.USERNAME]: stringToJsonFormatter, - [ConfigKey.PASSWORD]: stringToJsonFormatter, - [ConfigKey.PROXY_URL]: stringToJsonFormatter, + [ConfigKey.URLS]: null, + [ConfigKey.USERNAME]: null, + [ConfigKey.PASSWORD]: null, + [ConfigKey.PROXY_URL]: null, [ConfigKey.PROXY_HEADERS]: objectToJsonFormatter, - [ConfigKey.PORT]: stringToJsonFormatter, + [ConfigKey.PORT]: null, [ConfigKey.RESPONSE_BODY_CHECK_NEGATIVE]: arrayToJsonFormatter, [ConfigKey.RESPONSE_BODY_CHECK_POSITIVE]: arrayToJsonFormatter, [ConfigKey.RESPONSE_JSON_CHECK]: arrayToJsonFormatter, diff --git a/x-pack/plugins/synthetics/common/formatters/icmp/formatters.ts b/x-pack/plugins/synthetics/common/formatters/icmp/formatters.ts index acdccebfb4b57..f58e15c86b3ad 100644 --- a/x-pack/plugins/synthetics/common/formatters/icmp/formatters.ts +++ b/x-pack/plugins/synthetics/common/formatters/icmp/formatters.ts @@ -9,12 +9,11 @@ import { secondsToCronFormatter } from '../formatting_utils'; import { ICMPFields, ConfigKey } from '../../runtime_types/monitor_management'; import { Formatter, commonFormatters } from '../common/formatters'; -import { stringToJsonFormatter } from '../formatting_utils'; export type ICMPFormatMap = Record; export const icmpFormatters: ICMPFormatMap = { - [ConfigKey.HOSTS]: stringToJsonFormatter, + [ConfigKey.HOSTS]: null, [ConfigKey.WAIT]: secondsToCronFormatter, [ConfigKey.MODE]: null, [ConfigKey.IPV4]: null, diff --git a/x-pack/plugins/synthetics/common/formatters/tcp/formatters.ts b/x-pack/plugins/synthetics/common/formatters/tcp/formatters.ts index a3127c1cb49b4..2d850e95ceaf1 100644 --- a/x-pack/plugins/synthetics/common/formatters/tcp/formatters.ts +++ b/x-pack/plugins/synthetics/common/formatters/tcp/formatters.ts @@ -10,19 +10,19 @@ import { TCPFields, ConfigKey } from '../../runtime_types/monitor_management'; import { Formatter, commonFormatters } from '../common/formatters'; import { objectToJsonFormatter } from '../formatting_utils'; import { tlsFormatters } from '../tls/formatters'; -import { stringToJsonFormatter } from '../formatting_utils'; export type TCPFormatMap = Record; export const tcpFormatters: TCPFormatMap = { [ConfigKey.METADATA]: objectToJsonFormatter, - [ConfigKey.HOSTS]: stringToJsonFormatter, + [ConfigKey.HOSTS]: null, [ConfigKey.PROXY_USE_LOCAL_RESOLVER]: null, - [ConfigKey.RESPONSE_RECEIVE_CHECK]: stringToJsonFormatter, - [ConfigKey.REQUEST_SEND_CHECK]: stringToJsonFormatter, - [ConfigKey.PROXY_URL]: stringToJsonFormatter, - [ConfigKey.PORT]: stringToJsonFormatter, - [ConfigKey.URLS]: stringToJsonFormatter, + [ConfigKey.RESPONSE_RECEIVE_CHECK]: null, + [ConfigKey.REQUEST_SEND_CHECK]: null, + [ConfigKey.PROXY_URL]: null, + [ConfigKey.PROXY_URL]: null, + [ConfigKey.PORT]: null, + [ConfigKey.URLS]: null, [ConfigKey.MODE]: null, [ConfigKey.IPV4]: null, [ConfigKey.IPV6]: null, diff --git a/x-pack/plugins/synthetics/server/synthetics_service/formatters/format_configs.test.ts b/x-pack/plugins/synthetics/server/synthetics_service/formatters/format_configs.test.ts index 710946e520646..921fd737e5d3e 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/formatters/format_configs.test.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/formatters/format_configs.test.ts @@ -119,15 +119,15 @@ describe('formatMonitorConfig', () => { enabled: true, locations: [], max_redirects: '0', - name: '"Test"', - password: '"3z9SBOQWW5F0UrdqLVFqlF6z"', + name: 'Test', + password: '3z9SBOQWW5F0UrdqLVFqlF6z', 'response.include_body': 'on_error', 'response.include_headers': true, schedule: '@every 3m', timeout: '16s', type: 'http', - urls: '"https://www.google.com"', - proxy_url: '"https://www.google.com"', + urls: 'https://www.google.com', + proxy_url: 'https://www.google.com', }); }); @@ -158,15 +158,15 @@ describe('formatMonitorConfig', () => { enabled: true, locations: [], max_redirects: '0', - name: '"Test"', - password: '"3z9SBOQWW5F0UrdqLVFqlF6z"', - proxy_url: '"https://www.google.com"', + name: 'Test', + password: '3z9SBOQWW5F0UrdqLVFqlF6z', + proxy_url: 'https://www.google.com', 'response.include_body': 'on_error', 'response.include_headers': true, schedule: '@every 3m', timeout: '16s', type: 'http', - urls: '"https://www.google.com"', + urls: 'https://www.google.com', ...(isTLSEnabled ? { 'ssl.verification_mode': 'none' } : {}), }); } @@ -183,7 +183,7 @@ describe('browser fields', () => { enabled: true, 'filter_journeys.tags': ['dev'], ignore_https_errors: false, - name: '"Test"', + name: 'Test', locations: [], schedule: '@every 3m', screenshots: 'on', diff --git a/x-pack/plugins/synthetics/server/synthetics_service/private_location/synthetics_private_location.test.ts b/x-pack/plugins/synthetics/server/synthetics_service/private_location/synthetics_private_location.test.ts index fcab7e6cb06c4..5b0b1895de3a2 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/private_location/synthetics_private_location.test.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/private_location/synthetics_private_location.test.ts @@ -31,7 +31,7 @@ describe('SyntheticsPrivateLocation', () => { type: 'http', enabled: true, schedule: '@every 3m', - 'service.name': 'test service', + 'service.name': '', locations: [mockPrivateLocation], tags: [], timeout: '16', @@ -226,7 +226,7 @@ describe('SyntheticsPrivateLocation', () => { }, name: { type: 'text', - value: '"Browser monitor"', + value: 'Browser monitor', }, params: { type: 'yaml', @@ -246,7 +246,7 @@ describe('SyntheticsPrivateLocation', () => { }, 'service.name': { type: 'text', - value: '"test service"', + value: '', }, 'source.inline.script': { type: 'yaml', @@ -286,7 +286,7 @@ const dummyBrowserConfig: Partial & { type: DataStream.BROWSER, enabled: true, schedule: { unit: ScheduleUnit.MINUTES, number: '10' }, - 'service.name': 'test service', + 'service.name': '', tags: [], timeout: null, name: 'Browser monitor', diff --git a/x-pack/plugins/synthetics/server/synthetics_service/private_location/synthetics_private_location.ts b/x-pack/plugins/synthetics/server/synthetics_service/private_location/synthetics_private_location.ts index 9aef89a86a4a9..51545433b9450 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/private_location/synthetics_private_location.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/private_location/synthetics_private_location.ts @@ -9,7 +9,6 @@ import { NewPackagePolicy } from '@kbn/fleet-plugin/common'; import { NewPackagePolicyWithId } from '@kbn/fleet-plugin/server/services/package_policy'; import { cloneDeep } from 'lodash'; import { SavedObjectError } from '@kbn/core-saved-objects-common'; -import { stringifyString } from '../../../common/formatters/formatting_utils'; import { formatSyntheticsPolicy } from '../../../common/formatters/format_synthetics_policy'; import { ConfigKey, @@ -87,9 +86,9 @@ export class SyntheticsPrivateLocation { { ...(config as Partial), config_id: config.fields?.config_id, - location_name: stringifyString(privateLocation.label), - 'monitor.project.id': stringifyString(config.fields?.['monitor.project.name']), - 'monitor.project.name': stringifyString(config.fields?.['monitor.project.name']), + location_name: privateLocation.label, + 'monitor.project.id': config.fields?.['monitor.project.name'], + 'monitor.project.name': config.fields?.['monitor.project.name'], }, globalParams ); diff --git a/x-pack/test/api_integration/apis/synthetics/add_monitor_private_location.ts b/x-pack/test/api_integration/apis/synthetics/add_monitor_private_location.ts index 8a2da70a07009..149961f41e084 100644 --- a/x-pack/test/api_integration/apis/synthetics/add_monitor_private_location.ts +++ b/x-pack/test/api_integration/apis/synthetics/add_monitor_private_location.ts @@ -90,7 +90,7 @@ export default function ({ getService }: FtrProviderContext) { it('does not add a monitor if there is an error in creating integration', async () => { const newMonitor = { ...httpMonitorJson }; - const invalidName = '!@#$%^&*()_++[\\-\\]- wow'; + const invalidName = '[] - invalid name'; newMonitor.locations.push({ id: testFleetPolicyID, @@ -109,7 +109,7 @@ export default function ({ getService }: FtrProviderContext) { expect(apiResponse.body).eql({ statusCode: 500, message: - 'YAMLException: unknown escape sequence at line 3, column 34:\n name: "!@#$,%,^,&,*,(,),_,+,+,[,\\,\\,-,\\,\\,],-, ,w,o,w,"\n ^', + 'YAMLException: end of the stream or a document separator is expected at line 3, column 10:\n name: [] - invalid name\n ^', error: 'Internal Server Error', }); diff --git a/x-pack/test/api_integration/apis/synthetics/add_monitor_project_private_location.ts b/x-pack/test/api_integration/apis/synthetics/add_monitor_project_private_location.ts index d53309c48e340..7c6517d3cddf1 100644 --- a/x-pack/test/api_integration/apis/synthetics/add_monitor_project_private_location.ts +++ b/x-pack/test/api_integration/apis/synthetics/add_monitor_project_private_location.ts @@ -64,13 +64,13 @@ export default function ({ getService }: FtrProviderContext) { }; const testMonitors = [ projectMonitors.monitors[0], - { ...secondMonitor, name: '!@#$%^&*()_++[\\-\\]- wow name' }, + { ...secondMonitor, name: '[] - invalid name' }, ]; try { const body = await monitorTestService.addProjectMonitors(project, testMonitors); expect(body.createdMonitors.length).eql(1); expect(body.failedMonitors[0].reason).eql( - 'unknown escape sequence at line 3, column 34:\n name: "!@#$,%,^,&,*,(,),_,+,+,[,\\,\\,-,\\,\\,],-, ,w,o,w, ,n,a,m,e,"\n ^' + 'end of the stream or a document separator is expected at line 3, column 10:\n name: [] - invalid name\n ^' ); } finally { await Promise.all([ @@ -97,7 +97,7 @@ export default function ({ getService }: FtrProviderContext) { expect(editedBody.createdMonitors.length).eql(0); expect(editedBody.updatedMonitors.length).eql(2); - testMonitors[1].name = '!@#$%^&*()_++[\\-\\]- wow name'; + testMonitors[1].name = '[] - invalid name'; const editedBodyError = await monitorTestService.addProjectMonitors(project, testMonitors); expect(editedBodyError.createdMonitors.length).eql(0); @@ -107,7 +107,7 @@ export default function ({ getService }: FtrProviderContext) { 'Failed to update journey: test-id-2' ); expect(editedBodyError.failedMonitors[0].reason).eql( - 'unknown escape sequence at line 3, column 34:\n name: "!@#$,%,^,&,*,(,),_,+,+,[,\\,\\,-,\\,\\,],-, ,w,o,w, ,n,a,m,e,"\n ^' + 'end of the stream or a document separator is expected at line 3, column 10:\n name: [] - invalid name\n ^' ); } finally { await Promise.all([ diff --git a/x-pack/test/api_integration/apis/synthetics/sample_data/test_browser_policy.ts b/x-pack/test/api_integration/apis/synthetics/sample_data/test_browser_policy.ts index 19cc3998bee0d..5eec726cdb328 100644 --- a/x-pack/test/api_integration/apis/synthetics/sample_data/test_browser_policy.ts +++ b/x-pack/test/api_integration/apis/synthetics/sample_data/test_browser_policy.ts @@ -177,9 +177,9 @@ export const getTestBrowserSyntheticsPolicy = ({ }, enabled: { value: true, type: 'bool' }, type: { value: 'browser', type: 'text' }, - name: { value: '"Test HTTP Monitor 03"', type: 'text' }, + name: { value: 'Test HTTP Monitor 03', type: 'text' }, schedule: { value: '"@every 3m"', type: 'text' }, - 'service.name': { value: null, type: 'text' }, + 'service.name': { value: '', type: 'text' }, timeout: { value: '16s', type: 'text' }, tags: { value: '["cookie-test","browser"]', type: 'yaml' }, 'source.zip_url.url': { type: 'text' }, @@ -210,8 +210,8 @@ export const getTestBrowserSyntheticsPolicy = ({ 'source.zip_url.ssl.verification_mode': { type: 'text' }, 'source.zip_url.ssl.supported_protocols': { type: 'yaml' }, 'source.zip_url.proxy_url': { type: 'text' }, - location_name: { value: JSON.stringify('Test private location 0'), type: 'text' }, - id: { value: JSON.stringify(id), type: 'text' }, + location_name: { value: 'Test private location 0', type: 'text' }, + id: { value: id, type: 'text' }, config_id: { value: id, type: 'text' }, run_once: { value: false, type: 'bool' }, origin: { value: 'ui', type: 'text' }, diff --git a/x-pack/test/api_integration/apis/synthetics/sample_data/test_policy.ts b/x-pack/test/api_integration/apis/synthetics/sample_data/test_policy.ts index d59aa207c28a2..b0962e4d285e6 100644 --- a/x-pack/test/api_integration/apis/synthetics/sample_data/test_policy.ts +++ b/x-pack/test/api_integration/apis/synthetics/sample_data/test_policy.ts @@ -48,23 +48,17 @@ export const getTestSyntheticsPolicy = ( }, enabled: { value: true, type: 'bool' }, type: { value: 'http', type: 'text' }, - name: { value: `"${name}"`, type: 'text' }, + name: { value: name, type: 'text' }, schedule: { value: '"@every 5m"', type: 'text' }, - urls: { - value: JSON.stringify('https://nextjs-test-synthetics.vercel.app/api/users'), - type: 'text', - }, - 'service.name': { value: null, type: 'text' }, + urls: { value: 'https://nextjs-test-synthetics.vercel.app/api/users', type: 'text' }, + 'service.name': { value: '', type: 'text' }, timeout: { value: '3ms', type: 'text' }, max_redirects: { value: '3', type: 'integer' }, - proxy_url: { - value: JSON.stringify(proxyUrl) ?? JSON.stringify('http://proxy.com'), - type: 'text', - }, + proxy_url: { value: proxyUrl ?? 'http://proxy.com', type: 'text' }, proxy_headers: { value: null, type: 'yaml' }, tags: { value: '["tag1","tag2"]', type: 'yaml' }, - username: { value: '"test-username"', type: 'text' }, - password: { value: '"test"', type: 'password' }, + username: { value: 'test-username', type: 'text' }, + password: { value: 'test', type: 'password' }, 'response.include_headers': { value: true, type: 'bool' }, 'response.include_body': { value: 'never', type: 'text' }, 'response.include_body_max_bytes': { value: '1024', type: 'text' }, @@ -91,11 +85,8 @@ export const getTestSyntheticsPolicy = ( value: isTLSEnabled ? '["TLSv1.1","TLSv1.2"]' : null, type: 'yaml', }, - location_name: { - value: JSON.stringify(locationName) ?? JSON.stringify('Test private location 0'), - type: 'text', - }, - id: { value: JSON.stringify(id), type: 'text' }, + location_name: { value: locationName ?? 'Test private location 0', type: 'text' }, + id: { value: id, type: 'text' }, config_id: { value: id, type: 'text' }, run_once: { value: false, type: 'bool' }, origin: { value: 'ui', type: 'text' }, diff --git a/x-pack/test/api_integration/apis/synthetics/sample_data/test_project_monitor_policy.ts b/x-pack/test/api_integration/apis/synthetics/sample_data/test_project_monitor_policy.ts index 2289fb68d2565..bc015cb4bd77c 100644 --- a/x-pack/test/api_integration/apis/synthetics/sample_data/test_project_monitor_policy.ts +++ b/x-pack/test/api_integration/apis/synthetics/sample_data/test_project_monitor_policy.ts @@ -202,9 +202,9 @@ export const getTestProjectSyntheticsPolicy = ( }, enabled: { value: true, type: 'bool' }, type: { value: 'browser', type: 'text' }, - name: { value: '"check if title is present"', type: 'text' }, + name: { value: 'check if title is present', type: 'text' }, schedule: { value: '"@every 10m"', type: 'text' }, - 'service.name': { value: null, type: 'text' }, + 'service.name': { value: '', type: 'text' }, timeout: { value: null, type: 'text' }, tags: { value: null, type: 'yaml' }, 'source.zip_url.url': { type: 'text' }, @@ -238,13 +238,13 @@ export const getTestProjectSyntheticsPolicy = ( 'source.zip_url.ssl.verification_mode': { type: 'text' }, 'source.zip_url.ssl.supported_protocols': { type: 'yaml' }, 'source.zip_url.proxy_url': { type: 'text' }, - location_name: { value: '"Test private location 0"', type: 'text' }, - id: { value: `"${id}"`, type: 'text' }, + location_name: { value: 'Test private location 0', type: 'text' }, + id: { value: id, type: 'text' }, config_id: { value: configId, type: 'text' }, run_once: { value: false, type: 'bool' }, origin: { value: 'project', type: 'text' }, - 'monitor.project.id': { value: JSON.stringify(projectId), type: 'text' }, - 'monitor.project.name': { value: JSON.stringify(projectId), type: 'text' }, + 'monitor.project.id': { value: projectId, type: 'text' }, + 'monitor.project.name': { value: projectId, type: 'text' }, ...inputs, }, id: `synthetics/browser-browser-4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-d70a46e0-22ea-11ed-8c6b-09a2d21dfbc3`,