import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../../ftr_provider_context' ; export default function ( { getPageObjects , getService } ) { const security = getService ( 'security' ) ; const PageObjects = getPageObjects ( [ 'common' , 'settings' , 'security' ] ) ; const appsMenu = getService ( 'appsMenu' ) ; const managementMenu = getService ( 'managementMenu' ) ; describe ( 'security' , ( ) => { before ( async ( ) => { await PageObjects . common . navigateToApp ( 'home' ) ; } ) ; describe ( 'global all privileges (aka kibana_admin)' , ( ) => { before ( async ( ) => { await security . testUser . setRoles ( [ 'kibana_admin' ] , true ) ; } ) ; after ( async ( ) => { await security . testUser . restoreDefaults ( ) ; } ) ; it ( 'should show the Stack Management nav link' , async ( ) => { const links = await appsMenu . readLinks ( ) ; expect ( links . map ( ( link ) => link . text ) ) . to . contain ( 'Stack Management' ) ; } ) ; it ( 'should not render the "Security" section' , async ( ) => { await PageObjects . common . navigateToApp ( 'management' ) ; const sections = ( await managementMenu . getSections ( ) ) . map ( ( section ) => section . sectionId ) ; expect ( sections ) . to . eql ( [ 'insightsAndAlerting' , 'kibana' ] ) ; } ) ; } ) ; describe ( 'global dashboard read with manage_security' , ( ) => { before ( async ( ) => { await security . testUser . setRoles ( [ 'global_dashboard_read' , 'manage_security' ] , true ) ; } ) ; after ( async ( ) => { await security . testUser . restoreDefaults ( ) ; } ) ; it ( 'should show the Stack Management nav link' , async ( ) => { const links = await appsMenu . readLinks ( ) ; expect ( links . map ( ( link ) => link . text ) ) . to . contain ( 'Stack Management' ) ; } ) ; it ( 'should render the "Security" section with API Keys' , async ( ) => { await PageObjects . common . navigateToApp ( 'management' ) ; const sections = await managementMenu . getSections ( ) ; expect ( sections ) . to . have . length ( 1 ) ; expect ( sections [ 0 ] ) . to . eql ( { sectionId : 'security' , sectionLinks : [ 'users' , 'roles' , 'api_keys' , 'role_mappings' ] , } ) ; } ) ; } ) ; } ) ; }