Skip to content

Commit

Permalink
add suffix to database names
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkime committed Oct 18, 2024
1 parent 613a1eb commit 9835cef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? '' };
Expand Down

0 comments on commit 9835cef

Please sign in to comment.