From 43a2505de06274698ee3fbec9bc738dd95601482 Mon Sep 17 00:00:00 2001 From: Alexey Oplachko Date: Wed, 12 Jun 2024 10:58:47 +0300 Subject: [PATCH] feat: additional tests --- .../Configure/validateDataScheme.spec.ts | 30 ++ .../Configure/validateDataScheme.ts | 2 +- .../FlowModal/ParsedView/ParsedView.spec.ts | 20 ++ .../FlowModal/ParsedView/ParsedView.tsx | 60 ++-- src/components/FlowPanel.tsx | 5 +- src/helpers/dataProcessors/filterFlowItems.ts | 1 - src/test-samples/sample-data.ts | 258 ++++++++++++++---- src/test-samples/sample-parsed-view-config.ts | 82 ++++++ 8 files changed, 376 insertions(+), 82 deletions(-) create mode 100644 src/components/FlowModal/ParsedView/Configure/validateDataScheme.spec.ts create mode 100644 src/components/FlowModal/ParsedView/ParsedView.spec.ts diff --git a/src/components/FlowModal/ParsedView/Configure/validateDataScheme.spec.ts b/src/components/FlowModal/ParsedView/Configure/validateDataScheme.spec.ts new file mode 100644 index 0000000..998452d --- /dev/null +++ b/src/components/FlowModal/ParsedView/Configure/validateDataScheme.spec.ts @@ -0,0 +1,30 @@ +import { sampleBrokenParsedViewConfig, sampleBrokenParsedViewConfig2, sampleBrokenParsedViewConfig3, sampleBrokenParsedViewConfig4, sampleParsedViewConfig } from "test-samples/sample-parsed-view-config" +import { validateDataScheme } from "./validateDataScheme" + +describe('validateDataScheme', () => { + + it('should correctly validate data scheme for valid config', () => { + const result = validateDataScheme(sampleParsedViewConfig) + expect(result).toEqual(true) + }) + + it('should correctly validate data scheme for invalid config', () => { + const result = validateDataScheme(sampleBrokenParsedViewConfig) + expect(result).toEqual(false) + }) + + it('should correctly validate data scheme for invalid config 2', () => { + const result = validateDataScheme(sampleBrokenParsedViewConfig2 as any) + expect(result).toEqual(false) + }) + + it('should correctly validate data scheme for invalid config 3', () => { + const result = validateDataScheme(sampleBrokenParsedViewConfig3 as any) + expect(result).toEqual(false) + }) + + it('should correctly validate data scheme for invalid config 4', () => { + const result = validateDataScheme(sampleBrokenParsedViewConfig4 as any) + expect(result).toEqual(false) + }) +}) diff --git a/src/components/FlowModal/ParsedView/Configure/validateDataScheme.ts b/src/components/FlowModal/ParsedView/Configure/validateDataScheme.ts index fbf7256..9ceb363 100644 --- a/src/components/FlowModal/ParsedView/Configure/validateDataScheme.ts +++ b/src/components/FlowModal/ParsedView/Configure/validateDataScheme.ts @@ -5,7 +5,7 @@ export const validateDataScheme = (dataScheme: ParsedLabel[]): boolean => { return false } if (dataScheme.every((item) => { - return Array.isArray(item.labels) && typeof item.title === 'string' + return Array.isArray(item.labels) && item.labels.length > 0 && typeof item.title === 'string' })) { return true } diff --git a/src/components/FlowModal/ParsedView/ParsedView.spec.ts b/src/components/FlowModal/ParsedView/ParsedView.spec.ts new file mode 100644 index 0000000..f6af085 --- /dev/null +++ b/src/components/FlowModal/ParsedView/ParsedView.spec.ts @@ -0,0 +1,20 @@ +import { sampleParsedViewConfig, sampleParsedViewConfig2 } from "test-samples/sample-parsed-view-config"; +import { parseData } from "./ParsedView"; +import { parsedViewSampleDataSIP, parsedViewSampleDataSIPAfterParse, parsedViewSampleDataSIPAfterParseSecondConfig } from "test-samples/sample-data"; + + +describe('ParsedView', () => { + + it('should correctly parse SIP data based on data scheme', () => { + const result = parseData(parsedViewSampleDataSIP, sampleParsedViewConfig, () => { }) + expect(result).toEqual(parsedViewSampleDataSIPAfterParse); + }) + it('should correctly parse RTCP data based on data scheme', () => { + const result = parseData(parsedViewSampleDataSIP, sampleParsedViewConfig, () => { }) + expect(result).toEqual(parsedViewSampleDataSIPAfterParse); + }) + it('should correctly parse SIP data based on second data scheme', () => { + const result = parseData(parsedViewSampleDataSIP, sampleParsedViewConfig2, () => { }) + expect(result).toEqual(parsedViewSampleDataSIPAfterParseSecondConfig); + }) +}); diff --git a/src/components/FlowModal/ParsedView/ParsedView.tsx b/src/components/FlowModal/ParsedView/ParsedView.tsx index 7fc9e0c..05c0e4c 100644 --- a/src/components/FlowModal/ParsedView/ParsedView.tsx +++ b/src/components/FlowModal/ParsedView/ParsedView.tsx @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'; import { DetailItem } from '../DetailItem'; import { ParsedLabel } from './DataScheme'; import { parseDataIntoListOfFields } from 'helpers/dataProcessors/parseDataIntoListOfFields'; +import { sampleParsedViewConfig, sampleParsedViewConfig2 } from 'test-samples/sample-parsed-view-config'; interface Value { value: string title: string @@ -13,35 +14,11 @@ interface Props { dataScheme: ParsedLabel[] } export const ParsedView: React.FC = ({ data, theme, dataScheme }: Props): JSX.Element | null => { + console.log(data) const [values, setValues] = useState([]) + dataScheme = sampleParsedViewConfig2 useEffect(() => { - const labelMap = new Map() - Object.entries(data).forEach((item: any) => { - let [key, value]: any = item - parseDataIntoListOfFields(value, labelMap, key) - }) - const parsedValues = dataScheme.map((item) => { - let value = '' - if (item.isJSON) { - value = JSON.stringify(labelMap.get(item.labels[0]), null, 2) - } else { - const labelData = item.labels.map((label) => { - return labelMap.get(label)?.value ?? '' - }) - - value = labelData.join(item.separator ?? ' | ') - } - if (item.parser) { - value = item.parser(value) - } - return { - value: value, - tooltip: item.tooltip, - title: item.title - } - }) - - setValues(parsedValues) + parseData(data, dataScheme, setValues); }, [data, dataScheme]) return ( @@ -52,3 +29,32 @@ export const ParsedView: React.FC = ({ data, theme, dataScheme }: Props): J ); } +export function parseData(data: any, dataScheme: ParsedLabel[], setValues: React.Dispatch>) { + const labelMap = new Map(); + Object.entries(data).forEach((item: any) => { + let [key, value]: any = item; + parseDataIntoListOfFields(value, labelMap, key); + }); + const parsedValues = dataScheme.map((item) => { + let value = ''; + if (item.isJSON) { + value = JSON.stringify(labelMap.get(item.labels[0]), null, 2); + } else { + const labelData = item.labels.map((label) => { + return labelMap.get(label)?.value ?? ''; + }); + + value = labelData.join(item.separator ?? ' | '); + } + if (item.parser) { + value = item.parser(value); + } + return { + value: value, + tooltip: item.tooltip, + title: item.title + }; + }); + setValues(parsedValues); + return parsedValues +} diff --git a/src/components/FlowPanel.tsx b/src/components/FlowPanel.tsx index c6a9582..4d85b4d 100644 --- a/src/components/FlowPanel.tsx +++ b/src/components/FlowPanel.tsx @@ -15,6 +15,7 @@ import { pcapExporter, textExporter } from 'helpers/exporters'; import { FlowOptions } from 'types.js'; import { FilterPanel, Filters, defaultFilters } from './FilterPanel/FilterPanel'; import { FlowModal } from './FlowModal/FlowModal'; +import { sampleData } from 'test-samples/sample-data'; @@ -77,8 +78,8 @@ const getStyles = ({ name: themeName }: GrafanaTheme2) => { -export const FlowPanel = (props: MyPanelProps) => { - const { options, data, width, height } = props +export const FlowPanel = ({ options, data, width, height }: MyPanelProps) => { + data = sampleData const [flowData, setFlowData] = useState({ actors: [], data: [] }); const [modalIsOpen, setModalIsOpen] = useState(false); const [modalData, setModalData] = useState({}); diff --git a/src/helpers/dataProcessors/filterFlowItems.ts b/src/helpers/dataProcessors/filterFlowItems.ts index 3273f27..69f681e 100644 --- a/src/helpers/dataProcessors/filterFlowItems.ts +++ b/src/helpers/dataProcessors/filterFlowItems.ts @@ -35,7 +35,6 @@ export const filterFlowItems = (data: PanelData, options: any, setFlowData: Func isMethodDisabled || isTypeDisabled || isCallidDisabled - console.log(getOptionValue(options.details)) return { messageID: getOptionValue(options.colorGenerator) || 'Title', details: getOptionValue(options.details) || '', diff --git a/src/test-samples/sample-data.ts b/src/test-samples/sample-data.ts index 90ad12a..ba4cd99 100644 --- a/src/test-samples/sample-data.ts +++ b/src/test-samples/sample-data.ts @@ -1,5 +1,5 @@ import { FieldType, LoadingState, PanelData, dateTime } from "@grafana/data"; - +// MARK: DATA export const sampleData: PanelData = { state: LoadingState.Done, timeRange: { @@ -420,50 +420,47 @@ export const sampleDataFormattedAndSortedOldFirst = [ export const sampleDataFormattedAndSortedNewFirst = [ { "labels": { - "callid": "b7jl7s@127.0.0.1", - "dst_ip": "8.76.6.57", - "dst_port": "5064", + "dst_ip": "93.172.7.63", + "dst_port": "0", "hostname": "b6f17faf8431", "job": "heplify-server", - "method": "INVITE", "node": "2001", - "response": "407", - "src_ip": "17.103.77.199", - "src_port": "5060", - "type": "sip", - "timestamp": 1718031804118 + "src_ip": "216.187.19.159", + "src_port": "0", + "type": "rtcp", + "timestamp": 1718031813885 }, - "Time": 1718031804118, - "Line": "SIP/2.0 407 Proxy Authentication Required\r\nVia: SIP/2.0/UDP 192.168.10.129:5064;received=8.76.6.57;branch=z9hG4bK923381359;rport=5064\r\nFrom: ;tag=415746302\r\nTo: ;tag=1d24a28a0bded6c40d31e6db8aab9ac6.0385\r\nCall-ID: b7jl7s@127.0.0.1\r\nCSeq: 440 INVITE\r\nProxy-Authenticate: Digest realm=\"sipcapture.org\", nonce=\"VuRZ5VbkWLkkVKJ9B1rBIN9Q3nRbqc9z\"\r\nServer: SIP Proxy\r\nContent-Length: 0\r\n\r\n\r\n", - "tsNs": "1718031804118000000", - "id": "1718031804118000000_3ab4c30", + "Time": 1718031813885, + "Line": "{\"type\":200,\"ssrc\":1814766290,\"report_count\":0,\"report_blocks\":[],\"sender_information\":{\"packets\":2,\"ntp_timestamp_sec\":\"3373905459\",\"ntp_timestamp_usec\":\"4280379832\",\"rtp_timestamp\":-210833031,\"octets\":40}} ", + "tsNs": "1718031813885000000", + "id": "1718031813885000000_e209a8b", "traceId": null, "traceID": null, - "callid": "b7jl7s@127.0.0.1", + "callid": null, "correlationId": null }, { "labels": { - "callid": "b7jl7s@127.0.0.1", - "dst_ip": "8.76.6.57", - "dst_port": "5064", + "callid": "plwj7a@127.0.0.1_b2b-1", + "dst_ip": "93.172.7.63", + "dst_port": "5060", "hostname": "b6f17faf8431", "job": "heplify-server", - "method": "INVITE", + "method": "ACK", "node": "2001", - "response": "100", - "src_ip": "17.103.77.199", + "response": "ACK", + "src_ip": "216.187.19.159", "src_port": "5060", "type": "sip", - "timestamp": 1718031805368 + "timestamp": 1718031813685 }, - "Time": 1718031805368, - "Line": "SIP/2.0 100 Trying\r\nVia: SIP/2.0/UDP 192.168.10.129:5064;received=8.76.6.57;branch=z9hG4bK104237110;rport=5064\r\nFrom: ;tag=415746302\r\nTo: \r\nCall-ID: b7jl7s@127.0.0.1\r\nCSeq: 441 INVITE\r\nServer: SIP Proxy\r\nContent-Length: 0\r\n\r\n\r\n", - "tsNs": "1718031805368000000", - "id": "1718031805368000000_be944f35", + "Time": 1718031813685, + "Line": "ACK sip:109@93.172.7.63:7070 SIP/2.0\r\nMax-Forwards: 10\r\nRecord-Route: \r\nRecord-Route: \r\nVia: SIP/2.0/UDP 216.187.19.159;branch=z9hG4bK3365.4e589db6a3d69d4d4ee211444d6d8d29.0\r\nVia: SIP/2.0/UDP 127.0.0.1:5080;branch=z9hG4bKarC4XaNK;rport=5080\r\nFrom: ;tag=06DE7CEB-56E458BB000864AD-B855F700\r\nTo: ;tag=as6db2fc4d\r\nCSeq: 10 ACK\r\nCall-ID: plwj7a@127.0.0.1_b2b-1\r\nRoute: \r\nSupported: replaces, path, timer, eventlist\r\nUser-Agent: HEPGEN.JS@sipcapture.org\r\nAllow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE\r\nContent-Length: 0\r\nContact: \r\n\r\n\r\n", + "tsNs": "1718031813685000000", + "id": "1718031813685000000_a9231678", "traceId": null, "traceID": null, - "callid": "b7jl7s@127.0.0.1", + "callid": "plwj7a@127.0.0.1_b2b-1", "correlationId": null }, { @@ -492,47 +489,50 @@ export const sampleDataFormattedAndSortedNewFirst = [ }, { "labels": { - "callid": "plwj7a@127.0.0.1_b2b-1", - "dst_ip": "93.172.7.63", - "dst_port": "5060", + "callid": "b7jl7s@127.0.0.1", + "dst_ip": "8.76.6.57", + "dst_port": "5064", "hostname": "b6f17faf8431", "job": "heplify-server", - "method": "ACK", + "method": "INVITE", "node": "2001", - "response": "ACK", - "src_ip": "216.187.19.159", + "response": "100", + "src_ip": "17.103.77.199", "src_port": "5060", "type": "sip", - "timestamp": 1718031813685 + "timestamp": 1718031805368 }, - "Time": 1718031813685, - "Line": "ACK sip:109@93.172.7.63:7070 SIP/2.0\r\nMax-Forwards: 10\r\nRecord-Route: \r\nRecord-Route: \r\nVia: SIP/2.0/UDP 216.187.19.159;branch=z9hG4bK3365.4e589db6a3d69d4d4ee211444d6d8d29.0\r\nVia: SIP/2.0/UDP 127.0.0.1:5080;branch=z9hG4bKarC4XaNK;rport=5080\r\nFrom: ;tag=06DE7CEB-56E458BB000864AD-B855F700\r\nTo: ;tag=as6db2fc4d\r\nCSeq: 10 ACK\r\nCall-ID: plwj7a@127.0.0.1_b2b-1\r\nRoute: \r\nSupported: replaces, path, timer, eventlist\r\nUser-Agent: HEPGEN.JS@sipcapture.org\r\nAllow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE\r\nContent-Length: 0\r\nContact: \r\n\r\n\r\n", - "tsNs": "1718031813685000000", - "id": "1718031813685000000_a9231678", + "Time": 1718031805368, + "Line": "SIP/2.0 100 Trying\r\nVia: SIP/2.0/UDP 192.168.10.129:5064;received=8.76.6.57;branch=z9hG4bK104237110;rport=5064\r\nFrom: ;tag=415746302\r\nTo: \r\nCall-ID: b7jl7s@127.0.0.1\r\nCSeq: 441 INVITE\r\nServer: SIP Proxy\r\nContent-Length: 0\r\n\r\n\r\n", + "tsNs": "1718031805368000000", + "id": "1718031805368000000_be944f35", "traceId": null, "traceID": null, - "callid": "plwj7a@127.0.0.1_b2b-1", + "callid": "b7jl7s@127.0.0.1", "correlationId": null }, { "labels": { - "dst_ip": "93.172.7.63", - "dst_port": "0", + "callid": "b7jl7s@127.0.0.1", + "dst_ip": "8.76.6.57", + "dst_port": "5064", "hostname": "b6f17faf8431", "job": "heplify-server", + "method": "INVITE", "node": "2001", - "src_ip": "216.187.19.159", - "src_port": "0", - "type": "rtcp", - "timestamp": 1718031813885 + "response": "407", + "src_ip": "17.103.77.199", + "src_port": "5060", + "type": "sip", + "timestamp": 1718031804118 }, - "Time": 1718031813885, - "Line": "{\"type\":200,\"ssrc\":1814766290,\"report_count\":0,\"report_blocks\":[],\"sender_information\":{\"packets\":2,\"ntp_timestamp_sec\":\"3373905459\",\"ntp_timestamp_usec\":\"4280379832\",\"rtp_timestamp\":-210833031,\"octets\":40}} ", - "tsNs": "1718031813885000000", - "id": "1718031813885000000_e209a8b", + "Time": 1718031804118, + "Line": "SIP/2.0 407 Proxy Authentication Required\r\nVia: SIP/2.0/UDP 192.168.10.129:5064;received=8.76.6.57;branch=z9hG4bK923381359;rport=5064\r\nFrom: ;tag=415746302\r\nTo: ;tag=1d24a28a0bded6c40d31e6db8aab9ac6.0385\r\nCall-ID: b7jl7s@127.0.0.1\r\nCSeq: 440 INVITE\r\nProxy-Authenticate: Digest realm=\"sipcapture.org\", nonce=\"VuRZ5VbkWLkkVKJ9B1rBIN9Q3nRbqc9z\"\r\nServer: SIP Proxy\r\nContent-Length: 0\r\n\r\n\r\n", + "tsNs": "1718031804118000000", + "id": "1718031804118000000_3ab4c30", "traceId": null, "traceID": null, - "callid": null, + "callid": "b7jl7s@127.0.0.1", "correlationId": null } ] @@ -655,7 +655,7 @@ export const sampleDataFormattedAndUnsorted = [ "correlationId": null } ] - +// MARK: FILTERS export const sampleDataAfterBaseFilter = { "actors": [], "data": [ @@ -792,3 +792,159 @@ export const sampleDataAfterFilterWithoutRTCP = { } ] } + +// MARK: PARSED VIEW +export const parsedViewSampleDataSIP = { + "labels": "{\"callid\":\"b7jl7s@127.0.0.1\",\"dst_ip\":\"8.76.6.57\",\"dst_port\":\"5064\",\"hostname\":\"b6f17faf8431\",\"job\":\"heplify-server\",\"method\":\"INVITE\",\"node\":\"2001\",\"response\":\"407\",\"src_ip\":\"17.103.77.199\",\"src_port\":\"5060\",\"type\":\"sip\",\"timestamp\":1718031804118}", + "Time": 1718031804118, + "Line": "SIP/2.0 407 Proxy Authentication Required\r\nVia: SIP/2.0/UDP 192.168.10.129:5064;received=8.76.6.57;branch=z9hG4bK923381359;rport=5064\r\nFrom: ;tag=415746302\r\nTo: ;tag=1d24a28a0bded6c40d31e6db8aab9ac6.0385\r\nCall-ID: b7jl7s@127.0.0.1\r\nCSeq: 440 INVITE\r\nProxy-Authenticate: Digest realm=\"sipcapture.org\", nonce=\"VuRZ5VbkWLkkVKJ9B1rBIN9Q3nRbqc9z\"\r\nServer: SIP Proxy\r\nContent-Length: 0\r\n\r\n\r\n", + "tsNs": "1718031804118000000", + "id": "1718031804118000000_3ab4c30", + "traceId": null, + "traceID": null, + "callid": "b7jl7s@127.0.0.1", + "correlationId": null +} +export const parsedViewSampleDataSIPAfterParse = [ + { + "value": "b7jl7s@127.0.0.1", + "tooltip": "Data extracted from the `callid` label", + "title": "Call ID" + }, + { + "value": "8.76.6.57:5064", + "tooltip": "Data extracted from the `dst_ip` and `dst_port` labels", + "title": "Destination" + }, + { + "value": "17.103.77.199:5060", + "tooltip": "Data extracted from the `src_ip` and `src_port` labels", + "title": "Source" + }, + { + "value": "407", + "tooltip": "Data extracted from the `response` label", + "title": "Method" + }, + { + "value": "INVITE", + "tooltip": "Data extracted from the `response` label", + "title": "CSeq" + }, + { + "value": "SIP", + "tooltip": "Data extracted from the `type` label", + "title": "Payload Type" + }, + { + "value": "SIP/2.0 407 Proxy Authentication Required\r\nVia: SIP/2.0/UDP 192.168.10.129:5064;received=8.76.6.57;branch=z9hG4bK923381359;rport=5064\r\nFrom: ;tag=415746302\r\nTo: ;tag=1d24a28a0bded6c40d31e6db8aab9ac6.0385\r\nCall-ID: b7jl7s@127.0.0.1\r\nCSeq: 440 INVITE\r\nProxy-Authenticate: Digest realm=\"sipcapture.org\", nonce=\"VuRZ5VbkWLkkVKJ9B1rBIN9Q3nRbqc9z\"\r\nServer: SIP Proxy\r\nContent-Length: 0\r\n\r\n\r\n", + "tooltip": "Data extracted from the `Line` field", + "title": "Message" + }, + { + "tooltip": "Data extracted from the `sender_information` field", + "title": "Sender Information" + }, + { + "tooltip": "Data extracted from the `report_blocks` field", + "title": "Report Blocks" + } +] +export const parsedViewSampleDataSIPAfterParseSecondConfig = [ + { + "value": "b7jl7s@127.0.0.1", + "tooltip": "Data extracted from the `callid` label", + "title": "Call ID" + }, + { + "value": "8.76.6.57:5064", + "tooltip": "Data extracted from the `dst_ip` and `dst_port` labels", + "title": "Destination" + }, + { + "value": "17.103.77.199:5060", + "tooltip": "Data extracted from the `src_ip` and `src_port` labels", + "title": "Source" + }, + { + "value": "Method: 407\nCSeq: INVITE", + "tooltip": "Data extracted from the `response` label", + "title": "Method and CSeq method" + }, + { + "value": "SIP", + "tooltip": "Data extracted from the `type` label", + "title": "Payload Type" + }, + { + "value": "SIP/2.0 407 Proxy Authentication Required\r\nVia: SIP/2.0/UDP 192.168.10.129:5064;received=8.76.6.57;branch=z9hG4bK923381359;rport=5064\r\nFrom: ;tag=415746302\r\nTo: ;tag=1d24a28a0bded6c40d31e6db8aab9ac6.0385\r\nCall-ID: b7jl7s@127.0.0.1\r\nCSeq: 440 INVITE\r\nProxy-Authenticate: Digest realm=\"sipcapture.org\", nonce=\"VuRZ5VbkWLkkVKJ9B1rBIN9Q3nRbqc9z\"\r\nServer: SIP Proxy\r\nContent-Length: 0\r\n\r\n\r\n", + "tooltip": "Data extracted from the `Line` field", + "title": "Message" + }, + { + "tooltip": "Data extracted from the `sender_information` field", + "title": "Sender Information" + }, + { + "tooltip": "Data extracted from the `report_blocks` field", + "title": "Report Blocks" + } +] +export const parsedViewSampleDataRTCP = { + "labels": "{\"callid\":\"b7jl7s@127.0.0.1\",\"dst_ip\":\"8.76.6.57\",\"dst_port\":\"5064\",\"hostname\":\"b6f17faf8431\",\"job\":\"heplify-server\",\"method\":\"INVITE\",\"node\":\"2001\",\"response\":\"407\",\"src_ip\":\"17.103.77.199\",\"src_port\":\"5060\",\"type\":\"sip\",\"timestamp\":1718031804118}", + "Time": 1718031804118, + "Line": "SIP/2.0 407 Proxy Authentication Required\r\nVia: SIP/2.0/UDP 192.168.10.129:5064;received=8.76.6.57;branch=z9hG4bK923381359;rport=5064\r\nFrom: ;tag=415746302\r\nTo: ;tag=1d24a28a0bded6c40d31e6db8aab9ac6.0385\r\nCall-ID: b7jl7s@127.0.0.1\r\nCSeq: 440 INVITE\r\nProxy-Authenticate: Digest realm=\"sipcapture.org\", nonce=\"VuRZ5VbkWLkkVKJ9B1rBIN9Q3nRbqc9z\"\r\nServer: SIP Proxy\r\nContent-Length: 0\r\n\r\n\r\n", + "tsNs": "1718031804118000000", + "id": "1718031804118000000_3ab4c30", + "traceId": null, + "traceID": null, + "callid": "b7jl7s@127.0.0.1", + "correlationId": null +} +export const parsedViewSampleDataRTCPAfterParse = [ + { + "value": "", + "tooltip": "Data extracted from the `callid` label", + "title": "Call ID" + }, + { + "value": "93.172.7.63:0", + "tooltip": "Data extracted from the `dst_ip` and `dst_port` labels", + "title": "Destination" + }, + { + "value": "216.187.19.159:0", + "tooltip": "Data extracted from the `src_ip` and `src_port` labels", + "title": "Source" + }, + { + "value": "", + "tooltip": "Data extracted from the `response` label", + "title": "Method" + }, + { + "value": "", + "tooltip": "Data extracted from the `response` label", + "title": "CSeq" + }, + { + "value": "RTCP", + "tooltip": "Data extracted from the `type` label", + "title": "Payload Type" + }, + { + "value": "{\"type\":200,\"ssrc\":1814766290,\"report_count\":0,\"report_blocks\":[],\"sender_information\":{\"packets\":2,\"ntp_timestamp_sec\":\"3373905459\",\"ntp_timestamp_usec\":\"4280379832\",\"rtp_timestamp\":-210833031,\"octets\":40}} ", + "tooltip": "Data extracted from the `Line` field", + "title": "Message" + }, + { + "value": "{\n \"value\": {\n \"packets\": 2,\n \"ntp_timestamp_sec\": \"3373905459\",\n \"ntp_timestamp_usec\": \"4280379832\",\n \"rtp_timestamp\": -210833031,\n \"octets\": 40\n },\n \"key\": \"Line.sender_information\",\n \"label\": \"sender_information\",\n \"group\": \"Line\",\n \"parentGroup\": \"\",\n \"depth\": 1\n}", + "tooltip": "Data extracted from the `sender_information` field", + "title": "Sender Information" + }, + { + "value": "{\n \"value\": [],\n \"key\": \"Line.report_blocks\",\n \"label\": \"report_blocks\",\n \"group\": \"Line\",\n \"parentGroup\": \"\",\n \"depth\": 1\n}", + "tooltip": "Data extracted from the `report_blocks` field", + "title": "Report Blocks" + } +] diff --git a/src/test-samples/sample-parsed-view-config.ts b/src/test-samples/sample-parsed-view-config.ts index e69de29..322fb75 100644 --- a/src/test-samples/sample-parsed-view-config.ts +++ b/src/test-samples/sample-parsed-view-config.ts @@ -0,0 +1,82 @@ +import { dataScheme } from "components/FlowModal/ParsedView/DataScheme"; + +export const sampleParsedViewConfig = dataScheme; + +export const sampleParsedViewConfig2 = [{ + title: "Call ID", + tooltip: "Data extracted from the `callid` label", + labels: ["callid"], + UUID: "1b2bfa59-4444-4444-b7ce-6116bab380ad", +}, { + title: "Destination", + tooltip: "Data extracted from the `dst_ip` and `dst_port` labels", + labels: ["labels.dst_ip", "labels.dst_port"], + separator: ":", + UUID: "1b2bfa59-4444-4444-b7ce-6116bab380ae", +}, { + title: "Source", + tooltip: "Data extracted from the `src_ip` and `src_port` labels", + labels: ["labels.src_ip", "labels.src_port"], + separator: ":", + UUID: "1b2bfa59-4444-4444-b7ce-6116bab380af", +}, { + title: "Method and CSeq method", + tooltip: "Data extracted from the `response` label", + labels: ["labels.response", "labels.method"], + separator: "|", + parser: (input: string) => { + const [method, cseq] = input.split("|"); + return `Method: ${method}\nCSeq: ${cseq}` + }, + UUID: "1b2bfa59-4444-4444-b7ce-6116bab380b0", +}, { + title: "Payload Type", + tooltip: "Data extracted from the `type` label", + labels: ["labels.type"], + parser: (input: string) => input.toUpperCase(), + UUID: "1b2bfa59-4444-4444-b7ce-6116bab380b2", +}, { + title: "Message", + tooltip: "Data extracted from the `Line` field", + labels: ["Line"], + UUID: "1b2bfa59-4444-4444-b7ce-6116bab380b3", +}, { + title: "Sender Information", + tooltip: "Data extracted from the `sender_information` field", + labels: ["Line.sender_information"], + isJSON: true, + UUID: "1b2bfa59-4444-4444-b7ce-6116bab380b4", +}, { + title: "Report Blocks", + tooltip: "Data extracted from the `report_blocks` field", + labels: ["Line.report_blocks"], + isJSON: true, + UUID: "1b2bfa59-4444-4444-b7ce-6116bab380b5", +} +] + +export const sampleBrokenParsedViewConfig = [] +export const sampleBrokenParsedViewConfig2 = [ + { + title: 3, + tooltip: "Data extracted from the `callid` label", + labels: ["callid"], + UUID: "1b2bfa59-4444-4444-b7ce-6116bab380ad", + } +] +export const sampleBrokenParsedViewConfig3 = [ + { + title: 'Callid', + tooltip: "Data extracted from the `callid` label", + labels: 'callid', + UUID: "1b2bfa59-4444-4444-b7ce-6116bab380ad", + } +] +export const sampleBrokenParsedViewConfig4 = [ + { + title: 'Callid', + tooltip: "Data extracted from the `callid` label", + labels: [], + UUID: "1b2bfa59-4444-4444-b7ce-6116bab380ad", + } +]