-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Review#1: dont unsubscribe from ES status and license changes after i…
…nitial registration + add API integration tests for the license downgrade scenario.
- Loading branch information
Showing
8 changed files
with
111 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
x-pack/test/api_integration/apis/security/license_downgrade.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* 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/expect.js'; | ||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default function ({ getService }: FtrProviderContext) { | ||
const supertest = getService('supertest'); | ||
|
||
describe('Privileges registration', function () { | ||
this.tags(['skipCloud']); | ||
|
||
it('privileges are re-registered on license downgrade', async () => { | ||
// Verify currently registered privileges for TRIAL license. | ||
// If you're adding a privilege to the following, that's great! | ||
// If you're removing a privilege, this breaks backwards compatibility | ||
// Roles are associated with these privileges, and we shouldn't be removing them in a minor version. | ||
const expectedTrialLicenseDiscoverPrivileges = [ | ||
'all', | ||
'read', | ||
'minimal_all', | ||
'minimal_read', | ||
'url_create', | ||
]; | ||
const trialPrivileges = await supertest | ||
.get('/api/security/privileges') | ||
.set('kbn-xsrf', 'xxx') | ||
.send() | ||
.expect(200); | ||
|
||
expect(trialPrivileges.body.features.discover).to.eql(expectedTrialLicenseDiscoverPrivileges); | ||
|
||
// Revert license to basic. | ||
await supertest | ||
.post('/api/license/start_basic?acknowledge=true') | ||
.set('kbn-xsrf', 'xxx') | ||
.expect(200, { | ||
basic_was_started: true, | ||
acknowledged: true, | ||
}); | ||
|
||
// Verify that privileges were re-registered. | ||
const expectedBasicLicenseDiscoverPrivileges = ['all', 'read']; | ||
const basicPrivileges = await supertest | ||
.get('/api/security/privileges') | ||
.set('kbn-xsrf', 'xxx') | ||
.send() | ||
.expect(200); | ||
|
||
expect(basicPrivileges.body.features.discover).to.eql(expectedBasicLicenseDiscoverPrivileges); | ||
}); | ||
}); | ||
} |
16 changes: 16 additions & 0 deletions
16
x-pack/test/api_integration/apis/security/security_trial.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 '../../ftr_provider_context'; | ||
|
||
export default function ({ loadTestFile }: FtrProviderContext) { | ||
describe('security (trial license)', function () { | ||
this.tags('ciGroup6'); | ||
|
||
// THIS TEST NEEDS TO BE LAST. IT IS DESTRUCTIVE! IT REMOVES TRIAL LICENSE!!! | ||
loadTestFile(require.resolve('./license_downgrade')); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/* eslint-disable import/no-default-export */ | ||
|
||
import { FtrConfigProviderContext } from '@kbn/test/types/ftr'; | ||
import { default as createTestConfig } from './config'; | ||
|
||
export default async function (context: FtrConfigProviderContext) { | ||
return createTestConfig(context).then((config) => { | ||
config.testFiles = [require.resolve('./apis/security/security_trial')]; | ||
return config; | ||
}); | ||
} |