Fix getting security license status lazily (#67320) (#67352)

# Conflicts:
#	x-pack/plugins/ingest_pipelines/server/plugin.ts
#	x-pack/plugins/ingest_pipelines/server/routes/api/privileges.ts
#	x-pack/plugins/ingest_pipelines/server/types.ts
#	x-pack/plugins/snapshot_restore/server/plugin.ts
This commit is contained in:
Jean-Louis Leysens 2020-05-27 09:31:04 +02:00 committed by GitHub
parent a19355a490
commit 67eba4735a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 4 deletions

View file

@ -84,7 +84,8 @@ export class SnapshotRestoreServerPlugin implements Plugin<void, void, any, any>
router,
license: this.license,
config: {
isSecurityEnabled: security !== undefined && security.__legacyCompat.license.isEnabled(),
isSecurityEnabled: () =>
security !== undefined && security.__legacyCompat.license.isEnabled(),
isCloudEnabled: cloud !== undefined && cloud.isCloudEnabled,
isSlmEnabled: pluginConfig.slm_ui.enabled,
},

View file

@ -39,7 +39,7 @@ export function registerAppRoutes({
},
};
if (!isSecurityEnabled) {
if (!isSecurityEnabled()) {
// If security isn't enabled, let the user use app.
return res.ok({ body: privilegesResult });
}

View file

@ -12,7 +12,7 @@ license.getStatus = jest.fn().mockReturnValue({ isValid: true });
export const routeDependencies = {
license,
config: {
isSecurityEnabled: true,
isSecurityEnabled: jest.fn().mockReturnValue(true),
isCloudEnabled: false,
isSlmEnabled: true,
},

View file

@ -21,7 +21,7 @@ export interface RouteDependencies {
license: License;
config: {
isSlmEnabled: boolean;
isSecurityEnabled: boolean;
isSecurityEnabled: () => boolean;
isCloudEnabled: boolean;
};
lib: {