kibana/x-pack/test/api_integration/apis/security_solution/sources.ts
Lukas Olson 34ada8a9a6
[data.search] Use versioned router (#158520)
## Summary

Step 1 of https://github.com/elastic/kibana/issues/157095.

Uses the new versioned router capabilities for the search routes (`POST`
and `DELETE`).

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
2023-06-07 10:33:39 +02:00

127 lines
4.3 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 { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const supertest = getService('supertest');
describe('sources', () => {
before(() => esArchiver.load('x-pack/test/functional/es_archives/auditbeat/default'));
after(() => esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/default'));
it('Make sure that we get source information when auditbeat indices is there', async () => {
const { body: sourceStatus } = await supertest
.post('/internal/search/indexFields/')
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
.set('kbn-xsrf', 'true')
.send({
indices: ['auditbeat-*'],
onlyCheckIfIndicesExist: false,
wait_for_completion_timeout: '10s',
})
.expect(200);
expect(sourceStatus.indexFields.length).to.be(351);
expect(sourceStatus.indicesExist).to.eql(['auditbeat-*']);
});
it('should find indexes as being available when they exist', async () => {
const { body: sourceStatus } = await supertest
.post('/internal/search/indexFields/')
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
.set('kbn-xsrf', 'true')
.send({
indices: ['auditbeat-*', 'filebeat-*'],
onlyCheckIfIndicesExist: false,
wait_for_completion_timeout: '10s',
})
.expect(200);
expect(sourceStatus.indicesExist).to.eql(['auditbeat-*']);
});
it('should not find indexes as existing when there is an empty array of them', async () => {
const { body: sourceStatus } = await supertest
.post('/internal/search/indexFields/')
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
.set('kbn-xsrf', 'true')
.send({
indices: [],
onlyCheckIfIndicesExist: false,
wait_for_completion_timeout: '10s',
})
.expect(200);
expect(sourceStatus.indicesExist).to.eql([]);
});
it('should not find indexes as existing when there is a _all within it', async () => {
const { body: sourceStatus } = await supertest
.post('/internal/search/indexFields/')
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
.set('kbn-xsrf', 'true')
.send({
indices: ['_all'],
onlyCheckIfIndicesExist: false,
wait_for_completion_timeout: '10s',
})
.expect(200);
expect(sourceStatus.indicesExist).to.eql([]);
});
it('should not find indexes as existing when there are empty strings within it', async () => {
const { body: sourceStatus } = await supertest
.post('/internal/search/indexFields/')
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
.set('kbn-xsrf', 'true')
.send({
indices: [''],
onlyCheckIfIndicesExist: false,
wait_for_completion_timeout: '10s',
})
.expect(200);
expect(sourceStatus.indicesExist).to.eql([]);
});
it('should not find indexes as existing when there are blank spaces within it', async () => {
const { body: sourceStatus } = await supertest
.post('/internal/search/indexFields/')
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
.set('kbn-xsrf', 'true')
.send({
indices: [' '],
onlyCheckIfIndicesExist: false,
wait_for_completion_timeout: '10s',
})
.expect(200);
expect(sourceStatus.indicesExist).to.eql([]);
});
it('should find indexes when one is an empty index but the others are valid', async () => {
const { body: sourceStatus } = await supertest
.post('/internal/search/indexFields/')
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
.set('kbn-xsrf', 'true')
.send({
indices: ['', 'auditbeat-*'],
onlyCheckIfIndicesExist: false,
wait_for_completion_timeout: '10s',
})
.expect(200);
expect(sourceStatus.indicesExist).to.eql(['auditbeat-*']);
});
});
}