import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../ftr_provider_context' ; export default function ( { getService } ) { const supertest = getService ( 'supertest' ) ; describe ( 'Builtin ES Privileges' , ( ) => { describe ( 'GET /internal/security/esPrivileges/builtin' , ( ) => { it ( 'should return a list of available builtin privileges' , async ( ) => { await supertest . get ( '/internal/security/esPrivileges/builtin' ) . set ( 'kbn-xsrf' , 'xxx' ) . send ( ) . expect ( 200 ) . then ( ( response ) => { const sampleOfExpectedClusterPrivileges = [ 'all' , 'manage' , 'monitor' ] ; const sampleOfExpectedIndexPrivileges = [ 'create' , 'index' , 'delete' ] ; const payload = response . body ; expect ( Object . keys ( payload ) . sort ( ) ) . to . eql ( [ 'cluster' , 'index' ] ) ; sampleOfExpectedClusterPrivileges . forEach ( ( privilege ) => expect ( payload . cluster ) . to . contain ( privilege ) ) ; sampleOfExpectedIndexPrivileges . forEach ( ( privilege ) => expect ( payload . index ) . to . contain ( privilege ) ) ; expect ( payload . cluster ) . not . to . contain ( 'none' ) ; expect ( payload . index ) . not . to . contain ( 'none' ) ; } ) ; } ) ; } ) ; } ) ; }