|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License; |
| 4 | + * you may not use this file except in compliance with the Elastic License. |
| 5 | + */ |
| 6 | + |
| 7 | +import expect from '@kbn/expect/expect.js'; |
| 8 | +import { FtrProviderContext } from '../../ftr_provider_context'; |
| 9 | + |
| 10 | +export default function ({ getService }: FtrProviderContext) { |
| 11 | + const supertest = getService('supertest'); |
| 12 | + |
| 13 | + describe('Privileges registration', function () { |
| 14 | + this.tags(['skipCloud']); |
| 15 | + |
| 16 | + it('privileges are re-registered on license downgrade', async () => { |
| 17 | + // Verify currently registered privileges for TRIAL license. |
| 18 | + // If you're adding a privilege to the following, that's great! |
| 19 | + // If you're removing a privilege, this breaks backwards compatibility |
| 20 | + // Roles are associated with these privileges, and we shouldn't be removing them in a minor version. |
| 21 | + const expectedTrialLicenseDiscoverPrivileges = [ |
| 22 | + 'all', |
| 23 | + 'read', |
| 24 | + 'minimal_all', |
| 25 | + 'minimal_read', |
| 26 | + 'url_create', |
| 27 | + ]; |
| 28 | + const trialPrivileges = await supertest |
| 29 | + .get('/api/security/privileges') |
| 30 | + .set('kbn-xsrf', 'xxx') |
| 31 | + .send() |
| 32 | + .expect(200); |
| 33 | + |
| 34 | + expect(trialPrivileges.body.features.discover).to.eql(expectedTrialLicenseDiscoverPrivileges); |
| 35 | + |
| 36 | + // Revert license to basic. |
| 37 | + await supertest |
| 38 | + .post('/api/license/start_basic?acknowledge=true') |
| 39 | + .set('kbn-xsrf', 'xxx') |
| 40 | + .expect(200, { |
| 41 | + basic_was_started: true, |
| 42 | + acknowledged: true, |
| 43 | + }); |
| 44 | + |
| 45 | + // Verify that privileges were re-registered. |
| 46 | + const expectedBasicLicenseDiscoverPrivileges = ['all', 'read']; |
| 47 | + const basicPrivileges = await supertest |
| 48 | + .get('/api/security/privileges') |
| 49 | + .set('kbn-xsrf', 'xxx') |
| 50 | + .send() |
| 51 | + .expect(200); |
| 52 | + |
| 53 | + expect(basicPrivileges.body.features.discover).to.eql(expectedBasicLicenseDiscoverPrivileges); |
| 54 | + }); |
| 55 | + }); |
| 56 | +} |
0 commit comments