diff --git a/x-pack/plugins/licensing/server/plugin.test.ts b/x-pack/plugins/licensing/server/plugin.test.ts index b1669db00f227..7aec81f84f978 100644 --- a/x-pack/plugins/licensing/server/plugin.test.ts +++ b/x-pack/plugins/licensing/server/plugin.test.ts @@ -81,6 +81,25 @@ describe('licensing plugin', () => { expect(license.isAvailable).toBe(true); }); + it('calls `callAsInternalUser` with the correct parameters', async () => { + const esClient = elasticsearchServiceMock.createLegacyClusterClient(); + esClient.callAsInternalUser.mockResolvedValue({ + license: buildRawLicense(), + features: {}, + }); + + const coreSetup = createCoreSetupWith(esClient); + await plugin.setup(coreSetup); + const { license$ } = await plugin.start(); + await license$.pipe(take(1)).toPromise(); + + expect(esClient.callAsInternalUser).toHaveBeenCalledTimes(1); + expect(esClient.callAsInternalUser).toHaveBeenCalledWith('transport.request', { + method: 'GET', + path: '/_xpack?accept_enterprise=true', + }); + }); + it('observable receives updated licenses', async () => { const types: LicenseType[] = ['basic', 'gold', 'platinum']; diff --git a/x-pack/plugins/licensing/server/plugin.ts b/x-pack/plugins/licensing/server/plugin.ts index 2ee8d26419571..3823f251fb7fb 100644 --- a/x-pack/plugins/licensing/server/plugin.ts +++ b/x-pack/plugins/licensing/server/plugin.ts @@ -182,7 +182,7 @@ export class LicensingPlugin implements Plugin { + await scenario.startEnterprise(); + await scenario.waitForPluginToDetectLicenseUpdate(); + + const enterpriseLicense = await scenario.getLicense(); + expect(enterpriseLicense.license?.type).to.be('enterprise'); + }); }); }