Skip to content

Commit

Permalink
add 3 scenario for licensing plugins: server, client, legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Dec 13, 2019
1 parent b74a8c8 commit 9483684
Show file tree
Hide file tree
Showing 13 changed files with 436 additions and 181 deletions.
177 changes: 0 additions & 177 deletions x-pack/test/licensing_plugin/apis/changes.ts

This file was deleted.

15 changes: 15 additions & 0 deletions x-pack/test/licensing_plugin/config.legacy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { FtrConfigProviderContext } from '@kbn/test/types/ftr';

export default async function({ readConfigFile }: FtrConfigProviderContext) {
const commonConfig = await readConfigFile(require.resolve('./config'));

return {
...commonConfig.getAll(),
testFiles: [require.resolve('./legacy')],
};
}
26 changes: 26 additions & 0 deletions x-pack/test/licensing_plugin/config.public.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import path from 'path';
import { KIBANA_ROOT } from '@kbn/test';
import { FtrConfigProviderContext } from '@kbn/test/types/ftr';

export default async function({ readConfigFile }: FtrConfigProviderContext) {
const commonConfig = await readConfigFile(require.resolve('./config'));

return {
...commonConfig.getAll(),
testFiles: [require.resolve('./public')],
kbnTestServer: {
serverArgs: [
...commonConfig.get('kbnTestServer.serverArgs'),
`--plugin-path=${path.resolve(
KIBANA_ROOT,
'test/plugin_functional/plugins/core_provider_plugin'
)}`,
],
},
};
}
4 changes: 2 additions & 2 deletions x-pack/test/licensing_plugin/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default async function({ readConfigFile }: FtrConfigProviderContext) {
};

return {
testFiles: [require.resolve('./apis')],
testFiles: [require.resolve('./server')],
servers,
services,
pageObjects,
Expand All @@ -43,7 +43,7 @@ export default async function({ readConfigFile }: FtrConfigProviderContext) {
...functionalTestsConfig.get('kbnTestServer'),
serverArgs: [
...functionalTestsConfig.get('kbnTestServer.serverArgs'),
'--xpack.licensing.api_polling_frequency=300',
'--xpack.licensing.api_polling_frequency=100',
],
},

Expand Down
16 changes: 16 additions & 0 deletions x-pack/test/licensing_plugin/legacy/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { FtrProviderContext } from '../services';

// eslint-disable-next-line import/no-default-export
export default function({ loadTestFile }: FtrProviderContext) {
describe('Legacy licensing plugin', function() {
this.tags('ciGroup2');
// MUST BE LAST! CHANGES LICENSE TYPE!
loadTestFile(require.resolve('./updates'));
});
}
71 changes: 71 additions & 0 deletions x-pack/test/licensing_plugin/legacy/updates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../services';
import { createScenario } from '../scenario';
import '../../../../test/plugin_functional/plugins/core_provider_plugin/types';

// eslint-disable-next-line import/no-default-export
export default function(ftrContext: FtrProviderContext) {
const { getService } = ftrContext;
const supertest = getService('supertest');
const testSubjects = getService('testSubjects');

const scenario = createScenario(ftrContext);

describe('changes in license types', () => {
after(async () => {
await scenario.startBasic();
});

it('provides changes in license types', async () => {
await scenario.setup();
await scenario.waitForPluginToDetectLicenseUpdate();

const {
body: legacyInitialLicense,
headers: legacyInitialLicenseHeaders,
} = 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');

// server allows to request trial only once.
// other attempts will throw 403
await scenario.startTrial();
await scenario.waitForPluginToDetectLicenseUpdate();

const { body: legacyTrialLicense, headers: legacyTrialLicenseHeaders } = await supertest
.get('/api/xpack/v1/info')
.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']
);

await scenario.startBasic();
await scenario.waitForPluginToDetectLicenseUpdate();

const { body: legacyBasicLicense, headers: legacyBasicLicenseHeaders } = await supertest
.get('/api/xpack/v1/info')
.expect(200);
expect(legacyBasicLicense.license?.type).to.be('basic');
expect(legacyBasicLicense.features).to.have.property('security');
expect(legacyBasicLicenseHeaders['kbn-xpack-sig']).to.not.be(
legacyInitialLicenseHeaders['kbn-xpack-sig']
);

await scenario.deleteLicense();
await scenario.waitForPluginToDetectLicenseUpdate();

// banner shown only when license expired not just deleted
await testSubjects.missingOrFail('licenseExpiredBanner');
});
});
}
16 changes: 16 additions & 0 deletions x-pack/test/licensing_plugin/public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { FtrProviderContext } from '../services';

// eslint-disable-next-line import/no-default-export
export default function({ loadTestFile }: FtrProviderContext) {
describe('Licensing plugin public client', function() {
this.tags('ciGroup2');
// MUST BE LAST! CHANGES LICENSE TYPE!
loadTestFile(require.resolve('./updates'));
});
}
Loading

0 comments on commit 9483684

Please sign in to comment.