Skip to content

Commit ad65b91

Browse files
committed
PR feedback
1 parent 035d994 commit ad65b91

6 files changed

Lines changed: 13 additions & 15 deletions

File tree

x-pack/platform/plugins/private/reporting/server/core.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -411,18 +411,16 @@ export class ReportingCore {
411411
return dataViews;
412412
}
413413

414-
public async getSoClient(request?: KibanaRequest) {
414+
public async getScopedSoClient(request: KibanaRequest) {
415415
const { savedObjects } = await this.getPluginStartDeps();
416+
return savedObjects.getScopedClient(request, {
417+
excludedExtensions: [SECURITY_EXTENSION_ID],
418+
includedHiddenTypes: [SCHEDULED_REPORT_SAVED_OBJECT_TYPE],
419+
});
420+
}
416421

417-
// if request is provided, use scoped client
418-
if (request) {
419-
return savedObjects.getScopedClient(request, {
420-
excludedExtensions: [SECURITY_EXTENSION_ID],
421-
includedHiddenTypes: [SCHEDULED_REPORT_SAVED_OBJECT_TYPE],
422-
});
423-
}
424-
425-
// otherwise use internal repository
422+
public async getInternalSoClient() {
423+
const { savedObjects } = await this.getPluginStartDeps();
426424
return savedObjects.createInternalRepository([SCHEDULED_REPORT_SAVED_OBJECT_TYPE]);
427425
}
428426

x-pack/platform/plugins/private/reporting/server/lib/tasks/run_scheduled_report.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe('Run Scheduled Report Task', () => {
107107
configType = createMockConfigSchema();
108108
mockReporting = await createMockReportingCore(configType);
109109

110-
soClient = await mockReporting.getSoClient();
110+
soClient = await mockReporting.getInternalSoClient();
111111
soClient.get = jest.fn().mockImplementation(async () => {
112112
return reportSO;
113113
});

x-pack/platform/plugins/private/reporting/server/lib/tasks/run_scheduled_report.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class RunScheduledReportTask extends RunReportTask<ScheduledReportTaskPar
4646
);
4747
}
4848

49-
const internalSoClient = await this.opts.reporting.getSoClient();
49+
const internalSoClient = await this.opts.reporting.getInternalSoClient();
5050
const reportSO = await internalSoClient.get<ScheduledReportType>(
5151
SCHEDULED_REPORT_SAVED_OBJECT_TYPE,
5252
reportSoId,

x-pack/platform/plugins/private/reporting/server/routes/common/request_handler/schedule_request_handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describe('Handle request to schedule', () => {
8181
mockContext = getMockContext();
8282
mockContext.reporting = Promise.resolve({} as ReportingSetup);
8383

84-
soClient = await reportingCore.getSoClient(fakeRawRequest as unknown as KibanaRequest);
84+
soClient = await reportingCore.getScopedSoClient(fakeRawRequest as unknown as KibanaRequest);
8585
soClient.create = jest.fn().mockImplementation(async (_, opts) => {
8686
return {
8787
id: 'foo',

x-pack/platform/plugins/private/reporting/server/routes/common/request_handler/schedule_request_handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class ScheduleRequestHandler extends RequestHandler<
111111
const { exportTypeId, jobParams, schedule, notification } = params;
112112
const { reporting, logger, req, user } = this.opts;
113113

114-
const soClient = await reporting.getSoClient(req);
114+
const soClient = await reporting.getScopedSoClient(req);
115115
const { version, job, jobType, name } = await this.createJob(exportTypeId, jobParams);
116116

117117
const payload = {

x-pack/platform/plugins/private/reporting/server/routes/internal/schedule/integration_tests/scheduling_from_jobparams.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe(`POST ${INTERNAL_ROUTES.SCHEDULE_PREFIX}`, () => {
103103
mockExportTypesRegistry = new ExportTypesRegistry();
104104
mockExportTypesRegistry.register(mockPdfExportType);
105105

106-
soClient = await reportingCore.getSoClient(fakeRawRequest as unknown as KibanaRequest);
106+
soClient = await reportingCore.getScopedSoClient(fakeRawRequest as unknown as KibanaRequest);
107107
soClient.create = jest.fn().mockImplementation(async (_, opts) => {
108108
return {
109109
id: 'foo',

0 commit comments

Comments
 (0)