Skip to content

Commit

Permalink
[Security Solution] Search strategy - authentications (#76090)
Browse files Browse the repository at this point in the history
* move authentications to searchstrategy

* useAuthentications

* add authenticationFields

* remove import from lib

* remove duplicated types

* getInspectResponse

* getInspectResponse

* move folder

* update path

* update path

* shallowEqual

* revert path

* update path

* remove redundant types

* fix import

* fix types

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Patryk Kopyciński <[email protected]>
  • Loading branch information
3 people authored Sep 2, 2020
1 parent 01e4420 commit d932830
Show file tree
Hide file tree
Showing 25 changed files with 1,143 additions and 177 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { extendMap } from './extend_map';

describe('ecs_fields test', () => {
describe('extendMap', () => {
test('it should extend a record', () => {
const osFieldsMap: Readonly<Record<string, string>> = {
'os.platform': 'os.platform',
'os.full': 'os.full',
'os.family': 'os.family',
'os.version': 'os.version',
'os.kernel': 'os.kernel',
};
const expected: Record<string, string> = {
'host.os.family': 'host.os.family',
'host.os.full': 'host.os.full',
'host.os.kernel': 'host.os.kernel',
'host.os.platform': 'host.os.platform',
'host.os.version': 'host.os.version',
};
expect(extendMap('host', osFieldsMap)).toEqual(expected);
});

test('it should extend a sample hosts record', () => {
const hostMap: Record<string, string> = {
'host.id': 'host.id',
'host.ip': 'host.ip',
'host.name': 'host.name',
};
const osFieldsMap: Readonly<Record<string, string>> = {
'os.platform': 'os.platform',
'os.full': 'os.full',
'os.family': 'os.family',
'os.version': 'os.version',
'os.kernel': 'os.kernel',
};
const expected: Record<string, string> = {
'host.id': 'host.id',
'host.ip': 'host.ip',
'host.name': 'host.name',
'host.os.family': 'host.os.family',
'host.os.full': 'host.os.full',
'host.os.kernel': 'host.os.kernel',
'host.os.platform': 'host.os.platform',
'host.os.version': 'host.os.version',
};
const output = { ...hostMap, ...extendMap('host', osFieldsMap) };
expect(output).toEqual(expected);
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export const extendMap = (
path: string,
map: Readonly<Record<string, string>>
): Readonly<Record<string, string>> =>
Object.entries(map).reduce<Record<string, string>>((accum, [key, value]) => {
accum[`${path}.${key}`] = `${path}.${value}`;
return accum;
}, {});
Loading

0 comments on commit d932830

Please sign in to comment.