Skip to content

Commit

Permalink
Remove unused license check result from LP Security plugin (elastic#6…
Browse files Browse the repository at this point in the history
…6966)

* remove unused license check result

* remove outdated test

* update licensing tests
  • Loading branch information
mshustov committed May 20, 2020
1 parent 47facb8 commit c2b95e4
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 22 deletions.
8 changes: 0 additions & 8 deletions x-pack/legacy/plugins/security/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ export const security = (kibana: Record<string, any>) =>
auditLogger: new AuditLogger(server, 'security', server.config(), xpackInfo),
});

// Legacy xPack Info endpoint returns whatever we return in a callback for `registerLicenseCheckResultsGenerator`
// and the result is consumed by the legacy plugins all over the place, so we should keep it here for now. We assume
// that when legacy callback is called license has been already propagated to the new platform security plugin and
// features are up to date.
xpackInfo
.feature(this.id)
.registerLicenseCheckResultsGenerator(() => securityPlugin.license.getFeatures());

server.expose({
getUser: async (request: LegacyRequest) =>
securityPlugin.authc.getCurrentUser(KibanaRequest.from(request)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,6 @@ describe('replaceInjectedVars uiExport', () => {
},
});
});

it('sends the originalInjectedVars if the license check result is not available', async () => {
const originalInjectedVars = { a: 1 };
const request = buildRequest();
const server = mockServer();
server.plugins.xpack_main.info.feature().getLicenseCheckResults.returns(undefined);

const newVars = await replaceInjectedVars(originalInjectedVars, request, server);
expect(newVars).to.eql(originalInjectedVars);
});
});

// creates a mock server object that defaults to being authenticated with a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function replaceInjectedVars(originalInjectedVars, request, server)
}

// not enough license info to make decision one way or another
if (!xpackInfo.isAvailable() || !xpackInfo.feature('security').getLicenseCheckResults()) {
if (!xpackInfo.isAvailable()) {
return originalInjectedVars;
}

Expand Down
3 changes: 0 additions & 3 deletions x-pack/test/licensing_plugin/legacy/updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default function(ftrContext: FtrProviderContext) {
} = await supertest.get('/api/xpack/v1/info').expect(200);

expect(legacyInitialLicense.license?.type).to.be('basic');
expect(legacyInitialLicense.features).to.have.property('security');
expect(legacyInitialLicenseHeaders['kbn-xpack-sig']).to.be.a('string');

await scenario.startTrial();
Expand All @@ -42,7 +41,6 @@ export default function(ftrContext: FtrProviderContext) {
.expect(200);

expect(legacyTrialLicense.license?.type).to.be('trial');
expect(legacyTrialLicense.features).to.have.property('security');
expect(legacyTrialLicenseHeaders['kbn-xpack-sig']).to.not.be(
legacyInitialLicenseHeaders['kbn-xpack-sig']
);
Expand All @@ -52,7 +50,6 @@ export default function(ftrContext: FtrProviderContext) {

const { body: legacyBasicLicense } = await supertest.get('/api/xpack/v1/info').expect(200);
expect(legacyBasicLicense.license?.type).to.be('basic');
expect(legacyBasicLicense.features).to.have.property('security');

// banner shown only when license expired not just deleted
await testSubjects.missingOrFail('licenseExpiredBanner');
Expand Down

0 comments on commit c2b95e4

Please sign in to comment.