import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../../../common/ftr_provider_context' ; import { postCaseResp , getPostCaseRequest , nullUser } from '../../../../common/lib/mock' ; import { deleteCasesByESQuery , createCase , getCase , removeServerGeneratedPropertiesFromCase , getAuthWithSuperUser , } from '../../../../common/lib/utils' ; export default ( { getService } ) : void => { const supertest = getService ( 'supertest' ) ; const es = getService ( 'es' ) ; const authSpace1 = getAuthWithSuperUser ( ) ; describe ( 'get_case' , ( ) => { afterEach ( async ( ) => { await deleteCasesByESQuery ( es ) ; } ) ; it ( 'should return a case in space1' , async ( ) => { const postedCase = await createCase ( supertest , getPostCaseRequest ( ) , 200 , authSpace1 ) ; const theCase = await getCase ( { supertest , caseId : postedCase . id , auth : authSpace1 } ) ; const data = removeServerGeneratedPropertiesFromCase ( theCase ) ; expect ( data ) . to . eql ( { ... postCaseResp ( ) , created_by : nullUser } ) ; } ) ; it ( 'should not return a case in the wrong space' , async ( ) => { const postedCase = await createCase ( supertest , getPostCaseRequest ( ) , 200 , authSpace1 ) ; await getCase ( { supertest , caseId : postedCase . id , auth : getAuthWithSuperUser ( 'space2' ) , expectedHttpCode : 404 , } ) ; } ) ; } ) ; } ;