Skip to content

Commit

Permalink
[Reporting] Increase functional tests on feature priviliges (#117443) (
Browse files Browse the repository at this point in the history
…#117896)

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
tsullivan and kibanamachine authored Nov 9, 2021
1 parent 2ca2788 commit d801c82
Showing 1 changed file with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import expect from '@kbn/expect';
import { SearchSourceFields } from 'src/plugins/data/common';
import supertest from 'supertest';
import { FtrProviderContext } from '../ftr_provider_context';

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

describe('Security Roles and Privileges for Applications', () => {
before(async () => {
Expand All @@ -25,7 +25,7 @@ export default function ({ getService }: FtrProviderContext) {

describe('Dashboard: CSV download file', () => {
it('does not allow user that does not have the role-based privilege', async () => {
const res = (await reportingAPI.downloadCsv(
const res = await reportingAPI.downloadCsv(
reportingAPI.DATA_ANALYST_USERNAME,
reportingAPI.DATA_ANALYST_PASSWORD,
{
Expand All @@ -37,12 +37,12 @@ export default function ({ getService }: FtrProviderContext) {
browserTimezone: 'UTC',
title: 'testfooyu78yt90-',
}
)) as supertest.Response;
);
expect(res.status).to.eql(403);
});

it('does allow user with the role privilege', async () => {
const res = (await reportingAPI.downloadCsv(
const res = await reportingAPI.downloadCsv(
reportingAPI.REPORTING_USER_USERNAME,
reportingAPI.REPORTING_USER_PASSWORD,
{
Expand All @@ -54,7 +54,7 @@ export default function ({ getService }: FtrProviderContext) {
browserTimezone: 'UTC',
title: 'testfooyu78yt90-',
}
)) as supertest.Response;
);
expect(res.status).to.eql(200);
});
});
Expand Down Expand Up @@ -197,5 +197,21 @@ export default function ({ getService }: FtrProviderContext) {
expect(res.status).to.eql(200);
});
});

// This tests the same API as x-pack/test/api_integration/apis/security/privileges.ts, but it uses the non-deprecated config
it('should register reporting privileges with the security privileges API', async () => {
await supertest
.get('/api/security/privileges')
.set('kbn-xsrf', 'xxx')
.send()
.expect(200)
.expect((res) => {
expect(res.body.features.canvas).match(/generate_report/);
expect(res.body.features.dashboard).match(/download_csv_report/);
expect(res.body.features.dashboard).match(/generate_report/);
expect(res.body.features.discover).match(/generate_report/);
expect(res.body.features.visualize).match(/generate_report/);
});
});
});
}

0 comments on commit d801c82

Please sign in to comment.