diff --git a/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts b/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts index caa6d371d50b2e..cf67de10d1bf06 100644 --- a/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts +++ b/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts @@ -137,7 +137,7 @@ describe('checking migration metadata changes on all registered SO types', () => "slo": "ee0e16abebba5779c37277bc3fe8da1fe1207b7a", "space": "7fc578a1f9f7708cb07479f03953d664ad9f1dae", "spaces-usage-stats": "084bd0f080f94fb5735d7f3cf12f13ec92f36bad", - "synthetics-monitor": "96cc312bfa597022f83dfb3b5d1501e27a73e8d5", + "synthetics-monitor": "7136a2669a65323c56da849f26c369cdeeb3b381", "synthetics-param": "9776c9b571d35f0d0397e8915e035ea1dc026db7", "synthetics-privates-locations": "7d032fc788905e32152029ae7ab3d6038c48ae44", "tag": "87f21f07df9cc37001b15a26e413c18f50d1fbfe", diff --git a/x-pack/plugins/synthetics/common/constants/monitor_defaults.ts b/x-pack/plugins/synthetics/common/constants/monitor_defaults.ts index 83aeed3269f3e6..956dfa2af23b54 100644 --- a/x-pack/plugins/synthetics/common/constants/monitor_defaults.ts +++ b/x-pack/plugins/synthetics/common/constants/monitor_defaults.ts @@ -30,6 +30,19 @@ import { ConfigKey } from './monitor_management'; export const DEFAULT_NAMESPACE_STRING = 'default'; +export const ALLOWED_SCHEDULES_IN_MINUTES = [ + '1', + '3', + '5', + '10', + '15', + '20', + '30', + '60', + '120', + '240', +]; + export const DEFAULT_COMMON_FIELDS: CommonFields = { [ConfigKey.MONITOR_TYPE]: DataStream.HTTP, [ConfigKey.FORM_MONITOR_TYPE]: FormMonitorType.MULTISTEP, @@ -74,7 +87,6 @@ export const DEFAULT_BROWSER_SIMPLE_FIELDS: BrowserSimpleFields = { is_generated_script: false, file_name: '', }, - is_zip_url_tls_enabled: false, }, [ConfigKey.MONITOR_TYPE]: DataStream.BROWSER, [ConfigKey.PARAMS]: '', @@ -85,23 +97,10 @@ export const DEFAULT_BROWSER_SIMPLE_FIELDS: BrowserSimpleFields = { }, [ConfigKey.SOURCE_INLINE]: '', [ConfigKey.SOURCE_PROJECT_CONTENT]: '', - [ConfigKey.SOURCE_ZIP_URL]: '', - [ConfigKey.SOURCE_ZIP_USERNAME]: '', - [ConfigKey.SOURCE_ZIP_PASSWORD]: '', - [ConfigKey.SOURCE_ZIP_FOLDER]: '', - [ConfigKey.SOURCE_ZIP_PROXY_URL]: '', [ConfigKey.TEXT_ASSERTION]: '', [ConfigKey.URLS]: '', [ConfigKey.FORM_MONITOR_TYPE]: FormMonitorType.MULTISTEP, [ConfigKey.TIMEOUT]: null, - - // Deprecated, slated to be removed in a future version - [ConfigKey.ZIP_URL_TLS_CERTIFICATE_AUTHORITIES]: undefined, - [ConfigKey.ZIP_URL_TLS_CERTIFICATE]: undefined, - [ConfigKey.ZIP_URL_TLS_KEY]: undefined, - [ConfigKey.ZIP_URL_TLS_KEY_PASSPHRASE]: undefined, - [ConfigKey.ZIP_URL_TLS_VERIFICATION_MODE]: undefined, - [ConfigKey.ZIP_URL_TLS_VERSION]: undefined, }; export const DEFAULT_HTTP_SIMPLE_FIELDS: HTTPSimpleFields = { diff --git a/x-pack/plugins/synthetics/common/constants/monitor_management.ts b/x-pack/plugins/synthetics/common/constants/monitor_management.ts index 78e1829356458d..231acff2c6230f 100644 --- a/x-pack/plugins/synthetics/common/constants/monitor_management.ts +++ b/x-pack/plugins/synthetics/common/constants/monitor_management.ts @@ -54,11 +54,6 @@ export enum ConfigKey { SCREENSHOTS = 'screenshots', SOURCE_PROJECT_CONTENT = 'source.project.content', SOURCE_INLINE = 'source.inline.script', - SOURCE_ZIP_URL = 'source.zip_url.url', - SOURCE_ZIP_USERNAME = 'source.zip_url.username', - SOURCE_ZIP_PASSWORD = 'source.zip_url.password', - SOURCE_ZIP_FOLDER = 'source.zip_url.folder', - SOURCE_ZIP_PROXY_URL = 'source.zip_url.proxy_url', PROJECT_ID = 'project_id', SYNTHETICS_ARGS = 'synthetics_args', TEXT_ASSERTION = 'playwright_text_assertion', @@ -78,12 +73,6 @@ export enum ConfigKey { URLS = 'urls', USERNAME = 'username', WAIT = 'wait', - ZIP_URL_TLS_CERTIFICATE_AUTHORITIES = 'source.zip_url.ssl.certificate_authorities', - ZIP_URL_TLS_CERTIFICATE = 'source.zip_url.ssl.certificate', - ZIP_URL_TLS_KEY = 'source.zip_url.ssl.key', - ZIP_URL_TLS_KEY_PASSPHRASE = 'source.zip_url.ssl.key_passphrase', - ZIP_URL_TLS_VERIFICATION_MODE = 'source.zip_url.ssl.verification_mode', - ZIP_URL_TLS_VERSION = 'source.zip_url.ssl.supported_protocols', MONITOR_QUERY_ID = 'id', } @@ -99,12 +88,22 @@ export const secretKeys = [ ConfigKey.RESPONSE_RECEIVE_CHECK, ConfigKey.SOURCE_INLINE, ConfigKey.SOURCE_PROJECT_CONTENT, - ConfigKey.SOURCE_ZIP_USERNAME, - ConfigKey.SOURCE_ZIP_PASSWORD, ConfigKey.SYNTHETICS_ARGS, ConfigKey.TLS_KEY, ConfigKey.TLS_KEY_PASSPHRASE, ConfigKey.USERNAME, - ConfigKey.ZIP_URL_TLS_KEY, - ConfigKey.ZIP_URL_TLS_KEY_PASSPHRASE, ] as const; + +export enum LegacyConfigKey { + SOURCE_ZIP_URL = 'source.zip_url.url', + SOURCE_ZIP_USERNAME = 'source.zip_url.username', + SOURCE_ZIP_PASSWORD = 'source.zip_url.password', + SOURCE_ZIP_FOLDER = 'source.zip_url.folder', + SOURCE_ZIP_PROXY_URL = 'source.zip_url.proxy_url', + ZIP_URL_TLS_CERTIFICATE_AUTHORITIES = 'source.zip_url.ssl.certificate_authorities', + ZIP_URL_TLS_CERTIFICATE = 'source.zip_url.ssl.certificate', + ZIP_URL_TLS_KEY = 'source.zip_url.ssl.key', + ZIP_URL_TLS_KEY_PASSPHRASE = 'source.zip_url.ssl.key_passphrase', + ZIP_URL_TLS_VERIFICATION_MODE = 'source.zip_url.ssl.verification_mode', + ZIP_URL_TLS_VERSION = 'source.zip_url.ssl.supported_protocols', +} diff --git a/x-pack/plugins/synthetics/common/formatters/browser/formatters.ts b/x-pack/plugins/synthetics/common/formatters/browser/formatters.ts index 9e9f7283ec38f7..1ad7c055aecc37 100644 --- a/x-pack/plugins/synthetics/common/formatters/browser/formatters.ts +++ b/x-pack/plugins/synthetics/common/formatters/browser/formatters.ts @@ -11,9 +11,6 @@ import { arrayToJsonFormatter, objectToJsonFormatter, stringToJsonFormatter, - tlsArrayToYamlFormatter, - tlsValueToStringFormatter, - tlsValueToYamlFormatter, } from '../formatting_utils'; import { tlsFormatters } from '../tls/formatters'; @@ -35,20 +32,6 @@ const throttlingFormatter: Formatter = (fields) => { .join('/'); }; -export const deprecatedZipUrlFormatters = { - [ConfigKey.SOURCE_ZIP_URL]: null, - [ConfigKey.SOURCE_ZIP_USERNAME]: null, - [ConfigKey.SOURCE_ZIP_PASSWORD]: null, - [ConfigKey.SOURCE_ZIP_FOLDER]: null, - [ConfigKey.SOURCE_ZIP_PROXY_URL]: null, - [ConfigKey.ZIP_URL_TLS_CERTIFICATE_AUTHORITIES]: tlsValueToYamlFormatter, - [ConfigKey.ZIP_URL_TLS_CERTIFICATE]: tlsValueToYamlFormatter, - [ConfigKey.ZIP_URL_TLS_KEY]: tlsValueToYamlFormatter, - [ConfigKey.ZIP_URL_TLS_KEY_PASSPHRASE]: tlsValueToStringFormatter, - [ConfigKey.ZIP_URL_TLS_VERIFICATION_MODE]: tlsValueToStringFormatter, - [ConfigKey.ZIP_URL_TLS_VERSION]: tlsArrayToYamlFormatter, -}; - export const browserFormatters: BrowserFormatMap = { [ConfigKey.SOURCE_PROJECT_CONTENT]: null, [ConfigKey.PARAMS]: null, @@ -68,7 +51,6 @@ export const browserFormatters: BrowserFormatMap = { [ConfigKey.JOURNEY_FILTERS_MATCH]: stringToJsonFormatter, [ConfigKey.JOURNEY_FILTERS_TAGS]: arrayToJsonFormatter, [ConfigKey.THROTTLING_CONFIG]: throttlingFormatter, - ...deprecatedZipUrlFormatters, ...commonFormatters, ...tlsFormatters, }; 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 9eca4aa70b216f..a03c54fc4f34e2 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 @@ -333,7 +333,7 @@ describe('formatSyntheticsPolicy', () => { __ui: { type: 'yaml', value: - '{"script_source":{"is_generated_script":false,"file_name":""},"is_zip_url_tls_enabled":false,"is_tls_enabled":false}', + '{"script_source":{"is_generated_script":false,"file_name":""},"is_tls_enabled":false}', }, config_id: { type: 'text', @@ -411,44 +411,6 @@ describe('formatSyntheticsPolicy', () => { type: 'text', value: '', }, - 'source.zip_url.folder': { - type: 'text', - value: '', - }, - 'source.zip_url.password': { - type: 'password', - value: '', - }, - 'source.zip_url.proxy_url': { - type: 'text', - value: '', - }, - 'source.zip_url.ssl.certificate': { - type: 'yaml', - }, - 'source.zip_url.ssl.certificate_authorities': { - type: 'yaml', - }, - 'source.zip_url.ssl.key': { - type: 'yaml', - }, - 'source.zip_url.ssl.key_passphrase': { - type: 'text', - }, - 'source.zip_url.ssl.supported_protocols': { - type: 'yaml', - }, - 'source.zip_url.ssl.verification_mode': { - type: 'text', - }, - 'source.zip_url.url': { - type: 'text', - value: '', - }, - 'source.zip_url.username': { - type: 'text', - value: '', - }, synthetics_args: { type: 'text', value: null, @@ -918,39 +880,6 @@ describe('formatSyntheticsPolicy', () => { 'source.project.content': { type: 'text', }, - 'source.zip_url.folder': { - type: 'text', - }, - 'source.zip_url.password': { - type: 'password', - }, - 'source.zip_url.proxy_url': { - type: 'text', - }, - 'source.zip_url.ssl.certificate': { - type: 'yaml', - }, - 'source.zip_url.ssl.certificate_authorities': { - type: 'yaml', - }, - 'source.zip_url.ssl.key': { - type: 'yaml', - }, - 'source.zip_url.ssl.key_passphrase': { - type: 'text', - }, - 'source.zip_url.ssl.supported_protocols': { - type: 'yaml', - }, - 'source.zip_url.ssl.verification_mode': { - type: 'text', - }, - 'source.zip_url.url': { - type: 'text', - }, - 'source.zip_url.username': { - type: 'text', - }, synthetics_args: { type: 'text', }, @@ -1147,10 +1076,6 @@ const testNewPolicy = { 'service.name': { type: 'text' }, timeout: { type: 'text' }, tags: { type: 'yaml' }, - 'source.zip_url.url': { type: 'text' }, - 'source.zip_url.username': { type: 'text' }, - 'source.zip_url.folder': { type: 'text' }, - 'source.zip_url.password': { type: 'password' }, 'source.inline.script': { type: 'yaml' }, 'source.project.content': { type: 'text' }, params: { type: 'yaml' }, @@ -1161,13 +1086,6 @@ const testNewPolicy = { 'throttling.config': { type: 'text' }, 'filter_journeys.tags': { type: 'yaml' }, 'filter_journeys.match': { type: 'text' }, - 'source.zip_url.ssl.certificate_authorities': { type: 'yaml' }, - 'source.zip_url.ssl.certificate': { type: 'yaml' }, - 'source.zip_url.ssl.key': { type: 'yaml' }, - 'source.zip_url.ssl.key_passphrase': { type: 'text' }, - '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: 'Fleet managed', type: 'text' }, id: { type: 'text' }, config_id: { type: 'text' }, @@ -1212,7 +1130,6 @@ const browserConfig: any = { playwright_options: '', __ui: { script_source: { is_generated_script: false, file_name: '' }, - is_zip_url_tls_enabled: false, is_tls_enabled: false, }, params: @@ -1221,11 +1138,6 @@ const browserConfig: any = { 'source.inline.script': 'step("Visit /users api route", async () => {\\n const response = await page.goto(\'https://nextjs-test-synthetics.vercel.app/api/users\');\\n expect(response.status()).toEqual(200);\\n});', 'source.project.content': '', - 'source.zip_url.url': '', - 'source.zip_url.username': '', - 'source.zip_url.password': '', - 'source.zip_url.folder': '', - 'source.zip_url.proxy_url': '', playwright_text_assertion: '', urls: '', screenshots: 'on', diff --git a/x-pack/plugins/synthetics/common/runtime_types/monitor_management/monitor_meta_data.ts b/x-pack/plugins/synthetics/common/runtime_types/monitor_management/monitor_meta_data.ts index da3ce0fab60212..5ef3c448e7e84e 100644 --- a/x-pack/plugins/synthetics/common/runtime_types/monitor_management/monitor_meta_data.ts +++ b/x-pack/plugins/synthetics/common/runtime_types/monitor_management/monitor_meta_data.ts @@ -14,7 +14,6 @@ const ScriptSourceCodec = t.interface({ export const MetadataCodec = t.partial({ is_tls_enabled: t.boolean, - is_zip_url_tls_enabled: t.boolean, script_source: ScriptSourceCodec, }); diff --git a/x-pack/plugins/synthetics/common/runtime_types/monitor_management/monitor_types.ts b/x-pack/plugins/synthetics/common/runtime_types/monitor_management/monitor_types.ts index 5cb78f45e1fdd5..2e639e360fd1a5 100644 --- a/x-pack/plugins/synthetics/common/runtime_types/monitor_management/monitor_types.ts +++ b/x-pack/plugins/synthetics/common/runtime_types/monitor_management/monitor_types.ts @@ -48,23 +48,6 @@ export const TLSCodec = t.intersection([TLSFieldsCodec, TLSSensitiveFieldsCodec] export type TLSFields = t.TypeOf; -// ZipUrlTLSFields -export const ZipUrlTLSFieldsCodec = t.partial({ - [ConfigKey.ZIP_URL_TLS_CERTIFICATE_AUTHORITIES]: t.string, - [ConfigKey.ZIP_URL_TLS_CERTIFICATE]: t.string, - [ConfigKey.ZIP_URL_TLS_VERIFICATION_MODE]: VerificationModeCodec, - [ConfigKey.ZIP_URL_TLS_VERSION]: t.array(TLSVersionCodec), -}); - -export const ZipUrlTLSSensitiveFieldsCodec = t.partial({ - [ConfigKey.ZIP_URL_TLS_KEY]: t.string, - [ConfigKey.ZIP_URL_TLS_KEY_PASSPHRASE]: t.string, -}); - -export const ZipUrlTLSCodec = t.intersection([ZipUrlTLSFieldsCodec, ZipUrlTLSSensitiveFieldsCodec]); - -export type ZipUrlTLSFields = t.TypeOf; - // CommonFields export const CommonFieldsCodec = t.intersection([ t.interface({ @@ -222,17 +205,12 @@ export const EncryptedBrowserSimpleFieldsCodec = t.intersection([ t.intersection([ t.interface({ [ConfigKey.METADATA]: MetadataCodec, - [ConfigKey.SOURCE_ZIP_URL]: t.string, - [ConfigKey.SOURCE_ZIP_FOLDER]: t.string, - [ConfigKey.SOURCE_ZIP_PROXY_URL]: t.string, }), t.partial({ [ConfigKey.PLAYWRIGHT_OPTIONS]: t.string, [ConfigKey.TEXT_ASSERTION]: t.string, }), ]), - ZipUrlTLSFieldsCodec, - ZipUrlTLSSensitiveFieldsCodec, CommonFieldsCodec, ]); @@ -240,13 +218,10 @@ export const BrowserSensitiveSimpleFieldsCodec = t.intersection([ t.interface({ [ConfigKey.SOURCE_INLINE]: t.string, [ConfigKey.SOURCE_PROJECT_CONTENT]: t.string, - [ConfigKey.SOURCE_ZIP_USERNAME]: t.string, - [ConfigKey.SOURCE_ZIP_PASSWORD]: t.string, [ConfigKey.PARAMS]: t.string, [ConfigKey.URLS]: t.union([t.string, t.null]), [ConfigKey.PORT]: t.union([t.number, t.null]), }), - ZipUrlTLSFieldsCodec, CommonFieldsCodec, ]); @@ -265,7 +240,6 @@ export const EncryptedBrowserAdvancedFieldsCodec = t.interface({ export const BrowserSimpleFieldsCodec = t.intersection([ EncryptedBrowserSimpleFieldsCodec, BrowserSensitiveSimpleFieldsCodec, - ZipUrlTLSSensitiveFieldsCodec, ]); export const BrowserSensitiveAdvancedFieldsCodec = t.interface({ diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/services/add_monitor.ts b/x-pack/plugins/synthetics/e2e/journeys/synthetics/services/add_monitor.ts index 90a16752441ef2..44053aa29ed26d 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/services/add_monitor.ts +++ b/x-pack/plugins/synthetics/e2e/journeys/synthetics/services/add_monitor.ts @@ -117,18 +117,12 @@ export const testDataMonitor = { playwright_options: '', __ui: { script_source: { is_generated_script: false, file_name: '' }, - is_zip_url_tls_enabled: false, }, params: '', 'url.port': null, 'source.inline.script': "step('Go to https://www.google.com', async () => {\n await page.goto('https://www.google.com');\n expect(await page.isVisible('text=Data')).toBeTruthy();\n });", 'source.project.content': '', - 'source.zip_url.url': '', - 'source.zip_url.username': '', - 'source.zip_url.password': '', - 'source.zip_url.folder': '', - 'source.zip_url.proxy_url': '', playwright_text_assertion: 'Data', urls: 'https://www.google.com', screenshots: 'on', diff --git a/x-pack/plugins/synthetics/e2e/tasks/import_monitors.ts b/x-pack/plugins/synthetics/e2e/tasks/import_monitors.ts index 2d28655da4e1be..f65d82a9933f43 100644 --- a/x-pack/plugins/synthetics/e2e/tasks/import_monitors.ts +++ b/x-pack/plugins/synthetics/e2e/tasks/import_monitors.ts @@ -35,7 +35,6 @@ export const importMonitors = async ({ playwright_options: '', __ui: { script_source: { is_generated_script: false, file_name: '' }, - is_zip_url_tls_enabled: false, is_tls_enabled: false, }, params: '', @@ -43,11 +42,6 @@ export const importMonitors = async ({ 'source.inline.script': "const username = 'diawar.khan.shewani+conduit@gmail.com';\nconst password = 'aNL2sTGRbNYauc8';\n// Goto https://demo.realworld.io/ and sign up for username and password\n\nconst articleTitle = 'Artile No. ' + Math.ceil(Math.random() * 1000);\n\nstep(\"Goto home page\", async () => {\n await page.goto('https://demo.realworld.io/');\n});\n\nstep(\"Goto login page\", async () => {\n await page.click('text=Sign in');\n});\n\nstep(\"Enter login credentials\", async () => {\n await page.fill('[placeholder=\"Email\"]', username);\n await page.fill('[placeholder=\"Password\"]', password);\n});\n\nstep(\"Sign in\", async () => {\n await page.click('button[type=submit]');\n});\n\nstep(\"Create article\", async () => {\n const articleSubject = 'Test article subject';\n const articleBody = 'This ariticle is created with **synthetics** for purely testing purposes.';\n\n await page.click('text=New Article');\n await page.fill('[placeholder=\"Article Title\"]', articleTitle);\n await page.fill('[placeholder=\"What\\'s this article about?\"]', articleSubject);\n await page.fill('textarea', articleBody);\n});\n\nstep(\"Publish article\", async () => {\n await page.click('text=Publish Article');\n await page.waitForNavigation();\n\n // Fail about 30% of random times\n const passFailText = Math.random() * 10 > 7 ? 'non-existent-text' : articleTitle ;\n await page.waitForSelector('text=' + articleTitle);\n});\n\nstep(\"Post 1st comment\", async() => {\n const firstCommentText = 'First comment!';\n await page.fill('[placeholder=\"Write a comment...\"]', firstCommentText);\n await page.click('text=Post Comment');\n await page.waitForSelector('text=' + firstCommentText);\n});", 'source.project.content': '', - 'source.zip_url.url': '', - 'source.zip_url.username': '', - 'source.zip_url.password': '', - 'source.zip_url.folder': '', - 'source.zip_url.proxy_url': '', urls: '', screenshots: 'on', synthetics_args: [], diff --git a/x-pack/plugins/synthetics/e2e/tasks/uptime_monitor.ndjson b/x-pack/plugins/synthetics/e2e/tasks/uptime_monitor.ndjson index bb8acca2400944..818bbfcefd5794 100644 --- a/x-pack/plugins/synthetics/e2e/tasks/uptime_monitor.ndjson +++ b/x-pack/plugins/synthetics/e2e/tasks/uptime_monitor.ndjson @@ -1,2 +1,2 @@ -{"attributes":{"__ui":{"is_tls_enabled":false,"is_zip_url_tls_enabled":false},"check.request.method":"GET","check.response.status":[],"enabled":true,"locations":[{"geo":{"lat":41.25,"lon":-95.86},"id":"us_central","label":"US Central","url":"https://us-central.synthetics.elastic.dev"}],"max_redirects":"0","name":"Test Monitor","proxy_url":"","response.include_body":"on_error","response.include_headers":true,"schedule":{"number":"3","unit":"m"},"service.name":"","tags":[],"timeout":"16","type":"http","urls":"https://www.google.com", "secrets": "{}"},"coreMigrationVersion":"8.1.0","id":"832b9980-7fba-11ec-b360-25a79ce3f496","references":[],"sort":[1643319958480,20371],"type":"synthetics-monitor","updated_at":"2022-01-27T21:45:58.480Z","version":"WzExOTg3ODYsMl0="} +{"attributes":{"__ui":{"is_tls_enabled":false},"check.request.method":"GET","check.response.status":[],"enabled":true,"locations":[{"geo":{"lat":41.25,"lon":-95.86},"id":"us_central","label":"US Central","url":"https://us-central.synthetics.elastic.dev"}],"max_redirects":"0","name":"Test Monitor","proxy_url":"","response.include_body":"on_error","response.include_headers":true,"schedule":{"number":"3","unit":"m"},"service.name":"","tags":[],"timeout":"16","type":"http","urls":"https://www.google.com", "secrets": "{}"},"coreMigrationVersion":"8.1.0","id":"832b9980-7fba-11ec-b360-25a79ce3f496","references":[],"sort":[1643319958480,20371],"type":"synthetics-monitor","updated_at":"2022-01-27T21:45:58.480Z","version":"WzExOTg3ODYsMl0="} {"excludedObjects":[],"excludedObjectsCount":0,"exportedCount":2,"missingRefCount":0,"missingReferences":[]} diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/defaults.test.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/defaults.test.tsx index 47c1ce7989ef07..70521c28983f7d 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/defaults.test.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/defaults.test.tsx @@ -44,17 +44,6 @@ describe('defaults', () => { 'service.name': '', 'source.inline.script': testScript, 'source.project.content': '', - 'source.zip_url.folder': '', - 'source.zip_url.password': '', - 'source.zip_url.proxy_url': '', - 'source.zip_url.ssl.certificate': undefined, - 'source.zip_url.ssl.certificate_authorities': undefined, - 'source.zip_url.ssl.key': undefined, - 'source.zip_url.ssl.key_passphrase': undefined, - 'source.zip_url.ssl.supported_protocols': undefined, - 'source.zip_url.ssl.verification_mode': undefined, - 'source.zip_url.url': '', - 'source.zip_url.username': '', 'ssl.certificate': '', 'ssl.certificate_authorities': '', 'ssl.key': '', @@ -117,17 +106,6 @@ describe('defaults', () => { }, 'source.inline.script': 'testScript', 'source.project.content': '', - 'source.zip_url.folder': '', - 'source.zip_url.password': '', - 'source.zip_url.proxy_url': '', - 'source.zip_url.ssl.certificate': undefined, - 'source.zip_url.ssl.certificate_authorities': undefined, - 'source.zip_url.ssl.key': undefined, - 'source.zip_url.ssl.key_passphrase': undefined, - 'source.zip_url.ssl.supported_protocols': undefined, - 'source.zip_url.ssl.verification_mode': undefined, - 'source.zip_url.url': '', - 'source.zip_url.username': '', 'ssl.certificate': '', 'ssl.certificate_authorities': '', 'ssl.key': '', diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/field_config.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/field_config.tsx index 110ac698e22f79..934a895c47d343 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/field_config.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/field_config.tsx @@ -68,7 +68,11 @@ import { FieldMap, FormLocation, } from '../types'; -import { AlertConfigKey, DEFAULT_BROWSER_ADVANCED_FIELDS } from '../constants'; +import { + AlertConfigKey, + DEFAULT_BROWSER_ADVANCED_FIELDS, + ALLOWED_SCHEDULES_IN_MINUTES, +} from '../constants'; import { getDefaultFormFields } from './defaults'; import { validate, validateHeaders, WHOLE_NUMBERS_ONLY, FLOATS_ONLY } from './validation'; @@ -90,16 +94,10 @@ const getScheduleContent = (value: number) => { } }; -const getScheduleConfig = (schedules: number[]) => { - return schedules.map((value) => ({ - value: `${value}`, - text: getScheduleContent(value), - })); -}; - -const BROWSER_SCHEDULES = getScheduleConfig([3, 5, 10, 15, 30, 60, 120, 240]); - -const LIGHTWEIGHT_SCHEDULES = getScheduleConfig([1, 3, 5, 10, 15, 30, 60]); +const SCHEDULES = ALLOWED_SCHEDULES_IN_MINUTES.map((value) => ({ + value, + text: getScheduleContent(parseInt(value, 10)), +})); export const MONITOR_TYPE_CONFIG = { [FormMonitorType.MULTISTEP]: { @@ -378,12 +376,10 @@ export const FIELD = (readOnly?: boolean): FieldMap => ({ defaultMessage: 'How often do you want to run this test? Higher frequencies will increase your total cost.', }), - dependencies: [ConfigKey.MONITOR_TYPE], - props: ({ dependencies }): EuiSelectProps => { - const [monitorType] = dependencies; + props: (): EuiSelectProps => { return { 'data-test-subj': 'syntheticsMonitorConfigSchedule', - options: monitorType === DataStream.BROWSER ? BROWSER_SCHEDULES : LIGHTWEIGHT_SCHEDULES, + options: SCHEDULES, disabled: readOnly, }; }, diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/formatter.test.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/formatter.test.tsx index 6a457d601802b4..6000b02cb7f873 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/formatter.test.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/formatter.test.tsx @@ -188,16 +188,10 @@ describe('format', () => { is_generated_script: false, file_name: '', }, - is_zip_url_tls_enabled: false, }, params: '', 'source.inline.script': '', 'source.project.content': '', - 'source.zip_url.url': '', - 'source.zip_url.username': '', - 'source.zip_url.password': '', - 'source.zip_url.folder': '', - 'source.zip_url.proxy_url': '', playwright_text_assertion: '', urls: '', screenshots: 'on', @@ -276,17 +270,6 @@ describe('format', () => { 'service.name': '', 'source.inline.script': script, 'source.project.content': '', - 'source.zip_url.folder': '', - 'source.zip_url.password': '', - 'source.zip_url.proxy_url': '', - 'source.zip_url.ssl.certificate': undefined, - 'source.zip_url.ssl.certificate_authorities': undefined, - 'source.zip_url.ssl.key': undefined, - 'source.zip_url.ssl.key_passphrase': undefined, - 'source.zip_url.ssl.supported_protocols': undefined, - 'source.zip_url.ssl.verification_mode': undefined, - 'source.zip_url.url': '', - 'source.zip_url.username': '', 'ssl.certificate': '', 'ssl.certificate_authorities': '', 'ssl.key': '', diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/validation.test.ts b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/validation.test.ts index fa91bd457671dc..4b4e524c9f3b01 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/validation.test.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/validation.test.ts @@ -49,10 +49,7 @@ describe('[Monitor Management] validation', () => { }); }); - describe.each([ - [ConfigKey.SOURCE_INLINE, 'step(() => {});'], - [ConfigKey.SOURCE_ZIP_URL, 'https://test.zip'], - ])('Browser', (configKey, value) => { + describe.each([[ConfigKey.SOURCE_INLINE, 'step(() => {});']])('Browser', (configKey, value) => { const browserProps: Partial = { ...commonPropsValid, [ConfigKey.MONITOR_TYPE]: DataStream.BROWSER, diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/validation.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/validation.tsx index 9f06395bf1a199..cc03228d755bea 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/validation.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/validation.tsx @@ -147,14 +147,7 @@ const validateThrottleValue = (speed: string | undefined, allowZero?: boolean) = const validateBrowser: ValidationLibrary = { ...validateCommon, - [ConfigKey.SOURCE_ZIP_URL]: ({ - [ConfigKey.SOURCE_ZIP_URL]: zipUrl, - [ConfigKey.SOURCE_INLINE]: inlineScript, - }) => !zipUrl && !inlineScript, - [ConfigKey.SOURCE_INLINE]: ({ - [ConfigKey.SOURCE_ZIP_URL]: zipUrl, - [ConfigKey.SOURCE_INLINE]: inlineScript, - }) => !zipUrl && !inlineScript, + [ConfigKey.SOURCE_INLINE]: ({ [ConfigKey.SOURCE_INLINE]: inlineScript }) => !inlineScript, [ConfigKey.DOWNLOAD_SPEED]: ({ [ConfigKey.DOWNLOAD_SPEED]: downloadSpeed }) => validateThrottleValue(downloadSpeed), [ConfigKey.UPLOAD_SPEED]: ({ [ConfigKey.UPLOAD_SPEED]: uploadSpeed }) => diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/utils/testing/__mocks__/synthetics_store.mock.ts b/x-pack/plugins/synthetics/public/apps/synthetics/utils/testing/__mocks__/synthetics_store.mock.ts index 051f0731c62e63..5100b8e998e44d 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/utils/testing/__mocks__/synthetics_store.mock.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/utils/testing/__mocks__/synthetics_store.mock.ts @@ -416,7 +416,6 @@ function getMonitorDetailsMockSlice() { playwright_options: '', __ui: { script_source: { is_generated_script: false, file_name: '' }, - is_zip_url_tls_enabled: false, is_tls_enabled: false, }, params: '', @@ -424,11 +423,6 @@ function getMonitorDetailsMockSlice() { 'source.inline.script': "step('Goto one pixel image', async () => {\\n await page.goto('data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');\\n});", 'source.project.content': '', - 'source.zip_url.url': '', - 'source.zip_url.username': '', - 'source.zip_url.password': '', - 'source.zip_url.folder': '', - 'source.zip_url.proxy_url': '', urls: 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', screenshots: 'on', synthetics_args: [], diff --git a/x-pack/plugins/synthetics/server/alert_rules/status_rule/status_rule_executor.test.ts b/x-pack/plugins/synthetics/server/alert_rules/status_rule/status_rule_executor.test.ts index d95883f78b7b17..367c27c4bca082 100644 --- a/x-pack/plugins/synthetics/server/alert_rules/status_rule/status_rule_executor.test.ts +++ b/x-pack/plugins/synthetics/server/alert_rules/status_rule/status_rule_executor.test.ts @@ -161,12 +161,8 @@ const testMonitors = [ playwright_options: '', __ui: { script_source: { is_generated_script: false, file_name: '' }, - is_zip_url_tls_enabled: false, }, 'url.port': null, - 'source.zip_url.url': '', - 'source.zip_url.folder': '', - 'source.zip_url.proxy_url': '', playwright_text_assertion: '', urls: 'https://www.google.com', screenshots: 'on', diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/8.6.0.test.ts b/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/8.6.0.test.ts index 68e3416174c8fd..3f046a5ed31159 100644 --- a/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/8.6.0.test.ts +++ b/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/8.6.0.test.ts @@ -37,7 +37,7 @@ const monitor850UI = { origin: 'ui', journey_id: '', id: '', - __ui: { is_tls_enabled: false, is_zip_url_tls_enabled: false }, + __ui: { is_tls_enabled: false }, urls: 'https://elastic.co', max_redirects: '0', 'url.port': null, diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/8.6.0.ts b/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/8.6.0.ts index 1302e3bc203b81..cce87ec58f649b 100644 --- a/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/8.6.0.ts +++ b/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/8.6.0.ts @@ -7,7 +7,7 @@ import { EncryptedSavedObjectsPluginSetup } from '@kbn/encrypted-saved-objects-plugin/server'; import { SavedObjectUnsanitizedDoc } from '@kbn/core/server'; import { ConfigKey, SyntheticsMonitorWithSecrets } from '../../../../../../common/runtime_types'; -import { SYNTHETICS_MONITOR_ENCRYPTED_TYPE } from '../../synthetics_monitor'; +import { LEGACY_SYNTHETICS_MONITOR_ENCRYPTED_TYPE } from '../../synthetics_monitor'; export const migration860 = (encryptedSavedObjects: EncryptedSavedObjectsPluginSetup) => { return encryptedSavedObjects.createMigration< @@ -32,6 +32,6 @@ export const migration860 = (encryptedSavedObjects: EncryptedSavedObjectsPluginS }, }; }, - migratedType: SYNTHETICS_MONITOR_ENCRYPTED_TYPE, + migratedType: LEGACY_SYNTHETICS_MONITOR_ENCRYPTED_TYPE, }); }; diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/8.8.0.test.ts b/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/8.8.0.test.ts new file mode 100644 index 00000000000000..229a45eae14c55 --- /dev/null +++ b/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/8.8.0.test.ts @@ -0,0 +1,382 @@ +/* + * 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 { encryptedSavedObjectsMock } from '@kbn/encrypted-saved-objects-plugin/server/mocks'; +import { migration880 } from './8.8.0'; +import { migrationMocks } from '@kbn/core/server/mocks'; +import { ConfigKey, ScheduleUnit } from '../../../../../../common/runtime_types'; +import { ALLOWED_SCHEDULES_IN_MINUTES } from '../../../../../../common/constants/monitor_defaults'; +import { + browserUI, + browserProject, + browserUptimeUI, + tcpUptimeUI, + icmpUptimeUI, + httpUptimeUI, +} from './test_fixtures/8.7.0'; + +const context = migrationMocks.createContext(); +const encryptedSavedObjectsSetup = encryptedSavedObjectsMock.createSetup(); + +describe('Monitor migrations v8.7.0 -> v8.8.0', () => { + const testSchedules = [ + ['4', '3'], + ['7', '5'], + ['8', '10'], + ['9.5', '10'], + ['12', '10'], + ['13', '15'], + ['16', '15'], + ['18', '20'], + ['21', '20'], + ['25', '20'], + ['26', '30'], + ['31', '30'], + ['45', '30'], + ['46', '60'], + ['61', '60'], + ['90', '60'], + ['91', '120'], + ['121', '120'], + ['195', '240'], + ['600', '240'], + ]; + + beforeEach(() => { + jest.resetAllMocks(); + encryptedSavedObjectsSetup.createMigration.mockImplementation(({ migration }) => migration); + }); + + describe('config hash', () => { + it('sets config hash back to empty string', () => { + expect(browserProject.attributes[ConfigKey.CONFIG_HASH]).toBeTruthy(); + const actual = migration880(encryptedSavedObjectsSetup)(browserProject, context); + expect(actual.attributes[ConfigKey.CONFIG_HASH]).toEqual(''); + }); + }); + + describe('zip url deprecation', () => { + it('removes all top level zip url fields for synthetics UI monitor', () => { + expect( + Object.keys(browserUI.attributes).some((key: string) => key.includes('zip_url')) + ).toEqual(true); + const actual = migration880(encryptedSavedObjectsSetup)(browserUI, context); + expect(actual).toEqual({ + attributes: { + __ui: { + script_source: { + file_name: '', + is_generated_script: false, + }, + }, + alert: { + status: { + enabled: true, + }, + }, + config_id: '311cf324-2fc9-4453-9ba5-5e745fd81722', + enabled: true, + 'filter_journeys.match': '', + 'filter_journeys.tags': [], + form_monitor_type: 'multistep', + hash: '', + id: '311cf324-2fc9-4453-9ba5-5e745fd81722', + ignore_https_errors: false, + journey_id: '', + locations: [ + { + geo: { + lat: 41.25, + lon: -95.86, + }, + id: 'us_central', + isServiceManaged: true, + label: 'North America - US Central', + }, + ], + name: 'https://elastic.co', + namespace: 'default', + origin: 'ui', + playwright_options: '', + playwright_text_assertion: '', + project_id: '', + revision: 1, + schedule: { + number: '10', + unit: 'm', + }, + screenshots: 'on', + secrets: + '{"params":"","source.inline.script":"step(\'Go to https://elastic.co\', async () => {\\n await page.goto(\'https://elastic.co\');\\n});","source.project.content":"","synthetics_args":[],"ssl.key":"","ssl.key_passphrase":""}', + 'service.name': '', + 'ssl.certificate': '', + 'ssl.certificate_authorities': '', + 'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'], + 'ssl.verification_mode': 'full', + tags: [], + 'throttling.config': '5d/3u/20l', + 'throttling.download_speed': '5', + 'throttling.is_enabled': true, + 'throttling.latency': '20', + 'throttling.upload_speed': '3', + timeout: null, + type: 'browser', + 'url.port': null, + urls: 'https://elastic.co', + }, + coreMigrationVersion: '8.8.0', + created_at: '2023-03-31T20:31:24.177Z', + id: '311cf324-2fc9-4453-9ba5-5e745fd81722', + references: [], + type: 'synthetics-monitor', + typeMigrationVersion: '8.6.0', + updated_at: '2023-03-31T20:31:24.177Z', + }); + expect(Object.keys(actual.attributes).some((key: string) => key.includes('zip_url'))).toEqual( + false + ); + }); + + it.each([browserUptimeUI, browserProject])( + 'removes all top level zip url fields for Uptime and Project monitors', + (testMonitor) => { + expect( + Object.keys(testMonitor.attributes).some((key: string) => key.includes('zip_url')) + ).toEqual(true); + const actual = migration880(encryptedSavedObjectsSetup)(testMonitor, context); + expect( + Object.keys(actual.attributes).some((key: string) => key.includes('zip_url')) + ).toEqual(false); + } + ); + + it('returns the original doc if an error occurs removing zip url fields', () => { + const invalidTestMonitor = { + ...browserUI, + attributes: { + ...browserUI.attributes, + name: null, + }, + }; + // @ts-ignore specificially testing monitors with invalid values + const actual = migration880(encryptedSavedObjectsSetup)(invalidTestMonitor, context); + expect(actual).toEqual(invalidTestMonitor); + }); + }); + + describe('schedule migration', () => { + it.each(testSchedules)( + 'handles migrating schedule with invalid schedules - browser', + (previous, migrated) => { + const testMonitorWithSchedule = { + ...browserUptimeUI, + attributes: { + ...browserUptimeUI.attributes, + [ConfigKey.SCHEDULE]: { + unit: ScheduleUnit.MINUTES, + number: previous, + }, + }, + }; + expect( + ALLOWED_SCHEDULES_IN_MINUTES.includes( + testMonitorWithSchedule.attributes[ConfigKey.SCHEDULE].number + ) + ).toBe(false); + const actual = migration880(encryptedSavedObjectsSetup)(testMonitorWithSchedule, context); + expect(actual.attributes[ConfigKey.SCHEDULE].number).toEqual(migrated); + expect( + ALLOWED_SCHEDULES_IN_MINUTES.includes(actual.attributes[ConfigKey.SCHEDULE].number) + ).toBe(true); + expect(actual.attributes[ConfigKey.SCHEDULE].unit).toEqual(ScheduleUnit.MINUTES); + } + ); + + it.each(ALLOWED_SCHEDULES_IN_MINUTES)( + 'handles migrating schedule with valid schedules - browser', + (validSchedule) => { + const testMonitorWithSchedule = { + ...browserUptimeUI, + attributes: { + ...browserUptimeUI.attributes, + [ConfigKey.SCHEDULE]: { + unit: ScheduleUnit.MINUTES, + number: validSchedule, + }, + }, + }; + expect( + ALLOWED_SCHEDULES_IN_MINUTES.includes( + testMonitorWithSchedule.attributes[ConfigKey.SCHEDULE].number + ) + ).toBe(true); + const actual = migration880(encryptedSavedObjectsSetup)(testMonitorWithSchedule, context); + expect(actual.attributes[ConfigKey.SCHEDULE].number).toEqual(validSchedule); + expect( + ALLOWED_SCHEDULES_IN_MINUTES.includes(actual.attributes[ConfigKey.SCHEDULE].number) + ).toBe(true); + expect(actual.attributes[ConfigKey.SCHEDULE].unit).toEqual(ScheduleUnit.MINUTES); + } + ); + + it.each(ALLOWED_SCHEDULES_IN_MINUTES)( + 'handles migrating schedule with valid schedules - http', + (validSchedule) => { + const testMonitorWithSchedule = { + ...httpUptimeUI, + attributes: { + ...httpUptimeUI.attributes, + [ConfigKey.SCHEDULE]: { + unit: ScheduleUnit.MINUTES, + number: validSchedule, + }, + }, + }; + expect( + ALLOWED_SCHEDULES_IN_MINUTES.includes( + testMonitorWithSchedule.attributes[ConfigKey.SCHEDULE].number + ) + ).toBe(true); + const actual = migration880(encryptedSavedObjectsSetup)(testMonitorWithSchedule, context); + expect(actual.attributes[ConfigKey.SCHEDULE].number).toEqual(validSchedule); + expect( + ALLOWED_SCHEDULES_IN_MINUTES.includes(actual.attributes[ConfigKey.SCHEDULE].number) + ).toBe(true); + expect(actual.attributes[ConfigKey.SCHEDULE].unit).toEqual(ScheduleUnit.MINUTES); + } + ); + + it.each(ALLOWED_SCHEDULES_IN_MINUTES)( + 'handles migrating schedule with valid schedules - tcp', + (validSchedule) => { + const testMonitorWithSchedule = { + ...tcpUptimeUI, + attributes: { + ...tcpUptimeUI.attributes, + [ConfigKey.SCHEDULE]: { + unit: ScheduleUnit.MINUTES, + number: validSchedule, + }, + }, + }; + expect( + ALLOWED_SCHEDULES_IN_MINUTES.includes( + testMonitorWithSchedule.attributes[ConfigKey.SCHEDULE].number + ) + ).toBe(true); + const actual = migration880(encryptedSavedObjectsSetup)(testMonitorWithSchedule, context); + expect(actual.attributes[ConfigKey.SCHEDULE].number).toEqual(validSchedule); + expect( + ALLOWED_SCHEDULES_IN_MINUTES.includes(actual.attributes[ConfigKey.SCHEDULE].number) + ).toBe(true); + expect(actual.attributes[ConfigKey.SCHEDULE].unit).toEqual(ScheduleUnit.MINUTES); + } + ); + + it.each(ALLOWED_SCHEDULES_IN_MINUTES)( + 'handles migrating schedule with valid schedules - icmp', + (validSchedule) => { + const testMonitorWithSchedule = { + ...icmpUptimeUI, + attributes: { + ...icmpUptimeUI.attributes, + [ConfigKey.SCHEDULE]: { + unit: ScheduleUnit.MINUTES, + number: validSchedule, + }, + }, + }; + expect( + ALLOWED_SCHEDULES_IN_MINUTES.includes( + testMonitorWithSchedule.attributes[ConfigKey.SCHEDULE].number + ) + ).toBe(true); + const actual = migration880(encryptedSavedObjectsSetup)(testMonitorWithSchedule, context); + expect(actual.attributes[ConfigKey.SCHEDULE].number).toEqual(validSchedule); + expect( + ALLOWED_SCHEDULES_IN_MINUTES.includes(actual.attributes[ConfigKey.SCHEDULE].number) + ).toBe(true); + expect(actual.attributes[ConfigKey.SCHEDULE].unit).toEqual(ScheduleUnit.MINUTES); + } + ); + + it.each(ALLOWED_SCHEDULES_IN_MINUTES)( + 'handles migrating schedule with valid schedules - project', + (validSchedule) => { + const testMonitorWithSchedule = { + ...browserProject, + attributes: { + ...browserProject.attributes, + [ConfigKey.SCHEDULE]: { + unit: ScheduleUnit.MINUTES, + number: validSchedule, + }, + }, + }; + expect( + ALLOWED_SCHEDULES_IN_MINUTES.includes( + testMonitorWithSchedule.attributes[ConfigKey.SCHEDULE].number + ) + ).toBe(true); + const actual = migration880(encryptedSavedObjectsSetup)(testMonitorWithSchedule, context); + expect(actual.attributes[ConfigKey.SCHEDULE].number).toEqual(validSchedule); + expect( + ALLOWED_SCHEDULES_IN_MINUTES.includes(actual.attributes[ConfigKey.SCHEDULE].number) + ).toBe(true); + expect(actual.attributes[ConfigKey.SCHEDULE].unit).toEqual(ScheduleUnit.MINUTES); + } + ); + + // handles invalid values stored in saved object + it.each([null, undefined, {}, []])( + 'handles migrating schedule with invalid values - browser', + (invalidSchedule) => { + const testMonitorWithSchedule = { + ...browserUptimeUI, + attributes: { + ...browserUptimeUI.attributes, + [ConfigKey.SCHEDULE]: { + unit: ScheduleUnit.MINUTES, + number: invalidSchedule, + }, + }, + }; + // @ts-ignore specificially testing monitors with invalid values for full coverage + const actual = migration880(encryptedSavedObjectsSetup)(testMonitorWithSchedule, context); + expect(actual.attributes[ConfigKey.SCHEDULE].number).toEqual('1'); + expect( + ALLOWED_SCHEDULES_IN_MINUTES.includes(actual.attributes[ConfigKey.SCHEDULE].number) + ).toBe(true); + expect(actual.attributes[ConfigKey.SCHEDULE].unit).toEqual(ScheduleUnit.MINUTES); + } + ); + + // handles invalid values stored in saved object + it.each([ + [5, '5'], + [4, '3'], + [2.5, '3'], + ])('handles migrating schedule numeric values - browser', (invalidSchedule, migrated) => { + const testMonitorWithSchedule = { + ...browserUptimeUI, + attributes: { + ...browserUptimeUI.attributes, + [ConfigKey.SCHEDULE]: { + unit: ScheduleUnit.MINUTES, + number: invalidSchedule, + }, + }, + }; + // @ts-ignore specificially testing monitors with invalid values for full coverage + const actual = migration880(encryptedSavedObjectsSetup)(testMonitorWithSchedule, context); + expect(actual.attributes[ConfigKey.SCHEDULE].number).toEqual(migrated); + expect( + ALLOWED_SCHEDULES_IN_MINUTES.includes(actual.attributes[ConfigKey.SCHEDULE].number) + ).toBe(true); + expect(actual.attributes[ConfigKey.SCHEDULE].unit).toEqual(ScheduleUnit.MINUTES); + }); + }); +}); diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/8.8.0.ts b/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/8.8.0.ts new file mode 100644 index 00000000000000..bd15dae2d3c2cb --- /dev/null +++ b/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/8.8.0.ts @@ -0,0 +1,115 @@ +/* + * 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 { EncryptedSavedObjectsPluginSetup } from '@kbn/encrypted-saved-objects-plugin/server'; +import { SavedObjectUnsanitizedDoc } from '@kbn/core/server'; +import { + ConfigKey, + SyntheticsMonitorWithSecrets, + MonitorFields, + BrowserFields, + ScheduleUnit, +} from '../../../../../../common/runtime_types'; +import { ALLOWED_SCHEDULES_IN_MINUTES } from '../../../../../../common/constants/monitor_defaults'; +import { + LEGACY_SYNTHETICS_MONITOR_ENCRYPTED_TYPE, + SYNTHETICS_MONITOR_ENCRYPTED_TYPE, +} from '../../synthetics_monitor'; +import { validateMonitor } from '../../../../../routes/monitor_cruds/monitor_validation'; +import { + normalizeMonitorSecretAttributes, + formatSecrets, +} from '../../../../../synthetics_service/utils/secrets'; + +export const migration880 = (encryptedSavedObjects: EncryptedSavedObjectsPluginSetup) => { + return encryptedSavedObjects.createMigration< + SyntheticsMonitorWithSecrets, + SyntheticsMonitorWithSecrets + >({ + isMigrationNeededPredicate: function shouldBeMigrated( + doc + ): doc is SavedObjectUnsanitizedDoc { + return true; + }, + migration: ( + doc: SavedObjectUnsanitizedDoc, + logger + ): SavedObjectUnsanitizedDoc => { + let migrated = doc; + migrated = { + ...migrated, + attributes: { + ...migrated.attributes, + [ConfigKey.SCHEDULE]: { + number: getNearestSupportedSchedule(migrated.attributes[ConfigKey.SCHEDULE].number), + unit: ScheduleUnit.MINUTES, + }, + // when any action to change a project monitor configuration is taken + // outside of the synthetics agent cli, we should set the config hash back + // to an empty string so that the project monitors configuration + // will be updated on next push + [ConfigKey.CONFIG_HASH]: '', + }, + }; + if (migrated.attributes.type === 'browser') { + try { + const normalizedMonitorAttributes = normalizeMonitorSecretAttributes(migrated.attributes); + migrated = { + ...migrated, + attributes: omitZipUrlFields(normalizedMonitorAttributes as BrowserFields), + }; + } catch (e) { + logger.log.warn( + `Failed to remove ZIP URL fields from legacy Synthetics monitor: ${e.message}` + ); + return migrated; + } + } + return migrated; + }, + inputType: LEGACY_SYNTHETICS_MONITOR_ENCRYPTED_TYPE, + migratedType: SYNTHETICS_MONITOR_ENCRYPTED_TYPE, + }); +}; + +const getNearestSupportedSchedule = (currentSchedule: string): string => { + try { + const closest = ALLOWED_SCHEDULES_IN_MINUTES.reduce(function (prev, curr) { + const supportedSchedule = parseFloat(curr); + const currSchedule = parseFloat(currentSchedule); + const prevSupportedSchedule = parseFloat(prev); + return Math.abs(supportedSchedule - currSchedule) < + Math.abs(prevSupportedSchedule - currSchedule) + ? curr + : prev; + }); + + return closest; + } catch { + return ALLOWED_SCHEDULES_IN_MINUTES[0]; + } +}; + +const omitZipUrlFields = (fields: BrowserFields) => { + const metadata = fields[ConfigKey.METADATA]; + const updatedMetadata = omit(metadata || {}, 'is_zip_url_tls_enabled'); + // will return only fields that match the current type defs, which omit + // zip url fields + + const validationResult = validateMonitor({ + ...fields, + [ConfigKey.METADATA]: updatedMetadata, + } as MonitorFields); + + if (!validationResult.valid || !validationResult.decodedMonitor) { + throw new Error( + `Monitor is not valid: ${validationResult.reason}. ${validationResult.details}` + ); + } + + return formatSecrets(validationResult.decodedMonitor); +}; diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/index.ts b/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/index.ts index bb26f51a603e68..b200e7b09b3894 100644 --- a/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/index.ts +++ b/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/index.ts @@ -6,7 +6,9 @@ */ import { migration860 } from './8.6.0'; +import { migration880 } from './8.8.0'; export const monitorMigrations = { '8.6.0': migration860, + '8.8.0': migration880, }; diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/test_fixtures/8.7.0.ts b/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/test_fixtures/8.7.0.ts new file mode 100644 index 00000000000000..75bc3d0452ba70 --- /dev/null +++ b/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/migrations/monitors/test_fixtures/8.7.0.ts @@ -0,0 +1,659 @@ +/* + * 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 { SavedObjectUnsanitizedDoc } from '@kbn/core/server'; +import { SyntheticsMonitorWithSecrets } from '../../../../../../../common/runtime_types'; + +export const browserUI = { + type: 'synthetics-monitor', + id: '311cf324-2fc9-4453-9ba5-5e745fd81722', + attributes: { + type: 'browser', + form_monitor_type: 'multistep', + enabled: true, + alert: { status: { enabled: true } }, + schedule: { unit: 'm', number: '10' }, + 'service.name': '', + config_id: '311cf324-2fc9-4453-9ba5-5e745fd81722', + tags: [], + timeout: null, + name: 'https://elastic.co', + locations: [ + { + id: 'us_central', + label: 'North America - US Central', + geo: { lat: 41.25, lon: -95.86 }, + isServiceManaged: true, + }, + ], + namespace: 'default', + origin: 'ui', + journey_id: '', + hash: '', + id: '311cf324-2fc9-4453-9ba5-5e745fd81722', + project_id: '', + playwright_options: '', + __ui: { + script_source: { is_generated_script: false, file_name: '' }, + is_zip_url_tls_enabled: false, + }, + 'url.port': null, + 'source.zip_url.url': '', + 'source.zip_url.folder': '', + 'source.zip_url.proxy_url': '', + playwright_text_assertion: '', + urls: 'https://elastic.co', + screenshots: 'on', + 'filter_journeys.match': '', + 'filter_journeys.tags': [], + ignore_https_errors: false, + 'throttling.is_enabled': true, + 'throttling.download_speed': '5', + 'throttling.upload_speed': '3', + 'throttling.latency': '20', + 'throttling.config': '5d/3u/20l', + 'ssl.certificate_authorities': '', + 'ssl.certificate': '', + 'ssl.verification_mode': 'full', + 'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'], + revision: 1, + secrets: + '{"params":"","source.inline.script":"step(\'Go to https://elastic.co\', async () => {\\n await page.goto(\'https://elastic.co\');\\n});","source.project.content":"","source.zip_url.username":"","source.zip_url.password":"","synthetics_args":[],"ssl.key":"","ssl.key_passphrase":""}', + }, + references: [], + coreMigrationVersion: '8.8.0', + updated_at: '2023-03-31T20:31:24.177Z', + created_at: '2023-03-31T20:31:24.177Z', + typeMigrationVersion: '8.6.0', +} as SavedObjectUnsanitizedDoc; +export const browserSinglePageUI = { + type: 'synthetics-monitor', + id: '7a72e681-6033-444e-b402-bddbe4a9fc4e', + attributes: { + type: 'browser', + form_monitor_type: 'single', + enabled: true, + alert: { status: { enabled: true } }, + schedule: { unit: 'm', number: '10' }, + 'service.name': '', + config_id: '7a72e681-6033-444e-b402-bddbe4a9fc4e', + tags: [], + timeout: null, + name: 'https://google.com', + locations: [{ label: 'North America - US Central', id: 'us_central', isServiceManaged: true }], + namespace: 'default', + origin: 'ui', + journey_id: '', + hash: '', + id: '7a72e681-6033-444e-b402-bddbe4a9fc4e', + project_id: '', + playwright_options: '', + __ui: { + script_source: { is_generated_script: false, file_name: '' }, + is_zip_url_tls_enabled: false, + }, + 'url.port': null, + 'source.zip_url.url': '', + 'source.zip_url.folder': '', + 'source.zip_url.proxy_url': '', + playwright_text_assertion: 'Google', + urls: 'https://google.com', + screenshots: 'on', + 'filter_journeys.match': '', + 'filter_journeys.tags': [], + ignore_https_errors: false, + 'throttling.is_enabled': true, + 'throttling.download_speed': '5', + 'throttling.upload_speed': '3', + 'throttling.latency': '20', + 'throttling.config': '5d/3u/20l', + 'ssl.certificate_authorities': '', + 'ssl.certificate': '', + 'ssl.verification_mode': 'full', + 'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'], + revision: 1, + secrets: + '{"params":"","source.inline.script":"step(\'Go to https://google.com\', async () => {\\n await page.goto(\'https://google.com\');\\n expect(await page.isVisible(\'text=Google\')).toBeTruthy();\\n });","source.project.content":"","source.zip_url.username":"","source.zip_url.password":"","synthetics_args":[],"ssl.key":"","ssl.key_passphrase":""}', + }, + references: [], + coreMigrationVersion: '8.8.0', + updated_at: '2023-03-31T20:32:01.498Z', + created_at: '2023-03-31T20:32:01.498Z', + typeMigrationVersion: '8.6.0', +} as SavedObjectUnsanitizedDoc; +export const httpUI = { + type: 'synthetics-monitor', + id: '8f4ad634-205b-440b-80c6-27aa6ef57bba', + attributes: { + type: 'http', + form_monitor_type: 'http', + enabled: true, + alert: { status: { enabled: true } }, + schedule: { number: '3', unit: 'm' }, + 'service.name': '', + config_id: '8f4ad634-205b-440b-80c6-27aa6ef57bba', + tags: [], + timeout: '16', + name: 'https://github.com', + locations: [{ label: 'North America - US Central', id: 'us_central', isServiceManaged: true }], + namespace: 'default', + origin: 'ui', + journey_id: '', + hash: '', + id: '8f4ad634-205b-440b-80c6-27aa6ef57bba', + __ui: { is_tls_enabled: false }, + urls: 'https://github.com', + max_redirects: '0', + 'url.port': null, + proxy_url: '', + 'response.include_body': 'on_error', + 'response.include_headers': true, + 'check.response.status': [], + 'check.request.method': 'GET', + 'ssl.certificate_authorities': '', + 'ssl.certificate': '', + 'ssl.verification_mode': 'full', + 'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'], + revision: 1, + secrets: + '{"password":"","check.request.body":{"type":"text","value":""},"check.request.headers":{},"check.response.body.negative":[],"check.response.body.positive":[],"check.response.headers":{},"ssl.key":"","ssl.key_passphrase":"","username":""}', + }, + references: [], + coreMigrationVersion: '8.8.0', + updated_at: '2023-03-31T20:32:14.362Z', + created_at: '2023-03-31T20:32:14.362Z', + typeMigrationVersion: '8.6.0', +} as SavedObjectUnsanitizedDoc; +export const tcpUI = { + type: 'synthetics-monitor', + id: 'b56a8fab-9a69-4435-b368-cc4fe6cdc6b0', + attributes: { + type: 'tcp', + form_monitor_type: 'tcp', + enabled: true, + alert: { status: { enabled: true } }, + schedule: { number: '3', unit: 'm' }, + 'service.name': '', + config_id: 'b56a8fab-9a69-4435-b368-cc4fe6cdc6b0', + tags: [], + timeout: '16', + name: 'smtp.gmail.com:587', + locations: [{ label: 'North America - US Central', id: 'us_central', isServiceManaged: true }], + namespace: 'default', + origin: 'ui', + journey_id: '', + hash: '', + id: 'b56a8fab-9a69-4435-b368-cc4fe6cdc6b0', + __ui: { is_tls_enabled: false }, + hosts: 'smtp.gmail.com:587', + urls: '', + 'url.port': null, + proxy_url: '', + proxy_use_local_resolver: false, + 'ssl.certificate_authorities': '', + 'ssl.certificate': '', + 'ssl.verification_mode': 'full', + 'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'], + revision: 1, + secrets: '{"check.send":"","check.receive":"","ssl.key":"","ssl.key_passphrase":""}', + }, + references: [], + coreMigrationVersion: '8.8.0', + updated_at: '2023-03-31T20:32:27.678Z', + created_at: '2023-03-31T20:32:27.678Z', + typeMigrationVersion: '8.6.0', +} as SavedObjectUnsanitizedDoc; +const icmpUI = { + type: 'synthetics-monitor', + id: '1b625301-fe0b-46c0-9980-21347c58a6f8', + attributes: { + type: 'icmp', + form_monitor_type: 'icmp', + enabled: true, + alert: { status: { enabled: true } }, + schedule: { number: '3', unit: 'm' }, + 'service.name': '', + config_id: '1b625301-fe0b-46c0-9980-21347c58a6f8', + tags: [], + timeout: '16', + name: '1.1.1.1', + locations: [{ label: 'North America - US Central', id: 'us_central', isServiceManaged: true }], + namespace: 'default', + origin: 'ui', + journey_id: '', + hash: '', + id: '1b625301-fe0b-46c0-9980-21347c58a6f8', + hosts: '1.1.1.1', + wait: '1', + revision: 1, + secrets: '{}', + }, + references: [], + coreMigrationVersion: '8.8.0', + updated_at: '2023-03-31T20:32:39.147Z', + created_at: '2023-03-31T20:32:39.147Z', + typeMigrationVersion: '8.6.0', +} as SavedObjectUnsanitizedDoc; +export const browserUptimeUI = { + type: 'synthetics-monitor', + id: '9bf12063-271f-47b1-9121-db1d14a71bb3', + attributes: { + type: 'browser', + form_monitor_type: 'multistep', + enabled: true, + alert: { status: { enabled: true } }, + schedule: { number: '240', unit: 'm' }, + 'service.name': '', + config_id: '9bf12063-271f-47b1-9121-db1d14a71bb3', + tags: [], + timeout: null, + name: 'A browser monitor with an invalid schedule 600', + locations: [ + { + id: 'us_central', + label: 'North America - US Central', + geo: { lat: 41.25, lon: -95.86 }, + isServiceManaged: true, + }, + ], + namespace: 'default', + origin: 'ui', + journey_id: '', + hash: '', + id: '9bf12063-271f-47b1-9121-db1d14a71bb3', + project_id: '', + playwright_options: '', + __ui: { + script_source: { is_generated_script: false, file_name: '' }, + is_zip_url_tls_enabled: false, + is_tls_enabled: false, + }, + 'url.port': null, + 'source.zip_url.url': '', + 'source.zip_url.folder': '', + 'source.zip_url.proxy_url': '', + playwright_text_assertion: '', + urls: '', + screenshots: 'on', + 'filter_journeys.match': '', + 'filter_journeys.tags': [], + ignore_https_errors: false, + 'throttling.is_enabled': true, + 'throttling.download_speed': '5', + 'throttling.upload_speed': '3', + 'throttling.latency': '20', + 'throttling.config': '5d/3u/20l', + 'ssl.certificate_authorities': '', + 'ssl.certificate': '', + 'ssl.verification_mode': 'full', + 'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'], + revision: 1, + secrets: + '{"params":"","source.inline.script":"lkjelre","source.project.content":"","source.zip_url.username":"","source.zip_url.password":"","synthetics_args":[],"ssl.key":"","ssl.key_passphrase":""}', + }, + references: [], + coreMigrationVersion: '8.8.0', + updated_at: '2023-03-31T20:35:34.916Z', + created_at: '2023-03-31T20:35:34.916Z', + typeMigrationVersion: '8.6.0', +} as SavedObjectUnsanitizedDoc; +export const tcpUptimeUI = { + type: 'synthetics-monitor', + id: '726d3f74-7760-4045-ad8d-87642403c721', + attributes: { + type: 'tcp', + form_monitor_type: 'tcp', + enabled: true, + alert: { status: { enabled: true } }, + schedule: { number: '8', unit: 'm' }, + 'service.name': '', + config_id: '726d3f74-7760-4045-ad8d-87642403c721', + tags: [], + timeout: '16', + name: 'TCP monitor with invalid schedule 8m', + locations: [ + { + id: 'us_central', + label: 'North America - US Central', + geo: { lat: 41.25, lon: -95.86 }, + isServiceManaged: true, + }, + ], + namespace: 'default', + origin: 'ui', + journey_id: '', + hash: '', + id: '726d3f74-7760-4045-ad8d-87642403c721', + __ui: { is_tls_enabled: false, is_zip_url_tls_enabled: false }, + hosts: 'localhost:5601', + urls: '', + 'url.port': null, + proxy_url: '', + proxy_use_local_resolver: false, + 'ssl.certificate_authorities': '', + 'ssl.certificate': '', + 'ssl.verification_mode': 'full', + 'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'], + revision: 1, + secrets: '{"check.send":"","check.receive":"","ssl.key":"","ssl.key_passphrase":""}', + }, + references: [], + coreMigrationVersion: '8.8.0', + updated_at: '2023-03-31T20:38:29.582Z', + created_at: '2023-03-31T20:38:29.582Z', + typeMigrationVersion: '8.6.0', +} as SavedObjectUnsanitizedDoc; +export const httpUptimeUI = { + type: 'synthetics-monitor', + id: '35b2d765-4a62-4511-91c8-d5d52fdf4639', + attributes: { + type: 'http', + form_monitor_type: 'http', + enabled: true, + alert: { status: { enabled: true } }, + schedule: { number: '4', unit: 'm' }, + 'service.name': '', + config_id: '35b2d765-4a62-4511-91c8-d5d52fdf4639', + tags: [], + timeout: '16', + name: 'HTTP monitor with invalid schedule 4m', + locations: [ + { + id: 'us_central', + label: 'North America - US Central', + geo: { lat: 41.25, lon: -95.86 }, + isServiceManaged: true, + }, + ], + namespace: 'default', + origin: 'ui', + journey_id: '', + hash: '', + id: '35b2d765-4a62-4511-91c8-d5d52fdf4639', + __ui: { is_tls_enabled: false, is_zip_url_tls_enabled: false }, + urls: 'https://google.com', + max_redirects: '0', + 'url.port': null, + proxy_url: '', + 'response.include_body': 'on_error', + 'response.include_headers': true, + 'check.response.status': [], + 'check.request.method': 'GET', + 'ssl.certificate_authorities': '', + 'ssl.certificate': '', + 'ssl.verification_mode': 'full', + 'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'], + revision: 1, + secrets: + '{"password":"","check.request.body":{"type":"text","value":""},"check.request.headers":{},"check.response.body.negative":[],"check.response.body.positive":[],"check.response.headers":{},"ssl.key":"","ssl.key_passphrase":"","username":""}', + }, + references: [], + coreMigrationVersion: '8.8.0', + updated_at: '2023-03-31T20:37:24.093Z', + created_at: '2023-03-31T20:37:24.093Z', + typeMigrationVersion: '8.6.0', +} as SavedObjectUnsanitizedDoc; +export const icmpUptimeUI = { + type: 'synthetics-monitor', + id: '28b14c99-4a39-475d-9545-21b35b35751d', + attributes: { + type: 'icmp', + form_monitor_type: 'icmp', + enabled: true, + alert: { status: { enabled: true } }, + schedule: { number: '11', unit: 'm' }, + 'service.name': '', + config_id: '28b14c99-4a39-475d-9545-21b35b35751d', + tags: [], + timeout: '16', + name: 'ICMP monitor with invalid schedule 11m', + locations: [ + { + geo: { lon: -95.86, lat: 41.25 }, + isServiceManaged: true, + id: 'us_central', + label: 'North America - US Central', + }, + ], + namespace: 'default', + origin: 'ui', + journey_id: '', + hash: '', + id: '28b14c99-4a39-475d-9545-21b35b35751d', + hosts: '1.1.1.1', + wait: '1', + revision: 2, + secrets: '{}', + }, + references: [], + coreMigrationVersion: '8.8.0', + updated_at: '2023-03-31T20:40:28.889Z', + created_at: '2023-03-31T20:39:13.783Z', + typeMigrationVersion: '8.6.0', +} as SavedObjectUnsanitizedDoc; +export const browserProject = { + type: 'synthetics-monitor', + id: 'ea123f46-eb02-4a8a-b3ce-53e645ce4aef', + attributes: { + type: 'browser', + form_monitor_type: 'multistep', + enabled: true, + alert: { status: { enabled: true } }, + schedule: { number: '10', unit: 'm' }, + 'service.name': '', + config_id: 'ea123f46-eb02-4a8a-b3ce-53e645ce4aef', + tags: [], + timeout: null, + name: 'addition and completion of single task', + locations: [ + { + id: 'us_central', + label: 'North America - US Central', + geo: { lat: 41.25, lon: -95.86 }, + isServiceManaged: true, + }, + ], + namespace: 'default', + origin: 'project', + journey_id: 'addition and completion of single task', + hash: '7a7cyPraVarTWfDHyqSgXBktTAcuwwWtcB+IGdNZF14=', + id: 'addition and completion of single task-test2-default', + project_id: 'test2', + playwright_options: '{"ignoreHTTPSErrors":true,"headless":true}', + __ui: { + script_source: { is_generated_script: false, file_name: '' }, + is_zip_url_tls_enabled: false, + }, + 'url.port': null, + 'source.zip_url.url': '', + 'source.zip_url.folder': '', + 'source.zip_url.proxy_url': '', + playwright_text_assertion: '', + urls: '', + screenshots: 'on', + 'filter_journeys.match': 'addition and completion of single task', + 'filter_journeys.tags': [], + ignore_https_errors: false, + 'throttling.is_enabled': true, + 'throttling.download_speed': '5', + 'throttling.upload_speed': '3', + 'throttling.latency': '20', + 'throttling.config': '5d/3u/20l', + 'ssl.certificate_authorities': '', + 'ssl.certificate': '', + 'ssl.verification_mode': 'full', + 'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'], + original_space: 'default', + custom_heartbeat_id: 'addition and completion of single task-test2-default', + revision: 1, + secrets: + '{"params":"{\\"url\\":\\"https://elastic.github.io/synthetics-demo/\\"}","source.inline.script":"","source.project.content":"UEsDBBQACAAIAAAAIQAAAAAAAAAAAAAAAAAkAAAAam91cm5leXMvYWR2YW5jZWQtZXhhbXBsZS5qb3VybmV5LnRzpVVrb9pKEP2eX2H5XqlESsCQ0DatUt3wMDE1tDbYPKrqZrE3YDC2410epsp/v7PrB4aQKNL9wrI7M2fOnJldl0rC3F+FHo5ICdlr5FnYvsRbtAxcXEwsRUrO1igUnGXgh/RfEnl0hqljkYpwK4T4aeWEuCD+g11E4LS0t4vnX8/OSm9kuJxhN8AheTXDOxKwONdH9l0Q9CgOIKIQoCm+EFahey7cfhP+nAlCQbp4CV4k4H9eEF208qyZgIJAvBAQ2C2hkEUKAtoghwoMszj1qV9guF/B8gy/z3F+ZNt9RBaH+SmcvIvAA4Rzb+HvP2x5fjhFw/I9QgXHC1YUcuRIub6FqB8WRG4renhzSX3bFznJlH5so1GAC5zXS1sQYkIKYtOjOBSPC2SApIddbEEmSC+u3CI7u3QdIOU6fCPGvo+Ox9VgLOMqTugRYgozcaqMBxAhn+1Z+PZNoHhLb8VEHvFhT8yaYWsh+2FO/teTvtkEjiQ8Qnm8FR+SZB9AHoFVebIpSRlpyfmkRwramNDQj/4/zwToiOUbI+OiCXazkXmNaubtZK48cD9e2wDR2S27vwT2X764zq/yb/EgOOFWW1Hqe3scZw8y4abDKMt1oIcrUBJDzAFGkdsKB+MKcDN/jcPD0xxITvk3X5/8+3ZS8krqAY8E3FGHOlAV8mzgzeL51n8UiONNXcylhAek8EeIpQ1QiJYEmKQNiaulUF8fxpndoobvfYDxhxtNkMsuohBBQgFHmIisity7VsiDFtM3KPfwpA1N4Ln5+Hac8jkazJcuTMp3yeNNuTghXvprtlmuXOoEiTLkvdIwX9Dml8jfkDKExf8q2b8r8fe7xMnginCrm8iaFQo0/66/1C67tG/KwiBh9F9pQMzxWkyUK5X+EgjIZOEOfGBAFkNXb21E0RfYwswiNkWlOfG9rxNE8MfrC7zxp0q9XRkP2zs0uFkpc3/aiTbflfqdY1Vuytay61qR8lGRiYOWbF918bCzHg30ymhQnY8HGh0PZ7PJsEbGverT5MqMJkuzqnr6TnE2U2UZrO1hezUeuju1Ii/spbwaVcyFOjCvR4PyZtIyKGqZxGqZkRVVJStq2+od50RHw9oGDaoez19XPmmGXNN623aybrWFXLMl5dOPHa1pknytOdsrdjYxOsy32zUU0gPffm87h/1cbXZrmtEhfTgb9LY6nHnaHGKNrqTXN9csthclvrJb08wFw2l0JYWYMY4Ke1VtshhCdEmu6Sw32NSmWdOu2vUkB4/rNZjN/Kk2AcuQyAj8R9G2wWxqs8zwiQFnyOC1NeyFRn402xx7sOeo57lMFp2US2xjOIDdkzj3+Kxl13O1Pen1rcn0OPJlOrZ/wH/OWza5rR9jd2P/Gzj7nOouQ1070Jjz53HSlNnkpCfdw7zmMq3bBF8z2v4E289TdXcMje/7UZo31teAvEZvew9n92qjBtjNDeTnODx/ZSaz1ZA+p32mcf8V0t/jjVUZejJw63HMVlYbszrvY6vMVgqYAYsDPrHufa7bCnQbcs4s3uyk2ux1M5pEZ/MBcRrb81noKsymGxmnkGNLb3EKcpxctgbAqQ9rP997/ErvmXZGph3TnPvL9t4/mdtyvscxxr3J8pX39yCZlbSXToprg91Ke8JjeZ3RTSOdnWS+k7vGc3EeuJnxiHuZs42dOF9eT+NoxuB+t/X7WUPrbSSmpdHbbJjeHcDlukdsNmU5qy83S/F867Iqy/tZ5H0yn6C2Oe/FYRznyON2Zl1tdfm85jWLbXI9mZ8g04jlMJu8Vyr0G0lwlwd2PesT0y6eLV+LcjVC3TArMrxBSX3bHavLkt5ZH5vppL7k3YjfGNYX0+Dam/me9aBnh3Uld5P3OH7zkrtgZrPG3gLCbdZCIWNW2z7+oBY98dnfCbuptujhPCXcwLemc01sokWH/djr1Sln706kkLpzB9+V6mwyMHfsezWI2gF8f9aWpz9aV+7Kbs1cu+XO2bek7knfz/4DUEsHCBVHLjjcBQAAeA4AAFBLAQItAxQACAAIAAAAIQAVRy443AUAAHgOAAAkAAAAAAAAAAAAIACkgQAAAABqb3VybmV5cy9hZHZhbmNlZC1leGFtcGxlLmpvdXJuZXkudHNQSwUGAAAAAAEAAQBSAAAALgYAAAAA","source.zip_url.username":"","source.zip_url.password":"","synthetics_args":[],"ssl.key":"","ssl.key_passphrase":""}', + }, + references: [], + coreMigrationVersion: '8.8.0', + updated_at: '2023-03-31T20:43:35.214Z', + created_at: '2023-03-31T20:43:35.214Z', + typeMigrationVersion: '8.6.0', +} as SavedObjectUnsanitizedDoc; +export const httpProject = { + type: 'synthetics-monitor', + id: '316c0df8-56fc-428a-a477-7bf580f6cb4c', + attributes: { + type: 'http', + form_monitor_type: 'http', + enabled: true, + alert: { status: { enabled: true } }, + schedule: { number: '10', unit: 'm' }, + 'service.name': '', + config_id: '316c0df8-56fc-428a-a477-7bf580f6cb4c', + tags: ['org:elastics'], + timeout: '16', + name: 'facebook', + locations: [ + { + id: 'us_central', + label: 'North America - US Central', + geo: { lat: 41.25, lon: -95.86 }, + isServiceManaged: true, + }, + ], + namespace: 'default', + origin: 'project', + journey_id: 'an-id3', + hash: 'thcZtI5hzo94RiDoK1B+MEwIPIzJMINtuA042Y+yrDU=', + id: 'an-id3-test2-default', + __ui: { is_tls_enabled: false }, + urls: 'https://www.facebook.com', + max_redirects: '0', + 'url.port': null, + proxy_url: '', + 'response.include_body': 'on_error', + 'response.include_headers': true, + 'check.response.status': [], + 'check.request.method': 'GET', + 'ssl.certificate_authorities': '', + 'ssl.certificate': '', + 'ssl.verification_mode': 'full', + 'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'], + project_id: 'test2', + original_space: 'default', + custom_heartbeat_id: 'an-id3-test2-default', + revision: 1, + secrets: + '{"password":"","check.request.body":{"type":"text","value":""},"check.request.headers":{"Content-Type":"text/plain"},"check.response.body.negative":[],"check.response.body.positive":[],"check.response.headers":{},"ssl.key":"","ssl.key_passphrase":"","username":""}', + }, + references: [], + coreMigrationVersion: '8.8.0', + updated_at: '2023-03-31T20:43:35.214Z', + created_at: '2023-03-31T20:43:35.214Z', + typeMigrationVersion: '8.6.0', +} as SavedObjectUnsanitizedDoc; +export const icmpProject = { + type: 'synthetics-monitor', + id: 'e21a30b5-6d40-4458-8cff-9003d7b83eb6', + attributes: { + type: 'icmp', + form_monitor_type: 'icmp', + enabled: true, + alert: { status: { enabled: true } }, + schedule: { number: '10', unit: 'm' }, + 'service.name': '', + config_id: 'e21a30b5-6d40-4458-8cff-9003d7b83eb6', + tags: ['service:dns', 'org:cloudflare'], + timeout: '16', + name: 'Cloudflare DNS', + locations: [ + { + id: 'us_central', + label: 'North America - US Central', + geo: { lat: 41.25, lon: -95.86 }, + isServiceManaged: true, + }, + ], + namespace: 'default', + origin: 'project', + journey_id: 'stuff', + hash: 'fZfJJOKGdjznBxHZLgLrWbkvUI/AH4SzFqweV/NnpIw=', + id: 'stuff-test2-default', + hosts: '${random_host}', + wait: '1', + project_id: 'test2', + original_space: 'default', + custom_heartbeat_id: 'stuff-test2-default', + revision: 1, + secrets: '{}', + }, + references: [], + coreMigrationVersion: '8.8.0', + updated_at: '2023-03-31T20:43:35.214Z', + created_at: '2023-03-31T20:43:35.214Z', + typeMigrationVersion: '8.6.0', +} as SavedObjectUnsanitizedDoc; +export const tcpProject = { + type: 'synthetics-monitor', + id: '9f5d6206-9a1d-47fb-bd67-c7895b07f716', + attributes: { + type: 'tcp', + form_monitor_type: 'tcp', + enabled: true, + alert: { status: { enabled: false } }, + schedule: { number: '30', unit: 'm' }, + 'service.name': '', + config_id: '9f5d6206-9a1d-47fb-bd67-c7895b07f716', + tags: ['service:smtp', 'org:google'], + timeout: '16', + name: 'GMail SMTP', + locations: [ + { + geo: { lon: -95.86, lat: 41.25 }, + isServiceManaged: true, + id: 'us_central', + label: 'North America - US Central', + }, + ], + namespace: 'default', + origin: 'project', + journey_id: 'gmail-smtp', + hash: 'BoPnjeryNLnktKz+PeeHwHKzEnZaxHNJmAUjlOVKfRY=', + id: 'gmail-smtp-test2-default', + __ui: { is_tls_enabled: false }, + hosts: '${random_host}', + urls: '', + 'url.port': null, + proxy_url: '', + proxy_use_local_resolver: false, + 'ssl.certificate_authorities': '', + 'ssl.certificate': '', + 'ssl.verification_mode': 'full', + 'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'], + project_id: 'test2', + original_space: 'default', + custom_heartbeat_id: 'gmail-smtp-test2-default', + revision: 3, + secrets: '{"check.send":"","check.receive":"","ssl.key":"","ssl.key_passphrase":""}', + }, + references: [], + coreMigrationVersion: '8.8.0', + updated_at: '2023-03-31T20:47:15.781Z', + created_at: '2023-03-31T20:43:35.214Z', + typeMigrationVersion: '8.6.0', +} as SavedObjectUnsanitizedDoc; + +export const testMonitors = [ + browserUI, + browserSinglePageUI, + httpUI, + tcpUI, + icmpUI, + browserUptimeUI, + httpUptimeUI, + tcpUptimeUI, + icmpUptimeUI, + browserProject, + httpProject, + tcpProject, + icmpProject, +]; diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/synthetics_monitor.ts b/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/synthetics_monitor.ts index 0a766e4a5833da..3d5ddecf188a50 100644 --- a/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/synthetics_monitor.ts +++ b/x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objects/synthetics_monitor.ts @@ -7,11 +7,31 @@ import { EncryptedSavedObjectsPluginSetup } from '@kbn/encrypted-saved-objects-plugin/server'; import { SavedObjectsType } from '@kbn/core/server'; import { i18n } from '@kbn/i18n'; -import { secretKeys } from '../../../../common/constants/monitor_management'; +import { + secretKeys, + ConfigKey, + LegacyConfigKey, +} from '../../../../common/constants/monitor_management'; import { monitorMigrations } from './migrations/monitors'; export const syntheticsMonitorType = 'synthetics-monitor'; +const legacyConfigKeys = Object.values(LegacyConfigKey); + +export const LEGACY_SYNTHETICS_MONITOR_ENCRYPTED_TYPE = { + type: syntheticsMonitorType, + attributesToEncrypt: new Set([ + 'secrets', + /* adding secretKeys to the list of attributes to encrypt ensures + * that secrets are never stored on the resulting saved object, + * even in the presence of developer error. + * + * In practice, all secrets should be stored as a single JSON + * payload on the `secrets` key. This ensures performant decryption. */ + ...secretKeys, + ]), +}; + export const SYNTHETICS_MONITOR_ENCRYPTED_TYPE = { type: syntheticsMonitorType, attributesToEncrypt: new Set([ @@ -24,6 +44,11 @@ export const SYNTHETICS_MONITOR_ENCRYPTED_TYPE = { * payload on the `secrets` key. This ensures performant decryption. */ ...secretKeys, ]), + attributesToExcludeFromAAD: new Set([ + ConfigKey.ALERT_CONFIG, + ConfigKey.METADATA, + ...legacyConfigKeys, + ]), }; export const getSyntheticsMonitorSavedObjectType = ( @@ -35,6 +60,7 @@ export const getSyntheticsMonitorSavedObjectType = ( namespaceType: 'single', migrations: { '8.6.0': monitorMigrations['8.6.0'](encryptedSavedObjects), + '8.8.0': monitorMigrations['8.8.0'](encryptedSavedObjects), }, mappings: { dynamic: false, diff --git a/x-pack/plugins/synthetics/server/routes/monitor_cruds/monitor_validation.test.ts b/x-pack/plugins/synthetics/server/routes/monitor_cruds/monitor_validation.test.ts index b927e1a37e21af..98188e88dc7ffe 100644 --- a/x-pack/plugins/synthetics/server/routes/monitor_cruds/monitor_validation.test.ts +++ b/x-pack/plugins/synthetics/server/routes/monitor_cruds/monitor_validation.test.ts @@ -29,7 +29,6 @@ import { TLSFields, TLSVersion, VerificationMode, - ZipUrlTLSFields, } from '../../../common/runtime_types'; import { validateMonitor } from './monitor_validation'; @@ -46,7 +45,6 @@ describe('validateMonitor', () => { let testHTTPSimpleFields: HTTPSimpleFields; let testHTTPAdvancedFields: HTTPAdvancedFields; let testHTTPFields: HTTPFields; - let testZipUrlTLSFields: ZipUrlTLSFields; let testBrowserSimpleFields: BrowserSimpleFields; let testBrowserAdvancedFields: BrowserAdvancedFields; let testBrowserFields: BrowserFields; @@ -81,7 +79,6 @@ describe('validateMonitor', () => { }; testMetaData = { is_tls_enabled: false, - is_zip_url_tls_enabled: false, script_source: { is_generated_script: false, file_name: 'test-file.name', @@ -158,17 +155,7 @@ describe('validateMonitor', () => { [ConfigKey.MONITOR_TYPE]: DataStream.HTTP, }; - testZipUrlTLSFields = { - [ConfigKey.ZIP_URL_TLS_CERTIFICATE_AUTHORITIES]: 'test', - [ConfigKey.ZIP_URL_TLS_CERTIFICATE]: 'test', - [ConfigKey.ZIP_URL_TLS_KEY]: 'key', - [ConfigKey.ZIP_URL_TLS_KEY_PASSPHRASE]: 'passphrase', - [ConfigKey.ZIP_URL_TLS_VERIFICATION_MODE]: VerificationMode.STRICT, - [ConfigKey.ZIP_URL_TLS_VERSION]: [TLSVersion.ONE_ONE, TLSVersion.ONE_TWO], - }; - testBrowserSimpleFields = { - ...testZipUrlTLSFields, ...testCommonFields, [ConfigKey.FORM_MONITOR_TYPE]: FormMonitorType.MULTISTEP, [ConfigKey.MONITOR_SOURCE_TYPE]: SourceType.PROJECT, @@ -177,11 +164,6 @@ describe('validateMonitor', () => { [ConfigKey.METADATA]: testMetaData, [ConfigKey.SOURCE_INLINE]: '', [ConfigKey.SOURCE_PROJECT_CONTENT]: '', - [ConfigKey.SOURCE_ZIP_URL]: '', - [ConfigKey.SOURCE_ZIP_FOLDER]: '', - [ConfigKey.SOURCE_ZIP_USERNAME]: 'test-username', - [ConfigKey.SOURCE_ZIP_PASSWORD]: 'password', - [ConfigKey.SOURCE_ZIP_PROXY_URL]: 'http://proxy-url.com', [ConfigKey.PARAMS]: '', [ConfigKey.URLS]: null, [ConfigKey.PORT]: null, @@ -209,7 +191,13 @@ describe('validateMonitor', () => { describe('should invalidate', () => { it(`when 'type' is null or undefined`, () => { - const testMonitor = { type: undefined } as unknown as MonitorFields; + const testMonitor = { + type: undefined, + schedule: { + unit: ScheduleUnit.MINUTES, + number: '3', + }, + } as unknown as MonitorFields; const result = validateMonitor(testMonitor); expect(result).toMatchObject({ valid: false, @@ -219,7 +207,13 @@ describe('validateMonitor', () => { }); it(`when 'type' is not an acceptable monitor type (DataStream)`, () => { - const monitor = { type: 'non-HTTP' } as unknown as MonitorFields; + const monitor = { + type: 'non-HTTP', + schedule: { + unit: ScheduleUnit.MINUTES, + number: '3', + }, + } as unknown as MonitorFields; const result = validateMonitor(monitor); expect(result).toMatchObject({ valid: false, @@ -227,6 +221,22 @@ describe('validateMonitor', () => { details: expect.stringMatching(/(?=.*invalid)(?=.*non-HTTP)(?=.*DataStream)/i), }); }); + + it(`when schedule is not valid`, () => { + const result = validateMonitor({ + ...testICMPFields, + schedule: { + number: '4', + unit: ScheduleUnit.MINUTES, + }, + } as unknown as MonitorFields); + expect(result).toMatchObject({ + valid: false, + reason: 'Monitor schedule is invalid', + details: + 'Invalid schedule 4 minutes supplied to monitor configuration. Please use a supported monitor schedule.', + }); + }); }); describe('should validate', () => { @@ -408,7 +418,6 @@ function getJsonPayload() { ' "timeout": "3m",' + ' "__ui": {' + ' "is_tls_enabled": false,' + - ' "is_zip_url_tls_enabled": false,' + ' "script_source": {' + ' "is_generated_script": false,' + ' "file_name": "test-file.name"' + diff --git a/x-pack/plugins/synthetics/server/routes/monitor_cruds/monitor_validation.ts b/x-pack/plugins/synthetics/server/routes/monitor_cruds/monitor_validation.ts index 77cd0fa23a7cea..4f091c5e7c417c 100644 --- a/x-pack/plugins/synthetics/server/routes/monitor_cruds/monitor_validation.ts +++ b/x-pack/plugins/synthetics/server/routes/monitor_cruds/monitor_validation.ts @@ -23,6 +23,8 @@ import { SyntheticsMonitor, } from '../../../common/runtime_types'; +import { ALLOWED_SCHEDULES_IN_MINUTES } from '../../../common/constants/monitor_defaults'; + type MonitorCodecType = | typeof ICMPSimpleFieldsCodec | typeof TCPFieldsCodec @@ -52,6 +54,7 @@ export function validateMonitor(monitorFields: MonitorFields): ValidationResult const { [ConfigKey.MONITOR_TYPE]: monitorType } = monitorFields; const decodedType = DataStreamCodec.decode(monitorType); + if (isLeft(decodedType)) { return { valid: false, @@ -73,6 +76,17 @@ export function validateMonitor(monitorFields: MonitorFields): ValidationResult }; } + if (!ALLOWED_SCHEDULES_IN_MINUTES.includes(monitorFields[ConfigKey.SCHEDULE].number)) { + return { + valid: false, + reason: `Monitor schedule is invalid`, + details: `Invalid schedule ${ + monitorFields[ConfigKey.SCHEDULE].number + } minutes supplied to monitor configuration. Please use a supported monitor schedule.`, + payload: monitorFields, + }; + } + const ExactSyntheticsMonitorCodec = t.exact(SyntheticsMonitorCodec); const decodedMonitor = ExactSyntheticsMonitorCodec.decode(monitorFields); diff --git a/x-pack/plugins/synthetics/server/routes/telemetry/monitor_upgrade_sender.test.ts b/x-pack/plugins/synthetics/server/routes/telemetry/monitor_upgrade_sender.test.ts index 65ee31dbb08aa1..6dc14565b6289c 100644 --- a/x-pack/plugins/synthetics/server/routes/telemetry/monitor_upgrade_sender.test.ts +++ b/x-pack/plugins/synthetics/server/routes/telemetry/monitor_upgrade_sender.test.ts @@ -117,7 +117,6 @@ describe('monitor upgrade telemetry helpers', () => { [ConfigKey.MONITOR_SOURCE_TYPE, SourceType.PROJECT, 'project', false, false], [ConfigKey.SOURCE_INLINE, 'test', 'recorder', true, true], [ConfigKey.SOURCE_INLINE, 'test', 'inline', false, true], - [ConfigKey.SOURCE_ZIP_URL, 'test', 'zip', false, false], ])( 'handles formatting scriptType for browser monitors', (config, value, scriptType, isRecorder, isInlineScript) => { diff --git a/x-pack/plugins/synthetics/server/routes/telemetry/monitor_upgrade_sender.ts b/x-pack/plugins/synthetics/server/routes/telemetry/monitor_upgrade_sender.ts index d86792a7967c36..fcfce9d2c85a1c 100644 --- a/x-pack/plugins/synthetics/server/routes/telemetry/monitor_upgrade_sender.ts +++ b/x-pack/plugins/synthetics/server/routes/telemetry/monitor_upgrade_sender.ts @@ -165,8 +165,6 @@ function getScriptType( isInlineScript: boolean ): MonitorUpdateEvent['scriptType'] | undefined { switch (true) { - case Boolean(attributes[ConfigKey.SOURCE_ZIP_URL]): - return 'zip'; case Boolean( isInlineScript && attributes[ConfigKey.METADATA]?.script_source?.is_generated_script ): diff --git a/x-pack/plugins/synthetics/server/synthetics_service/formatters/browser.ts b/x-pack/plugins/synthetics/server/synthetics_service/formatters/browser.ts index 1a5e090033ece4..391556bb996496 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/formatters/browser.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/formatters/browser.ts @@ -36,13 +36,7 @@ const throttlingFormatter: Formatter = (fields) => { export const browserFormatters: BrowserFormatMap = { ...basicBrowserFormatters, [ConfigKey.METADATA]: objectFormatter, - [ConfigKey.ZIP_URL_TLS_VERSION]: arrayFormatter, [ConfigKey.SOURCE_INLINE]: null, - [ConfigKey.ZIP_URL_TLS_CERTIFICATE_AUTHORITIES]: null, - [ConfigKey.ZIP_URL_TLS_CERTIFICATE]: null, - [ConfigKey.ZIP_URL_TLS_KEY]: null, - [ConfigKey.ZIP_URL_TLS_KEY_PASSPHRASE]: null, - [ConfigKey.ZIP_URL_TLS_VERIFICATION_MODE]: null, [ConfigKey.THROTTLING_CONFIG]: throttlingFormatter, [ConfigKey.JOURNEY_FILTERS_MATCH]: null, [ConfigKey.SYNTHETICS_ARGS]: arrayFormatter, 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 139c9faa91854e..eb2b40e3242492 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 @@ -32,7 +32,7 @@ const testHTTPConfig: Partial = { timeout: '16', name: 'Test', locations: [], - __ui: { is_tls_enabled: false, is_zip_url_tls_enabled: false }, + __ui: { is_tls_enabled: false }, urls: 'https://www.google.com', max_redirects: '0', password: '3z9SBOQWW5F0UrdqLVFqlF6z', @@ -62,14 +62,8 @@ const testBrowserConfig: Partial = { locations: [], __ui: { script_source: { is_generated_script: false, file_name: '' }, - is_zip_url_tls_enabled: false, is_tls_enabled: false, }, - 'source.zip_url.url': '', - 'source.zip_url.username': '', - 'source.zip_url.password': '', - 'source.zip_url.folder': '', - 'source.zip_url.proxy_url': '', 'source.inline.script': "step('Go to https://www.google.com/', async () => {\n await page.goto('https://www.google.com/');\n});", params: '{"a":"param"}', 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 4d319c714a44be..5f1c74d5dfb05f 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 @@ -198,7 +198,7 @@ describe('SyntheticsPrivateLocation', () => { __ui: { type: 'yaml', value: - '{"script_source":{"is_generated_script":false,"file_name":""},"is_zip_url_tls_enabled":false,"is_tls_enabled":true}', + '{"script_source":{"is_generated_script":false,"file_name":""},"is_tls_enabled":true}', }, config_id: { type: 'text', @@ -253,44 +253,6 @@ describe('SyntheticsPrivateLocation', () => { value: "\"step('Go to https://www.elastic.co/', async () => {\\n await page.goto('https://www.elastic.co/');\\n});\"", }, - 'source.zip_url.folder': { - type: 'text', - value: '', - }, - 'source.zip_url.password': { - type: 'password', - value: '', - }, - 'source.zip_url.proxy_url': { - type: 'text', - value: '', - }, - 'source.zip_url.ssl.certificate': { - type: 'yaml', - }, - 'source.zip_url.ssl.certificate_authorities': { - type: 'yaml', - }, - 'source.zip_url.ssl.key': { - type: 'yaml', - }, - 'source.zip_url.ssl.key_passphrase': { - type: 'text', - }, - 'source.zip_url.ssl.supported_protocols': { - type: 'yaml', - }, - 'source.zip_url.ssl.verification_mode': { - type: 'text', - }, - 'source.zip_url.url': { - type: 'text', - value: '', - }, - 'source.zip_url.username': { - type: 'text', - value: '', - }, synthetics_args: { type: 'text', value: null, @@ -336,7 +298,6 @@ const dummyBrowserConfig: Partial & { playwright_options: '', __ui: { script_source: { is_generated_script: false, file_name: '' }, - is_zip_url_tls_enabled: false, is_tls_enabled: true, }, params: '', @@ -344,11 +305,6 @@ const dummyBrowserConfig: Partial & { 'source.inline.script': "step('Go to https://www.elastic.co/', async () => {\n await page.goto('https://www.elastic.co/');\n});", 'source.project.content': '', - 'source.zip_url.url': '', - 'source.zip_url.username': '', - 'source.zip_url.password': '', - 'source.zip_url.folder': '', - 'source.zip_url.proxy_url': '', urls: 'https://www.elastic.co/', screenshots: 'on', synthetics_args: [], diff --git a/x-pack/plugins/synthetics/server/synthetics_service/private_location/test_policy.ts b/x-pack/plugins/synthetics/server/synthetics_service/private_location/test_policy.ts index 597045ea459736..266d440e4df86b 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/private_location/test_policy.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/private_location/test_policy.ts @@ -135,10 +135,6 @@ export const testMonitorPolicy = { 'service.name': { type: 'text' }, timeout: { type: 'text' }, tags: { type: 'yaml' }, - 'source.zip_url.url': { type: 'text' }, - 'source.zip_url.username': { type: 'text' }, - 'source.zip_url.folder': { type: 'text' }, - 'source.zip_url.password': { type: 'password' }, 'source.inline.script': { type: 'yaml' }, params: { type: 'yaml' }, screenshots: { type: 'text' }, @@ -147,13 +143,6 @@ export const testMonitorPolicy = { 'throttling.config': { type: 'text' }, 'filter_journeys.tags': { type: 'yaml' }, 'filter_journeys.match': { type: 'text' }, - 'source.zip_url.ssl.certificate_authorities': { type: 'yaml' }, - 'source.zip_url.ssl.certificate': { type: 'yaml' }, - 'source.zip_url.ssl.key': { type: 'yaml' }, - 'source.zip_url.ssl.key_passphrase': { type: 'text' }, - '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: 'Fleet managed', type: 'text' }, config_id: { type: 'text' }, run_once: { value: false, type: 'bool' }, diff --git a/x-pack/plugins/synthetics/server/synthetics_service/project_monitor/project_monitor_formatter.test.ts b/x-pack/plugins/synthetics/server/synthetics_service/project_monitor/project_monitor_formatter.test.ts index f085c73be2ba16..800b8cfa0ac5ee 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/project_monitor/project_monitor_formatter.test.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/project_monitor/project_monitor_formatter.test.ts @@ -445,7 +445,6 @@ const payloadData = [ { ...DEFAULT_FIELDS[DataStream.BROWSER], __ui: { - is_zip_url_tls_enabled: false, script_source: { file_name: '', is_generated_script: false, @@ -478,12 +477,6 @@ const payloadData = [ 'source.inline.script': '', 'source.project.content': 'UEsDBBQACAAIAAAAIQAAAAAAAAAAAAAAAAAQAAAAYmFzaWMuam91cm5leS50c2WQQU7DQAxF9znFV8QiUUOmXcCCUMQl2NdMnWbKJDMaO6Ilyt0JASQkNv9Z1teTZWNAIqwP5kU4iZGOug863u7uDXsSddbIddCOl0kMX6iPnsVoOAYxryTO1ucwpoGvtUrm+hiSYsLProIoxwp8iWwVM9oUeuTP/9V5k7UhofCscNhj2yx4xN2CzabElOHXWRxsx/YNroU69QwniImFB8Vui5vJzYcKxYRIJ66WTNQL5hL7p1WD9aYi9zQOtgPFGPNqecJ1sCj+tAB6J6erpj4FDcW3qh6TL5u1Mq/8yjn7BFBLBwhGDIWc4QAAAEkBAABQSwECLQMUAAgACAAAACEARgyFnOEAAABJAQAAEAAAAAAAAAAAACAApIEAAAAAYmFzaWMuam91cm5leS50c1BLBQYAAAAAAQABAD4AAAAfAQAAAAA=', - 'source.zip_url.folder': '', - 'source.zip_url.password': '', - 'source.zip_url.proxy_url': '', - 'source.zip_url.url': '', - 'source.zip_url.ssl.certificate': undefined, - 'source.zip_url.username': '', 'ssl.certificate': '', 'ssl.certificate_authorities': '', 'ssl.key': '', @@ -507,7 +500,6 @@ const payloadData = [ { ...DEFAULT_FIELDS[DataStream.BROWSER], __ui: { - is_zip_url_tls_enabled: false, script_source: { file_name: '', is_generated_script: false, @@ -540,11 +532,6 @@ const payloadData = [ 'source.inline.script': '', 'source.project.content': 'UEsDBBQACAAIAAAAIQAAAAAAAAAAAAAAAAAQAAAAYmFzaWMuam91cm5leS50c2WQQU7DQAxF9znFV8QiUUOmXcCCUMQl2NdMnWbKJDMaO6Ilyt0JASQkNv9Z1teTZWNAIqwP5kU4iZGOug863u7uDXsSddbIddCOl0kMX6iPnsVoOAYxryTO1ucwpoGvtUrm+hiSYsLProIoxwp8iWwVM9oUeuTP/9V5k7UhofCscNhj2yx4xN2CzabElOHXWRxsx/YNroU69QwniImFB8Vui5vJzYcKxYRIJ66WTNQL5hL7p1WD9aYi9zQOtgPFGPNqecJ1sCj+tAB6J6erpj4FDcW3qh6TL5u1Mq/8yjn7BFBLBwhGDIWc4QAAAEkBAABQSwECLQMUAAgACAAAACEARgyFnOEAAABJAQAAEAAAAAAAAAAAACAApIEAAAAAYmFzaWMuam91cm5leS50c1BLBQYAAAAAAQABAD4AAAAfAQAAAAA=', - 'source.zip_url.folder': '', - 'source.zip_url.password': '', - 'source.zip_url.proxy_url': '', - 'source.zip_url.url': '', - 'source.zip_url.username': '', 'ssl.certificate': '', 'ssl.certificate_authorities': '', 'ssl.key': '', diff --git a/x-pack/plugins/synthetics/server/synthetics_service/project_monitor/project_monitor_formatter_legacy.test.ts b/x-pack/plugins/synthetics/server/synthetics_service/project_monitor/project_monitor_formatter_legacy.test.ts index 6d449132b25d56..c284e18dac56d9 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/project_monitor/project_monitor_formatter_legacy.test.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/project_monitor/project_monitor_formatter_legacy.test.ts @@ -514,7 +514,6 @@ const payloadData = [ { ...DEFAULT_FIELDS[DataStream.BROWSER], __ui: { - is_zip_url_tls_enabled: false, script_source: { file_name: '', is_generated_script: false, @@ -547,12 +546,6 @@ const payloadData = [ 'source.inline.script': '', 'source.project.content': 'UEsDBBQACAAIAAAAIQAAAAAAAAAAAAAAAAAQAAAAYmFzaWMuam91cm5leS50c2WQQU7DQAxF9znFV8QiUUOmXcCCUMQl2NdMnWbKJDMaO6Ilyt0JASQkNv9Z1teTZWNAIqwP5kU4iZGOug863u7uDXsSddbIddCOl0kMX6iPnsVoOAYxryTO1ucwpoGvtUrm+hiSYsLProIoxwp8iWwVM9oUeuTP/9V5k7UhofCscNhj2yx4xN2CzabElOHXWRxsx/YNroU69QwniImFB8Vui5vJzYcKxYRIJ66WTNQL5hL7p1WD9aYi9zQOtgPFGPNqecJ1sCj+tAB6J6erpj4FDcW3qh6TL5u1Mq/8yjn7BFBLBwhGDIWc4QAAAEkBAABQSwECLQMUAAgACAAAACEARgyFnOEAAABJAQAAEAAAAAAAAAAAACAApIEAAAAAYmFzaWMuam91cm5leS50c1BLBQYAAAAAAQABAD4AAAAfAQAAAAA=', - 'source.zip_url.folder': '', - 'source.zip_url.password': '', - 'source.zip_url.proxy_url': '', - 'source.zip_url.url': '', - 'source.zip_url.ssl.certificate': undefined, - 'source.zip_url.username': '', 'ssl.certificate': '', 'ssl.certificate_authorities': '', 'ssl.key': '', @@ -576,7 +569,6 @@ const payloadData = [ { ...DEFAULT_FIELDS[DataStream.BROWSER], __ui: { - is_zip_url_tls_enabled: false, script_source: { file_name: '', is_generated_script: false, @@ -609,11 +601,6 @@ const payloadData = [ 'source.inline.script': '', 'source.project.content': 'UEsDBBQACAAIAAAAIQAAAAAAAAAAAAAAAAAQAAAAYmFzaWMuam91cm5leS50c2WQQU7DQAxF9znFV8QiUUOmXcCCUMQl2NdMnWbKJDMaO6Ilyt0JASQkNv9Z1teTZWNAIqwP5kU4iZGOug863u7uDXsSddbIddCOl0kMX6iPnsVoOAYxryTO1ucwpoGvtUrm+hiSYsLProIoxwp8iWwVM9oUeuTP/9V5k7UhofCscNhj2yx4xN2CzabElOHXWRxsx/YNroU69QwniImFB8Vui5vJzYcKxYRIJ66WTNQL5hL7p1WD9aYi9zQOtgPFGPNqecJ1sCj+tAB6J6erpj4FDcW3qh6TL5u1Mq/8yjn7BFBLBwhGDIWc4QAAAEkBAABQSwECLQMUAAgACAAAACEARgyFnOEAAABJAQAAEAAAAAAAAAAAACAApIEAAAAAYmFzaWMuam91cm5leS50c1BLBQYAAAAAAQABAD4AAAAfAQAAAAA=', - 'source.zip_url.folder': '', - 'source.zip_url.password': '', - 'source.zip_url.proxy_url': '', - 'source.zip_url.url': '', - 'source.zip_url.username': '', 'ssl.certificate': '', 'ssl.certificate_authorities': '', 'ssl.key': '', diff --git a/x-pack/plugins/synthetics/server/synthetics_service/utils/secrets.ts b/x-pack/plugins/synthetics/server/synthetics_service/utils/secrets.ts index ed59f2043c9d79..d9a338e1767d93 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/utils/secrets.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/utils/secrets.ts @@ -27,15 +27,23 @@ export function formatSecrets(monitor: SyntheticsMonitor): SyntheticsMonitorWith export function normalizeSecrets( monitor: SavedObject ): SavedObject { - const defaultFields = DEFAULT_FIELDS[monitor.attributes[ConfigKey.MONITOR_TYPE]]; + const attributes = normalizeMonitorSecretAttributes(monitor.attributes); const normalizedMonitor = { ...monitor, - attributes: { - ...defaultFields, - ...monitor.attributes, - ...JSON.parse(monitor.attributes.secrets || ''), - }, + attributes, }; - delete normalizedMonitor.attributes.secrets; return normalizedMonitor; } + +export function normalizeMonitorSecretAttributes( + monitor: SyntheticsMonitorWithSecrets +): SyntheticsMonitor { + const defaultFields = DEFAULT_FIELDS[monitor[ConfigKey.MONITOR_TYPE]]; + const normalizedMonitorAttributes = { + ...defaultFields, + ...monitor, + ...JSON.parse(monitor.secrets || ''), + }; + delete normalizedMonitorAttributes.secrets; + return normalizedMonitorAttributes; +} diff --git a/x-pack/test/api_integration/apis/synthetics/add_monitor_project.ts b/x-pack/test/api_integration/apis/synthetics/add_monitor_project.ts index 4bc005c46596cf..2dc99487a138e4 100644 --- a/x-pack/test/api_integration/apis/synthetics/add_monitor_project.ts +++ b/x-pack/test/api_integration/apis/synthetics/add_monitor_project.ts @@ -144,7 +144,6 @@ export default function ({ getService }: FtrProviderContext) { expect(decryptedCreatedMonitor.body.attributes).to.eql({ __ui: { - is_zip_url_tls_enabled: false, script_source: { file_name: '', is_generated_script: false, @@ -189,11 +188,6 @@ export default function ({ getService }: FtrProviderContext) { }, screenshots: 'on', 'service.name': '', - 'source.zip_url.folder': '', - 'source.zip_url.proxy_url': '', - 'source.zip_url.url': '', - 'source.zip_url.password': '', - 'source.zip_url.username': '', synthetics_args: [], tags: [], 'throttling.config': '5d/3u/20l', diff --git a/x-pack/test/api_integration/apis/synthetics/add_monitor_project_legacy.ts b/x-pack/test/api_integration/apis/synthetics/add_monitor_project_legacy.ts index ff0c1bbf0f9a1d..b9b3d567c44aa4 100644 --- a/x-pack/test/api_integration/apis/synthetics/add_monitor_project_legacy.ts +++ b/x-pack/test/api_integration/apis/synthetics/add_monitor_project_legacy.ts @@ -129,7 +129,6 @@ export default function ({ getService }: FtrProviderContext) { expect(decryptedCreatedMonitor.body.attributes).to.eql({ __ui: { - is_zip_url_tls_enabled: false, script_source: { file_name: '', is_generated_script: false, @@ -174,11 +173,6 @@ export default function ({ getService }: FtrProviderContext) { }, screenshots: 'on', 'service.name': '', - 'source.zip_url.folder': '', - 'source.zip_url.proxy_url': '', - 'source.zip_url.url': '', - 'source.zip_url.password': '', - 'source.zip_url.username': '', synthetics_args: [], tags: [], 'throttling.config': '5d/3u/20l', 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 f5acb0eef3f8c7..0cebf231cf7872 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 @@ -160,7 +160,7 @@ export const getTestBrowserSyntheticsPolicy = ({ vars: { __ui: { value: - '{"script_source":{"is_generated_script":false,"file_name":""},"is_zip_url_tls_enabled":false,"is_tls_enabled":false}', + '{"script_source":{"is_generated_script":false,"file_name":""},"is_tls_enabled":false}', type: 'yaml', }, enabled: { value: true, type: 'bool' }, @@ -170,10 +170,10 @@ export const getTestBrowserSyntheticsPolicy = ({ 'service.name': { value: '', type: 'text' }, timeout: { value: '16s', type: 'text' }, tags: { value: '["cookie-test","browser"]', type: 'yaml' }, - 'source.zip_url.url': { value: '', type: 'text' }, - 'source.zip_url.username': { value: '', type: 'text' }, - 'source.zip_url.folder': { value: '', type: 'text' }, - 'source.zip_url.password': { value: '', type: 'password' }, + 'source.zip_url.url': { type: 'text' }, + 'source.zip_url.username': { type: 'text' }, + 'source.zip_url.folder': { type: 'text' }, + 'source.zip_url.password': { type: 'password' }, 'source.inline.script': { value: '"step(\\"Visit /users api route\\", async () => {\\\\n const response = await page.goto(\'https://nextjs-test-synthetics.vercel.app/api/users\');\\\\n expect(response.status()).toEqual(200);\\\\n});"', @@ -188,13 +188,13 @@ export const getTestBrowserSyntheticsPolicy = ({ 'throttling.config': { value: '5d/3u/20l', type: 'text' }, 'filter_journeys.tags': { value: null, type: 'yaml' }, 'filter_journeys.match': { value: null, type: 'text' }, - 'source.zip_url.ssl.certificate_authorities': { value: null, type: 'yaml' }, - 'source.zip_url.ssl.certificate': { value: null, type: 'yaml' }, - 'source.zip_url.ssl.key': { value: null, type: 'yaml' }, - 'source.zip_url.ssl.key_passphrase': { value: null, type: 'text' }, - 'source.zip_url.ssl.verification_mode': { value: null, type: 'text' }, - 'source.zip_url.ssl.supported_protocols': { value: null, type: 'yaml' }, - 'source.zip_url.proxy_url': { value: '', type: 'text' }, + 'source.zip_url.ssl.certificate_authorities': { type: 'yaml' }, + 'source.zip_url.ssl.certificate': { type: 'yaml' }, + 'source.zip_url.ssl.key': { type: 'yaml' }, + 'source.zip_url.ssl.key_passphrase': { type: 'text' }, + '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' }, config_id: { value: id, type: 'text' }, @@ -207,7 +207,6 @@ export const getTestBrowserSyntheticsPolicy = ({ compiled_stream: { __ui: { script_source: { is_generated_script: false, file_name: '' }, - is_zip_url_tls_enabled: false, is_tls_enabled: false, }, type: 'browser', 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 c2a433c6028204..cd5ea22451b927 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 @@ -185,8 +185,7 @@ export const getTestProjectSyntheticsPolicy = ( }, vars: { __ui: { - value: - '{"script_source":{"is_generated_script":false,"file_name":""},"is_zip_url_tls_enabled":false}', + value: '{"script_source":{"is_generated_script":false,"file_name":""}}', type: 'yaml', }, enabled: { value: true, type: 'bool' }, @@ -196,10 +195,10 @@ export const getTestProjectSyntheticsPolicy = ( 'service.name': { value: '', type: 'text' }, timeout: { value: null, type: 'text' }, tags: { value: null, type: 'yaml' }, - 'source.zip_url.url': { value: '', type: 'text' }, - 'source.zip_url.username': { value: '', type: 'text' }, - 'source.zip_url.folder': { value: '', type: 'text' }, - 'source.zip_url.password': { value: '', type: 'password' }, + 'source.zip_url.url': { type: 'text' }, + 'source.zip_url.username': { type: 'text' }, + 'source.zip_url.folder': { type: 'text' }, + 'source.zip_url.password': { type: 'password' }, 'source.inline.script': { value: null, type: 'yaml' }, 'source.project.content': { value: @@ -217,13 +216,13 @@ export const getTestProjectSyntheticsPolicy = ( 'throttling.config': { value: '5d/3u/20l', type: 'text' }, 'filter_journeys.tags': { value: null, type: 'yaml' }, 'filter_journeys.match': { value: '"check if title is present"', type: 'text' }, - 'source.zip_url.ssl.certificate_authorities': { value: null, type: 'yaml' }, - 'source.zip_url.ssl.certificate': { value: null, type: 'yaml' }, - 'source.zip_url.ssl.key': { value: null, type: 'yaml' }, - 'source.zip_url.ssl.key_passphrase': { value: null, type: 'text' }, - 'source.zip_url.ssl.verification_mode': { value: null, type: 'text' }, - 'source.zip_url.ssl.supported_protocols': { value: null, type: 'yaml' }, - 'source.zip_url.proxy_url': { value: '', type: 'text' }, + 'source.zip_url.ssl.certificate_authorities': { type: 'yaml' }, + 'source.zip_url.ssl.certificate': { type: 'yaml' }, + 'source.zip_url.ssl.key': { type: 'yaml' }, + 'source.zip_url.ssl.key_passphrase': { type: 'text' }, + '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' }, config_id: { value: configId, type: 'text' }, @@ -237,7 +236,6 @@ export const getTestProjectSyntheticsPolicy = ( compiled_stream: { __ui: { script_source: { is_generated_script: false, file_name: '' }, - is_zip_url_tls_enabled: false, }, type: 'browser', name: 'check if title is present', diff --git a/x-pack/test/api_integration/apis/uptime/rest/fixtures/browser_monitor.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/browser_monitor.json index e8776fa1874b4c..1a12efba9dc1c1 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/fixtures/browser_monitor.json +++ b/x-pack/test/api_integration/apis/uptime/rest/fixtures/browser_monitor.json @@ -21,14 +21,8 @@ "is_generated_script": false, "file_name": "" }, - "is_zip_url_tls_enabled": false, "is_tls_enabled": false }, - "source.zip_url.url": "", - "source.zip_url.username": "", - "source.zip_url.password": "", - "source.zip_url.folder": "", - "source.zip_url.proxy_url": "", "source.inline.script": "step(\"Visit /users api route\", async () => {\\n const response = await page.goto('https://nextjs-test-synthetics.vercel.app/api/users');\\n expect(response.status()).toEqual(200);\\n});", "source.project.content": "", "params": "", diff --git a/x-pack/test/api_integration/apis/uptime/rest/fixtures/tcp_monitor.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/tcp_monitor.json index 209ef89373736e..c3664c5646b16b 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/fixtures/tcp_monitor.json +++ b/x-pack/test/api_integration/apis/uptime/rest/fixtures/tcp_monitor.json @@ -11,8 +11,7 @@ "tags": [], "timeout": "16", "__ui": { - "is_tls_enabled": true, - "is_zip_url_tls_enabled": false + "is_tls_enabled": true }, "hosts": "example-host:40", "urls": "example-host:40",