Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into move-alerts-t…
Browse files Browse the repository at this point in the history
…o-siem
  • Loading branch information
XavierM committed May 19, 2020
2 parents b4867c3 + 1964b77 commit c0a2920
Show file tree
Hide file tree
Showing 11 changed files with 401 additions and 741 deletions.

This file was deleted.

4 changes: 0 additions & 4 deletions x-pack/plugins/siem/common/endpoint_alerts/alert_constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ export class AlertConstants {
* The path for the Alert's Index Pattern API.
*/
static INDEX_PATTERN_ROUTE = `${AlertConstants.BASE_API_URL}/index_pattern`;
/**
* Alert's Index pattern
*/
static ALERT_INDEX_NAME = 'events-endpoint-1';
/**
* A paramter passed to Alert's Index Pattern.
*/
Expand Down
118 changes: 59 additions & 59 deletions x-pack/plugins/siem/public/resolver/store/data/selectors.test.ts
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
/*
* 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 { Store, createStore } from 'redux';
import { DataAction } from './action';
import { dataReducer } from './reducer';
import {
DataState,
RelatedEventDataEntry,
RelatedEventDataEntryWithStats,
RelatedEventData,
} from '../../types';
import { ResolverEvent } from '../../../../../common/types';
import { relatedEventStats, relatedEvents } from './selectors';

describe('resolver data selectors', () => {
const store: Store<DataState, DataAction> = createStore(dataReducer, undefined);
describe('when related event data is reduced into state with no results', () => {
let relatedEventInfoBeforeAction: RelatedEventData;
beforeEach(() => {
relatedEventInfoBeforeAction = new Map(relatedEvents(store.getState()) || []);
const payload: Map<ResolverEvent, RelatedEventDataEntry> = new Map();
const action: DataAction = { type: 'serverReturnedRelatedEventData', payload };
store.dispatch(action);
});
it('should have the same related info as before the action', () => {
const relatedInfoAfterAction = relatedEvents(store.getState());
expect(relatedInfoAfterAction).toEqual(relatedEventInfoBeforeAction);
});
});
describe('when related event data is reduced into state with 2 dns results', () => {
let mockBaseEvent: ResolverEvent;
beforeEach(() => {
mockBaseEvent = {} as ResolverEvent;
function dnsRelatedEventEntry() {
const fakeEvent = {} as ResolverEvent;
return { relatedEvent: fakeEvent, relatedEventType: 'dns' };
}
const payload: Map<ResolverEvent, RelatedEventDataEntry> = new Map([
[
mockBaseEvent,
{
relatedEvents: [dnsRelatedEventEntry(), dnsRelatedEventEntry()],
},
],
]);
const action: DataAction = { type: 'serverReturnedRelatedEventData', payload };
store.dispatch(action);
});
it('should compile stats reflecting a count of 2 for dns', () => {
const actualStats = relatedEventStats(store.getState());
const statsForFakeEvent = actualStats.get(mockBaseEvent)! as RelatedEventDataEntryWithStats;
expect(statsForFakeEvent.stats).toEqual({ dns: 2 });
});
});
});
/*
* 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 { Store, createStore } from 'redux';
import { DataAction } from './action';
import { dataReducer } from './reducer';
import {
DataState,
RelatedEventDataEntry,
RelatedEventDataEntryWithStats,
RelatedEventData,
} from '../../types';
import { ResolverEvent } from '../../../../common/endpoint/types';
import { relatedEventStats, relatedEvents } from './selectors';

describe('resolver data selectors', () => {
const store: Store<DataState, DataAction> = createStore(dataReducer, undefined);
describe('when related event data is reduced into state with no results', () => {
let relatedEventInfoBeforeAction: RelatedEventData;
beforeEach(() => {
relatedEventInfoBeforeAction = new Map(relatedEvents(store.getState()) || []);
const payload: Map<ResolverEvent, RelatedEventDataEntry> = new Map();
const action: DataAction = { type: 'serverReturnedRelatedEventData', payload };
store.dispatch(action);
});
it('should have the same related info as before the action', () => {
const relatedInfoAfterAction = relatedEvents(store.getState());
expect(relatedInfoAfterAction).toEqual(relatedEventInfoBeforeAction);
});
});
describe('when related event data is reduced into state with 2 dns results', () => {
let mockBaseEvent: ResolverEvent;
beforeEach(() => {
mockBaseEvent = {} as ResolverEvent;
function dnsRelatedEventEntry() {
const fakeEvent = {} as ResolverEvent;
return { relatedEvent: fakeEvent, relatedEventType: 'dns' };
}
const payload: Map<ResolverEvent, RelatedEventDataEntry> = new Map([
[
mockBaseEvent,
{
relatedEvents: [dnsRelatedEventEntry(), dnsRelatedEventEntry()],
},
],
]);
const action: DataAction = { type: 'serverReturnedRelatedEventData', payload };
store.dispatch(action);
});
it('should compile stats reflecting a count of 2 for dns', () => {
const actualStats = relatedEventStats(store.getState());
const statsForFakeEvent = actualStats.get(mockBaseEvent)! as RelatedEventDataEntryWithStats;
expect(statsForFakeEvent.stats).toEqual({ dns: 2 });
});
});
});
Loading

0 comments on commit c0a2920

Please sign in to comment.