import http from 'http' ; import getPort from 'get-port' ; import { FtrProviderContext } from '../../../../common/ftr_provider_context' ; import { getWebhookServer } from '../../../../common/fixtures/plugins/actions_simulators/server/plugin' ; export default function webhookTest ( { getService } ) { const supertest = getService ( 'supertest' ) ; describe ( 'webhook action' , ( ) => { let webhookSimulatorURL = '' ; let webhookServer ; before ( async ( ) => { webhookServer = await getWebhookServer ( ) ; const availablePort = await getPort ( { port : 9000 } ) ; webhookServer . listen ( availablePort ) ; webhookSimulatorURL = `http://localhost:${ availablePort }` ; } ) ; it ( 'should return 403 when creating a webhook action' , async ( ) => { await supertest . post ( '/api/actions/action' ) . set ( 'kbn-xsrf' , 'test' ) . send ( { name : 'A generic Webhook action' , actionTypeId : '.webhook' , secrets : { user : 'username' , password : 'mypassphrase' , } , config : { url : webhookSimulatorURL , } , } ) . expect ( 403 , { statusCode : 403 , error : 'Forbidden' , message : 'Action type .webhook is disabled because your basic license does not support it. Please upgrade your license.' , } ) ; } ) ; after ( ( ) => { webhookServer . close ( ) ; } ) ; } ) ; }