import expect from '@kbn/expect' ; import { UserAtSpaceScenarios } from '../../scenarios' ; import { getUrlPrefix } from '../../../common/lib/space_test_utils' ; import { FtrProviderContext } from '../../../common/ftr_provider_context' ; export default function listActionTypesTests ( { getService } ) { const supertestWithoutAuth = getService ( 'supertestWithoutAuth' ) ; describe ( 'connector_types' , ( ) => { for ( const scenario of UserAtSpaceScenarios ) { const { user , space } = scenario ; describe ( scenario . id , ( ) => { it ( 'should return 200 with list of action types containing defaults' , async ( ) => { const response = await supertestWithoutAuth . get ( `${ getUrlPrefix ( space . id ) }/api/actions/connector_types` ) . auth ( user . username , user . password ) ; function createActionTypeMatcher ( id , name ) { return ( actionType ) => { return actionType . id === id && actionType . name === name ; } ; } expect ( response . statusCode ) . to . eql ( 200 ) ; switch ( scenario . id ) { case 'no_kibana_privileges at space1' : case 'space_1_all_alerts_none_actions at space1' : case 'space_1_all at space2' : case 'global_read at space1' : case 'superuser at space1' : case 'space_1_all at space1' : case 'space_1_all_with_restricted_fixture at space1' : expect ( response . statusCode ) . to . eql ( 200 ) ; expect ( response . body . some ( createActionTypeMatcher ( 'test.index-record' , 'Test: Index Record' ) ) ) . to . be ( true ) ; break ; default : throw new Error ( `Scenario untested: ${ JSON . stringify ( scenario ) }` ) ; } } ) ; } ) ; } } ) ; }