-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Change the way the resolver simulator works * refactor resolver tree and data access layer mocks * Fix bug where timestamp and pid sometimes don't show in the node detail view * add a few tests for the panel (not done, but worth committing.) Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
e43301b
commit 51443b7
Showing
13 changed files
with
390 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...solver/data_access_layer/mocks/no_ancestors_two_children_with_related_events_on_origin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* 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 { DataAccessLayer } from '../../types'; | ||
import { mockTreeWithNoAncestorsAndTwoChildrenAndRelatedEventsOnOrigin } from '../../mocks/resolver_tree'; | ||
import { | ||
ResolverRelatedEvents, | ||
ResolverTree, | ||
ResolverEntityIndex, | ||
} from '../../../../common/endpoint/types'; | ||
|
||
interface Metadata { | ||
/** | ||
* The `_id` of the document being analyzed. | ||
*/ | ||
databaseDocumentID: string; | ||
/** | ||
* A record of entityIDs to be used in tests assertions. | ||
*/ | ||
entityIDs: { | ||
/** | ||
* The entityID of the node related to the document being analyzed. | ||
*/ | ||
origin: 'origin'; | ||
/** | ||
* The entityID of the first child of the origin. | ||
*/ | ||
firstChild: 'firstChild'; | ||
/** | ||
* The entityID of the second child of the origin. | ||
*/ | ||
secondChild: 'secondChild'; | ||
}; | ||
} | ||
|
||
export function noAncestorsTwoChildrenWithRelatedEventsOnOrigin(): { | ||
dataAccessLayer: DataAccessLayer; | ||
metadata: Metadata; | ||
} { | ||
const metadata: Metadata = { | ||
databaseDocumentID: '_id', | ||
entityIDs: { origin: 'origin', firstChild: 'firstChild', secondChild: 'secondChild' }, | ||
}; | ||
const tree = mockTreeWithNoAncestorsAndTwoChildrenAndRelatedEventsOnOrigin({ | ||
originID: metadata.entityIDs.origin, | ||
firstChildID: metadata.entityIDs.firstChild, | ||
secondChildID: metadata.entityIDs.secondChild, | ||
}); | ||
|
||
return { | ||
metadata, | ||
dataAccessLayer: { | ||
/** | ||
* Fetch related events for an entity ID | ||
*/ | ||
relatedEvents(entityID: string): Promise<ResolverRelatedEvents> { | ||
/** | ||
* Respond with the mocked related events when the origin's related events are fetched. | ||
**/ | ||
const events = entityID === metadata.entityIDs.origin ? tree.relatedEvents.events : []; | ||
|
||
return Promise.resolve({ | ||
entityID, | ||
events, | ||
nextEvent: null, | ||
} as ResolverRelatedEvents); | ||
}, | ||
|
||
/** | ||
* Fetch a ResolverTree for a entityID | ||
*/ | ||
resolverTree(): Promise<ResolverTree> { | ||
return Promise.resolve(tree); | ||
}, | ||
|
||
/** | ||
* Get an array of index patterns that contain events. | ||
*/ | ||
indexPatterns(): string[] { | ||
return ['index pattern']; | ||
}, | ||
|
||
/** | ||
* Get entities matching a document. | ||
*/ | ||
entities(): Promise<ResolverEntityIndex> { | ||
return Promise.resolve([{ entity_id: metadata.entityIDs.origin }]); | ||
}, | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
x-pack/plugins/security_solution/public/resolver/store/mocks/related_event.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.