Add getActionsHealth method to return permanent encryption key existence (#140535)

* add getActionsHealth method to return permanent encryption key existence
This commit is contained in:
Ersin Erdal 2022-09-14 17:10:04 +02:00 committed by GitHub
parent 02e1d7f2e0
commit 42e92926fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 0 deletions

View file

@ -28,6 +28,7 @@ const createSetupMock = () => {
isPreconfiguredConnector: jest.fn(),
getSubActionConnectorClass: jest.fn(),
getCaseConnectorClass: jest.fn(),
getActionsHealth: jest.fn(),
};
return mock;
};

View file

@ -472,5 +472,24 @@ describe('Actions Plugin', () => {
);
});
});
describe('getActionsHealth()', () => {
it('should return hasPermanentEncryptionKey false if canEncrypt of encryptedSavedObjects is false', async () => {
// coreMock.createSetup doesn't support Plugin generics
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const pluginSetup = await plugin.setup(coreSetup as any, pluginsSetup);
expect(pluginSetup.getActionsHealth()).toEqual({ hasPermanentEncryptionKey: false });
});
it('should return hasPermanentEncryptionKey true if canEncrypt of encryptedSavedObjects is true', async () => {
const pluginSetup = await plugin.setup(coreSetup, {
...pluginsSetup,
encryptedSavedObjects: {
...pluginsSetup.encryptedSavedObjects,
canEncrypt: true,
},
});
expect(pluginSetup.getActionsHealth()).toEqual({ hasPermanentEncryptionKey: true });
});
});
});
});

View file

@ -121,6 +121,7 @@ export interface PluginSetupContract {
isPreconfiguredConnector(connectorId: string): boolean;
getSubActionConnectorClass: <Config, Secrets>() => IServiceAbstract<Config, Secrets>;
getCaseConnectorClass: <Config, Secrets>() => IServiceAbstract<Config, Secrets>;
getActionsHealth: () => { hasPermanentEncryptionKey: boolean };
}
export interface PluginStartContract {
@ -375,6 +376,11 @@ export class ActionsPlugin implements Plugin<PluginSetupContract, PluginStartCon
},
getSubActionConnectorClass: () => SubActionConnector,
getCaseConnectorClass: () => CaseConnector,
getActionsHealth: () => {
return {
hasPermanentEncryptionKey: plugins.encryptedSavedObjects.canEncrypt,
};
},
};
}