kibana/x-pack/test/security_solution_endpoint_api_int/apis/policy.ts
Spencer f466ebf1a3
[esArchiver] drop support for --dir, use repo-relative paths instead (#101345)
Co-authored-by: spalger <spalger@users.noreply.github.com>
2021-06-08 17:37:42 -04:00

49 lines
1.8 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../ftr_provider_context';
import { deletePolicyStream } from './data_stream_helper';
export default function ({ getService }: FtrProviderContext) {
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,
})
);
// the endpoint uses data streams and es archiver does not support deleting them at the moment so we need
// to do it manually
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');
});
});
});
}