forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request elastic#18 from Elastic-AWP-Platform/session-view-…
…detail-panel-tests Session view detail panel tests
- Loading branch information
Showing
13 changed files
with
693 additions
and
140 deletions.
There are no files selected for viewing
453 changes: 453 additions & 0 deletions
453
x-pack/plugins/session_view/common/mocks/constants/session_view_process.mock.ts
Large diffs are not rendered by default.
Oops, something went wrong.
127 changes: 127 additions & 0 deletions
127
x-pack/plugins/session_view/common/types/process_tree/index.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,127 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export enum EventKind { | ||
event = 'event', | ||
signal = 'signal', | ||
} | ||
|
||
export enum EventAction { | ||
fork = 'fork', | ||
exec = 'exec', | ||
exit = 'exit', | ||
output = 'output', | ||
} | ||
|
||
export interface EventActionPartition { | ||
fork: ProcessEvent[]; | ||
exec: ProcessEvent[]; | ||
exit: ProcessEvent[]; | ||
output: ProcessEvent[]; | ||
} | ||
|
||
export interface User { | ||
id: string; | ||
name: string; | ||
} | ||
|
||
export interface ProcessFields { | ||
args: string[]; | ||
args_count: number; | ||
command_line: string; | ||
entity_id: string; | ||
executable: string; | ||
interactive: boolean; | ||
name: string; | ||
working_directory: string; | ||
pid: number; | ||
pgid: number; | ||
user: User; | ||
end?: string; | ||
exit_code?: number; | ||
} | ||
|
||
export interface ProcessSelf extends ProcessFields { | ||
parent: ProcessFields; | ||
session: ProcessFields; | ||
entry: ProcessFields; | ||
last_user_entered?: ProcessFields; | ||
} | ||
|
||
export interface ProcessEventHost { | ||
architecture: string; | ||
hostname: string; | ||
id: string; | ||
ip: string; | ||
mac: string; | ||
name: string; | ||
os: { | ||
family: string; | ||
full: string; | ||
kernel: string; | ||
name: string; | ||
platform: string; | ||
type: string; | ||
version: string; | ||
}; | ||
} | ||
|
||
export interface ProcessEventAlertRule { | ||
category: string; | ||
consumer: string; | ||
description: string; | ||
enabled: boolean; | ||
name: string; | ||
query: string; | ||
risk_score: number; | ||
severity: string; | ||
uuid: string; | ||
} | ||
|
||
export interface ProcessEventAlert { | ||
uuid: string; | ||
reason: string; | ||
workflow_status: string; | ||
status: string; | ||
original_time: Date; | ||
original_event: { | ||
action: string; | ||
}; | ||
rule: ProcessEventAlertRule; | ||
} | ||
|
||
export interface ProcessEvent { | ||
'@timestamp': Date; | ||
event: { | ||
kind: EventKind; | ||
category: string; | ||
action: EventAction; | ||
}; | ||
// optional host for now (raw agent output doesn't have server identity) | ||
host?: ProcessEventHost; | ||
process: ProcessSelf; | ||
kibana?: { | ||
alert: ProcessEventAlert; | ||
}; | ||
} | ||
|
||
export interface Process { | ||
id: string; // the process entity_id | ||
events: ProcessEvent[]; | ||
children: Process[]; | ||
parent: Process | undefined; | ||
autoExpand: boolean; | ||
searchMatched: string | null; // either false, or set to searchQuery | ||
hasOutput(): boolean; | ||
hasAlerts(): boolean; | ||
getAlerts(): ProcessEvent[]; | ||
hasExec(): boolean; | ||
getOutput(): string; | ||
getDetails(): ProcessEvent; | ||
isUserEntered(): boolean; | ||
getMaxAlertLevel(): number | null; | ||
} |
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
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
File renamed without changes.
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
72 changes: 72 additions & 0 deletions
72
x-pack/plugins/session_view/public/components/SessionViewDetailPanel/index.test.tsx
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,72 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { | ||
sessionViewBasicProcessMock, | ||
sessionViewAlertProcessMock, | ||
} from '../../../common/mocks/constants/session_view_process.mock'; | ||
import { AppContextTestRender, createAppRootMockRenderer } from '../../test'; | ||
import { SessionViewDetailPanel } from './index'; | ||
|
||
describe('SessionView component', () => { | ||
let render: () => ReturnType<AppContextTestRender['render']>; | ||
let renderResult: ReturnType<typeof render>; | ||
let mockedContext: AppContextTestRender; | ||
|
||
beforeEach(() => { | ||
mockedContext = createAppRootMockRenderer(); | ||
}); | ||
|
||
describe('When SessionViewDetailPanel is mounted', () => { | ||
it('should show session detail and server detail when no process is selected', async () => { | ||
renderResult = mockedContext.render( | ||
<SessionViewDetailPanel | ||
isDetailMounted={true} | ||
height={400} | ||
selectedProcess={null} | ||
setIsDetailOpen={() => jest.fn()} | ||
/> | ||
); | ||
// see if loader is present | ||
expect(renderResult.queryByTestId('sessionViewDetailPanelCommandDetail')).toBeNull(); | ||
expect(renderResult.queryByTestId('sessionViewDetailPanelSessionDetail')).toBeTruthy(); | ||
expect(renderResult.queryByTestId('sessionViewDetailPanelServerDetail')).toBeTruthy(); | ||
expect(renderResult.queryByTestId('sessionViewDetailPanelAlertDetail')).toBeNull(); | ||
}); | ||
|
||
it('should show command detail when selectedProcess is present', async () => { | ||
renderResult = mockedContext.render( | ||
<SessionViewDetailPanel | ||
isDetailMounted={true} | ||
height={400} | ||
selectedProcess={sessionViewBasicProcessMock} | ||
setIsDetailOpen={() => jest.fn()} | ||
/> | ||
); | ||
expect(renderResult.queryByTestId('sessionViewDetailPanelCommandDetail')).toBeTruthy(); | ||
expect(renderResult.queryByTestId('sessionViewDetailPanelSessionDetail')).toBeTruthy(); | ||
expect(renderResult.queryByTestId('sessionViewDetailPanelServerDetail')).toBeTruthy(); | ||
expect(renderResult.queryByTestId('sessionViewDetailPanelAlertDetail')).toBeNull(); | ||
}); | ||
|
||
it('should show command and alerts detail if selectedProcess contains a signal event', async () => { | ||
renderResult = mockedContext.render( | ||
<SessionViewDetailPanel | ||
isDetailMounted={true} | ||
height={400} | ||
selectedProcess={sessionViewAlertProcessMock} | ||
setIsDetailOpen={() => jest.fn()} | ||
/> | ||
); | ||
expect(renderResult.queryByTestId('sessionViewDetailPanelCommandDetail')).toBeTruthy(); | ||
expect(renderResult.queryByTestId('sessionViewDetailPanelSessionDetail')).toBeTruthy(); | ||
expect(renderResult.queryByTestId('sessionViewDetailPanelServerDetail')).toBeTruthy(); | ||
expect(renderResult.queryByTestId('sessionViewDetailPanelAlertDetail')).toBeTruthy(); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.