Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.16] [Ingest Pipelines] Improve api integration tests (#196718) #196749

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x-pack/test/api_integration/apis/management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export default function ({ loadTestFile }) {
loadTestFile(require.resolve('./index_management'));
loadTestFile(require.resolve('./index_lifecycle_management'));
loadTestFile(require.resolve('./snapshot_restore'));
loadTestFile(require.resolve('./ingest_pipelines'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,51 @@ export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const ingestPipelines = getService('ingestPipelines');
const url = `/api/ingest_pipelines/databases`;
const databaseName = 'GeoIP2-Anonymous-IP';
const normalizedDatabaseName = 'geoip2-anonymous-ip';
const maxmindDatabaseName = 'GeoIP2-Anonymous-IP';
const normalizedMaxmindDatabaseName = 'geoip2-anonymous-ip';
const ipinfoDatabaseName = 'asn';
const normalizedIpinfoDatabaseName = 'asn';

describe('Manage databases', function () {
after(async () => {
await ingestPipelines.api.deleteGeoipDatabases();
});

describe('Create', () => {
it('creates a geoip database when using a correct database name', async () => {
const database = { maxmind: '123456', databaseName };
it('creates a maxmind geoip database when using a correct database name', async () => {
const database = {
databaseType: 'maxmind',
databaseName: maxmindDatabaseName,
maxmind: '123456',
};
const { body } = await supertest
.post(url)
.set('kbn-xsrf', 'xxx')
.send(database)
.expect(200);

expect(body).to.eql({
name: databaseName,
id: normalizedDatabaseName,
name: maxmindDatabaseName,
id: normalizedMaxmindDatabaseName,
});
});

it('creates a geoip database when using an incorrect database name', async () => {
const database = { maxmind: '123456', databaseName: 'Test' };
it('creates an ipinfo geoip database when using a correct database name', async () => {
const database = { databaseType: 'ipinfo', databaseName: ipinfoDatabaseName };
const { body } = await supertest
.post(url)
.set('kbn-xsrf', 'xxx')
.send(database)
.expect(200);

expect(body).to.eql({
name: ipinfoDatabaseName,
id: normalizedIpinfoDatabaseName,
});
});

it('returns error when creating a geoip database with an incorrect database name', async () => {
const database = { databaseType: 'maxmind', databaseName: 'Test', maxmind: '123456' };
await supertest.post(url).set('kbn-xsrf', 'xxx').send(database).expect(400);
});
});
Expand All @@ -47,8 +67,13 @@ export default function ({ getService }: FtrProviderContext) {
const { body } = await supertest.get(url).set('kbn-xsrf', 'xxx').expect(200);
expect(body).to.eql([
{
id: normalizedDatabaseName,
name: databaseName,
id: normalizedIpinfoDatabaseName,
name: ipinfoDatabaseName,
type: 'ipinfo',
},
{
id: normalizedMaxmindDatabaseName,
name: maxmindDatabaseName,
type: 'maxmind',
},
]);
Expand All @@ -58,7 +83,12 @@ export default function ({ getService }: FtrProviderContext) {
describe('Delete', () => {
it('deletes a geoip database', async () => {
await supertest
.delete(`${url}/${normalizedDatabaseName}`)
.delete(`${url}/${normalizedMaxmindDatabaseName}`)
.set('kbn-xsrf', 'xxx')
.expect(200);

await supertest
.delete(`${url}/${normalizedIpinfoDatabaseName}`)
.set('kbn-xsrf', 'xxx')
.expect(200);
});
Expand Down