From 3c2f9470fb9b1be3b2ed90524868410204e12e5f Mon Sep 17 00:00:00 2001 From: Eyo Okon Eyo Date: Mon, 14 Oct 2024 18:10:15 +0100 Subject: [PATCH 1/4] prevent unhandled error --- .../screenshot/network_policy.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/screenshot/network_policy.ts b/x-pack/test/reporting_api_integration/reporting_and_security/screenshot/network_policy.ts index f608c8b7f250a..59ce1dfbf4b89 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/screenshot/network_policy.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/screenshot/network_policy.ts @@ -18,7 +18,7 @@ export default function ({ getService }: FtrProviderContext) { * The tests server config implements a network policy that is designed to disallow the following Canvas worksheet */ // Failing: See https://github.com/elastic/kibana/issues/193433 - describe.skip('Network Policy', () => { + describe.only('Network Policy', () => { before(async () => { await reportingAPI.initLogs(); // includes a canvas worksheet with an offending image URL }); @@ -27,20 +27,24 @@ export default function ({ getService }: FtrProviderContext) { await reportingAPI.teardownLogs(); }); - it('should fail job when page violates the network policy', async () => { + it('should fail job when page violates the network policy', async (done) => { const downloadPath = await reportingAPI.postJob( `/api/reporting/generate/printablePdfV2?jobParams=(layout:(dimensions:(height:720,width:1080),id:preserve_layout),locatorParams:!((id:CANVAS_APP_LOCATOR,params:(id:workpad-e7464259-0b75-4b8c-81c8-8422b15ff201,page:1,view:workpadPDF),version:'8.16.0')),objectType:'canvas workpad',title:'Workpad of Death',version:'8.16.0')` ); - // Retry the download URL until a "failed" response status is returned - let body: any; - await retry.tryForTime(120000, async () => { - body = (await supertest.get(downloadPath).expect(500)).body; - }); + try { + // Retry the download URL until a "failed" response status is returned + let body: any; + await retry.tryForTime(120000, async () => { + body = (await supertest.get(downloadPath).expect(500)).body; + }); - expect(body.message).to.match( - /Reporting generation failed: ReportingError\(code: disallowed_outgoing_url_error\)/ - ); + expect(body.message).to.match( + /Reporting generation failed: ReportingError\(code: disallowed_outgoing_url_error\)/ + ); + } catch (err) { + done(err); + } }); }); } From 44b1688dc07728147494db6cd096bf4fc19e2075 Mon Sep 17 00:00:00 2001 From: Eyo Okon Eyo Date: Mon, 14 Oct 2024 20:56:51 +0100 Subject: [PATCH 2/4] propagate error properly --- .../server/browsers/chromium/driver_factory/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/screenshotting/server/browsers/chromium/driver_factory/index.ts b/x-pack/plugins/screenshotting/server/browsers/chromium/driver_factory/index.ts index d8503b70ad963..06ed3e3b260bb 100644 --- a/x-pack/plugins/screenshotting/server/browsers/chromium/driver_factory/index.ts +++ b/x-pack/plugins/screenshotting/server/browsers/chromium/driver_factory/index.ts @@ -253,7 +253,7 @@ export class HeadlessChromiumDriverFactory { ); const error$ = Rx.concat(driver.screenshottingError$, this.getPageExit(browser, page)).pipe( - mergeMap((err) => Rx.throwError(err)) + mergeMap((err) => Rx.throwError(() => err)) ); const close = () => Rx.from(childProcess.kill()); From c87f658cecec6930976dda451c4db818eada7157 Mon Sep 17 00:00:00 2001 From: Eyo Okon Eyo Date: Mon, 14 Oct 2024 20:57:32 +0100 Subject: [PATCH 3/4] Revert "prevent unhandled error" This reverts commit 3c2f9470fb9b1be3b2ed90524868410204e12e5f. --- .../screenshot/network_policy.ts | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/screenshot/network_policy.ts b/x-pack/test/reporting_api_integration/reporting_and_security/screenshot/network_policy.ts index 59ce1dfbf4b89..f608c8b7f250a 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/screenshot/network_policy.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/screenshot/network_policy.ts @@ -18,7 +18,7 @@ export default function ({ getService }: FtrProviderContext) { * The tests server config implements a network policy that is designed to disallow the following Canvas worksheet */ // Failing: See https://github.com/elastic/kibana/issues/193433 - describe.only('Network Policy', () => { + describe.skip('Network Policy', () => { before(async () => { await reportingAPI.initLogs(); // includes a canvas worksheet with an offending image URL }); @@ -27,24 +27,20 @@ export default function ({ getService }: FtrProviderContext) { await reportingAPI.teardownLogs(); }); - it('should fail job when page violates the network policy', async (done) => { + it('should fail job when page violates the network policy', async () => { const downloadPath = await reportingAPI.postJob( `/api/reporting/generate/printablePdfV2?jobParams=(layout:(dimensions:(height:720,width:1080),id:preserve_layout),locatorParams:!((id:CANVAS_APP_LOCATOR,params:(id:workpad-e7464259-0b75-4b8c-81c8-8422b15ff201,page:1,view:workpadPDF),version:'8.16.0')),objectType:'canvas workpad',title:'Workpad of Death',version:'8.16.0')` ); - try { - // Retry the download URL until a "failed" response status is returned - let body: any; - await retry.tryForTime(120000, async () => { - body = (await supertest.get(downloadPath).expect(500)).body; - }); + // Retry the download URL until a "failed" response status is returned + let body: any; + await retry.tryForTime(120000, async () => { + body = (await supertest.get(downloadPath).expect(500)).body; + }); - expect(body.message).to.match( - /Reporting generation failed: ReportingError\(code: disallowed_outgoing_url_error\)/ - ); - } catch (err) { - done(err); - } + expect(body.message).to.match( + /Reporting generation failed: ReportingError\(code: disallowed_outgoing_url_error\)/ + ); }); }); } From e5f68903acb26c2cb969febb9128e8408d184094 Mon Sep 17 00:00:00 2001 From: Eyo Okon Eyo Date: Tue, 15 Oct 2024 12:03:21 +0100 Subject: [PATCH 4/4] make failing test suite exclusive for run --- .../reporting_and_security/screenshot/network_policy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/screenshot/network_policy.ts b/x-pack/test/reporting_api_integration/reporting_and_security/screenshot/network_policy.ts index f608c8b7f250a..4c1f6b9ca3190 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/screenshot/network_policy.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/screenshot/network_policy.ts @@ -18,7 +18,7 @@ export default function ({ getService }: FtrProviderContext) { * The tests server config implements a network policy that is designed to disallow the following Canvas worksheet */ // Failing: See https://github.com/elastic/kibana/issues/193433 - describe.skip('Network Policy', () => { + describe.only('Network Policy', () => { before(async () => { await reportingAPI.initLogs(); // includes a canvas worksheet with an offending image URL });