import expect from '@kbn/expect' ; import { FtrProviderContext } from '../ftr_provider_context' ; import { deletePolicyStream } from './data_stream_helper' ; export default function ( { getService } ) { const esArchiver = getService ( 'esArchiver' ) ; const supertest = getService ( 'supertest' ) ; describe ( 'Endpoint policy api' , ( ) => { describe ( 'GET /api/endpoint/policy_response' , ( ) => { before ( async ( ) => await esArchiver . load ( 'x-pack/test/functional/es_archives/endpoint/policy' , { useCreate : true , } ) ) ; after ( async ( ) => await deletePolicyStream ( getService ) ) ; it ( 'should return one policy response for an id' , async ( ) => { const expectedAgentId = 'a10ac658-a3bc-4ac6-944a-68d9bd1c5a5e' ; const { body } = await supertest . get ( `/api/endpoint/policy_response?agentId=${ expectedAgentId }` ) . send ( ) . expect ( 200 ) ; expect ( body . policy_response . agent . id ) . to . eql ( expectedAgentId ) ; expect ( body . policy_response . Endpoint . policy ) . to . not . be ( undefined ) ; } ) ; it ( 'should return not found if host has no policy response' , async ( ) => { const { body } = await supertest . get ( `/api/endpoint/policy_response?agentId=bad_id` ) . send ( ) . expect ( 404 ) ; expect ( body . message ) . to . contain ( 'Policy Response Not Found' ) ; } ) ; } ) ; } ) ; }