diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/security_roles_privileges.ts b/x-pack/test/reporting_api_integration/reporting_and_security/security_roles_privileges.ts index ec526ac1cd272..1ad7379aa184e 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/security_roles_privileges.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/security_roles_privileges.ts @@ -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 () => { @@ -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, { @@ -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, { @@ -54,7 +54,7 @@ export default function ({ getService }: FtrProviderContext) { browserTimezone: 'UTC', title: 'testfooyu78yt90-', } - )) as supertest.Response; + ); expect(res.status).to.eql(200); }); }); @@ -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/); + }); + }); }); }