Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export interface ReportingServerInfo {
export interface ReportingHealthInfo {
isSufficientlySecure: boolean;
hasPermanentEncryptionKey: boolean;
areNotificationsEnabled: boolean;
}

export type IlmPolicyMigrationStatus = 'policy-not-found' | 'indices-not-managed-by-policy' | 'ok';
Expand Down
1 change: 1 addition & 0 deletions x-pack/platform/plugins/private/reporting/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"fieldFormats",
"home",
"management",
"notifications",
"licensing",
"uiActions",
"taskManager",
Expand Down
5 changes: 4 additions & 1 deletion x-pack/platform/plugins/private/reporting/server/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import type {
TaskManagerStartContract,
} from '@kbn/task-manager-plugin/server';
import type { UsageCounter } from '@kbn/usage-collection-plugin/server';
import type { NotificationsPluginStart } from '@kbn/notifications-plugin/server';

import { checkLicense } from '@kbn/reporting-server/check_license';
import { ExportTypesRegistry } from '@kbn/reporting-server/export_types_registry';
Expand Down Expand Up @@ -84,6 +85,7 @@ export interface ReportingInternalStart {
fieldFormats: FieldFormatsStart;
licensing: LicensingPluginStart;
logger: Logger;
notifications: NotificationsPluginStart;
screenshotting?: ScreenshottingStart;
securityService: SecurityServiceStart;
taskManager: TaskManagerStartContract;
Expand Down Expand Up @@ -258,7 +260,7 @@ export class ReportingCore {

public async getHealthInfo(): Promise<ReportingHealthInfo> {
const { encryptedSavedObjects } = this.getPluginSetupDeps();
const { securityService } = await this.getPluginStartDeps();
const { notifications, securityService } = await this.getPluginStartDeps();
const isSecurityEnabled = await this.isSecurityEnabled();

let isSufficientlySecure: boolean;
Expand All @@ -279,6 +281,7 @@ export class ReportingCore {
return {
isSufficientlySecure,
hasPermanentEncryptionKey: encryptedSavedObjects.canEncrypt,
areNotificationsEnabled: notifications.isEmailServiceAvailable(),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,11 @@ describe('Execute Report Task', () => {
});

it('schedules task with request if health indicates security and api keys are enabled', async () => {
jest
.spyOn(mockReporting, 'getHealthInfo')
.mockResolvedValueOnce({ isSufficientlySecure: true, hasPermanentEncryptionKey: true });
jest.spyOn(mockReporting, 'getHealthInfo').mockResolvedValueOnce({
isSufficientlySecure: true,
hasPermanentEncryptionKey: true,
areNotificationsEnabled: true,
});
const task = new ExecuteReportTask(mockReporting, configType, logger);
const mockTaskManager = taskManagerMock.createStart();
await task.init(mockTaskManager);
Expand Down Expand Up @@ -201,9 +203,11 @@ describe('Execute Report Task', () => {
});

it('schedules task without request if health indicates security is disabled', async () => {
jest
.spyOn(mockReporting, 'getHealthInfo')
.mockResolvedValueOnce({ isSufficientlySecure: false, hasPermanentEncryptionKey: true });
jest.spyOn(mockReporting, 'getHealthInfo').mockResolvedValueOnce({
isSufficientlySecure: false,
hasPermanentEncryptionKey: true,
areNotificationsEnabled: false,
});
const task = new ExecuteReportTask(mockReporting, configType, logger);
const mockTaskManager = taskManagerMock.createStart();
await task.init(mockTaskManager);
Expand All @@ -229,9 +233,11 @@ describe('Execute Report Task', () => {
});

it('schedules task without request if health indicates no permanent encryption key', async () => {
jest
.spyOn(mockReporting, 'getHealthInfo')
.mockResolvedValueOnce({ isSufficientlySecure: true, hasPermanentEncryptionKey: false });
jest.spyOn(mockReporting, 'getHealthInfo').mockResolvedValueOnce({
isSufficientlySecure: true,
hasPermanentEncryptionKey: false,
areNotificationsEnabled: true,
});
const task = new ExecuteReportTask(mockReporting, configType, logger);
const mockTaskManager = taskManagerMock.createStart();
await task.init(mockTaskManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const registerHealthRoute = (reporting: ReportingCore, logger: Logger) =>
body: {
has_permanent_encryption_key: healthInfo.hasPermanentEncryptionKey,
is_sufficiently_secure: healthInfo.isSufficientlySecure,
are_notifications_enabled: healthInfo.areNotificationsEnabled,
},
});
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { setFieldFormats } from '@kbn/reporting-server';
import { createMockScreenshottingStart } from '@kbn/screenshotting-plugin/server/mock';
import { securityMock } from '@kbn/security-plugin/server/mocks';
import { taskManagerMock } from '@kbn/task-manager-plugin/server/mocks';
import { notificationsMock } from '@kbn/notifications-plugin/server/mocks';
import { ReportingCore } from '..';

import type { ReportingInternalSetup, ReportingInternalStart } from '../core';
Expand Down Expand Up @@ -76,6 +77,7 @@ export const createMockPluginStart = async (
data: dataPluginMock.createStartContract(),
fieldFormats: () => Promise.resolve(fieldFormatsMock),
store: await createMockReportingStore(config),
notifications: notificationsMock.createStart(),
taskManager: {
schedule: jest.fn().mockImplementation(() => ({ id: 'taskId' })),
ensureScheduled: jest.fn(),
Expand Down
2 changes: 2 additions & 0 deletions x-pack/platform/plugins/private/reporting/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import type {
TaskManagerStartContract,
} from '@kbn/task-manager-plugin/server';
import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/server';
import type { NotificationsPluginStart } from '@kbn/notifications-plugin/server';

import { ExportTypesRegistry } from '@kbn/reporting-server/export_types_registry';
import type { AuthenticatedUser } from '@kbn/core-security-common';
Expand Down Expand Up @@ -67,6 +68,7 @@ export interface ReportingStartDeps {
discover: DiscoverServerPluginStart;
fieldFormats: FieldFormatsStart;
licensing: LicensingPluginStart;
notifications: NotificationsPluginStart;
taskManager: TaskManagerStartContract;
screenshotting?: ScreenshottingStart;
}
Expand Down
1 change: 1 addition & 0 deletions x-pack/platform/plugins/private/reporting/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@kbn/react-kibana-mount",
"@kbn/core-security-common",
"@kbn/core-http-server-utils",
"@kbn/notifications-plugin",
],
"exclude": [
"target/**/*",
Expand Down