diff --git a/x-pack/plugins/ingest_pipelines/server/routes/api/database/serialization.test.ts b/x-pack/plugins/ingest_pipelines/server/routes/api/database/serialization.test.ts new file mode 100644 index 00000000000000..80598a1401bb10 --- /dev/null +++ b/x-pack/plugins/ingest_pipelines/server/routes/api/database/serialization.test.ts @@ -0,0 +1,23 @@ +/* + * 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 { serializeGeoipDatabase } from './serialization'; + +describe('serializeGeoipDatabase', () => { + it('serializes maxmind database', () => { + const licenseKey = '123'; + const createDbRequestBody = serializeGeoipDatabase({ + databaseType: 'maxmind', + databaseName: 'GeoIP2-Anonymous-IP', + maxmind: licenseKey, + }); + + expect(createDbRequestBody.name).toBe('GeoIP2-Anonymous-IP.mmdb'); + expect(createDbRequestBody.maxmind?.account_id).toBe(licenseKey); + expect(createDbRequestBody.ipinfo).toBeUndefined(); + }); +}); diff --git a/x-pack/plugins/ingest_pipelines/server/routes/api/database/serialization.ts b/x-pack/plugins/ingest_pipelines/server/routes/api/database/serialization.ts index 2f2c93ba5334d4..d6546d3c85248f 100644 --- a/x-pack/plugins/ingest_pipelines/server/routes/api/database/serialization.ts +++ b/x-pack/plugins/ingest_pipelines/server/routes/api/database/serialization.ts @@ -72,7 +72,7 @@ export const serializeGeoipDatabase = ({ databaseName: string; maxmind?: string; }): SerializedGeoipDatabase => { - const database = { name: databaseName } as SerializedGeoipDatabase; + const database = { name: `${databaseName}.mmdb` } as SerializedGeoipDatabase; if (databaseType === 'maxmind') { database.maxmind = { account_id: maxmind ?? '' };