coverage++
This commit is contained in:
parent
68c55979fb
commit
eefc55f28f
|
@ -184,9 +184,6 @@ def tserver_conn() -> connection.Server:
|
|||
return c
|
||||
|
||||
|
||||
def terr(content="error"):
|
||||
"""
|
||||
@return: mitmproxy.proxy.protocol.primitives.Error
|
||||
"""
|
||||
err = flow.Error(content)
|
||||
def terr(content: str = "error") -> flow.Error:
|
||||
err = flow.Error(content, 946681207)
|
||||
return err
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import asyncio
|
||||
import json as _json
|
||||
import logging
|
||||
from unittest import mock
|
||||
import os
|
||||
import asyncio
|
||||
import sys
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -331,14 +331,18 @@ class TestApp(tornado.testing.AsyncHTTPTestCase):
|
|||
# Set some value as constant, so that _tflow.js would not change every time.
|
||||
_tflow['client_conn']['id'] = "4a18d1a0-50a1-48dd-9aa6-d45d74282939"
|
||||
_tflow['id'] = "d91165be-ca1f-4612-88a9-c0f8696f3e29"
|
||||
_tflow['error']['timestamp'] = 1495370312.4814785
|
||||
_tflow['response']['timestamp_end'] = 1495370312.4814625
|
||||
_tflow['response']['timestamp_start'] = 1495370312.481462
|
||||
_tflow['server_conn']['id'] = "f087e7b2-6d0a-41a8-a8f0-e1a4761395f8"
|
||||
_tflow["request"]["trailers"] = [["trailer", "qvalue"]]
|
||||
_tflow["response"]["trailers"] = [["trailer", "qvalue"]]
|
||||
tflow_json = _json.dumps(_tflow, indent=4, sort_keys=True)
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
web_root = os.path.join(here, os.pardir, os.pardir, os.pardir, os.pardir, 'web')
|
||||
tflow_path = os.path.join(web_root, 'src/js/__tests__/ducks/_tflow.js')
|
||||
content = f"""export default function(){{\n return {tflow_json}\n}}"""
|
||||
content = (
|
||||
f"/** Auto-generated by test_app.py:TestApp._test_generate_tflow_js */\n"
|
||||
f"export default function(){{\n"
|
||||
f" return {tflow_json}\n"
|
||||
f"}}"
|
||||
)
|
||||
with open(tflow_path, 'w', newline="\n") as f:
|
||||
f.write(content)
|
||||
|
|
|
@ -7,6 +7,10 @@ and activate your virtualenv environment before proceeding.**
|
|||
- Run `yarn run gulp` to start live-compilation.
|
||||
- Run `mitmweb` and open http://localhost:8081/
|
||||
|
||||
## Testing
|
||||
|
||||
- Run `yarn run test` to run the testsuite.
|
||||
|
||||
## Architecture
|
||||
|
||||
There are two components:
|
||||
|
|
|
@ -105,4 +105,12 @@ describe('FlowColumns Components', () => {
|
|||
tree = timeColumn.toJSON()
|
||||
expect(tree).toMatchSnapshot()
|
||||
})
|
||||
|
||||
it('should render TimeStampColumn', () => {
|
||||
let timeStampColumn = renderer.create(<Columns.TimeStampColumn flow={tflow}/>),
|
||||
tree = timeStampColumn.toJSON()
|
||||
tflow.request.timestamp_start =
|
||||
|
||||
expect(tree).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -127,7 +127,7 @@ exports[`FlowColumns Components should render TimeColumn 1`] = `
|
|||
<td
|
||||
className="col-time"
|
||||
>
|
||||
415381h
|
||||
3s
|
||||
</td>
|
||||
`;
|
||||
|
||||
|
@ -139,6 +139,14 @@ exports[`FlowColumns Components should render TimeColumn 2`] = `
|
|||
</td>
|
||||
`;
|
||||
|
||||
exports[`FlowColumns Components should render TimeStampColumn 1`] = `
|
||||
<td
|
||||
className="col-start"
|
||||
>
|
||||
1999-12-31 23:00:00.000
|
||||
</td>
|
||||
`;
|
||||
|
||||
exports[`FlowColumns Components should render pathColumn 1`] = `
|
||||
<td
|
||||
className="col-path"
|
||||
|
|
|
@ -46,7 +46,7 @@ exports[`FlowRow Component should render correctly 1`] = `
|
|||
<td
|
||||
className="col-time"
|
||||
>
|
||||
415381h
|
||||
3s
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
|
|
@ -155,6 +155,18 @@ exports[`Details Component should render correctly 1`] = `
|
|||
TLSv1.2
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<abbr
|
||||
title="ALPN protocol negotiated"
|
||||
>
|
||||
ALPN:
|
||||
</abbr>
|
||||
</td>
|
||||
<td>
|
||||
http/1.1
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Resolved address:
|
||||
|
@ -182,24 +194,20 @@ exports[`Details Component should render correctly 1`] = `
|
|||
className="timing-table"
|
||||
>
|
||||
<tbody>
|
||||
<tr />
|
||||
<tr />
|
||||
<tr>
|
||||
<td>
|
||||
Server conn. initiated
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
1970-01-01 00:00:01.000
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Client conn. established
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
1970-01-01 00:00:01.000
|
||||
1999-12-31 23:00:02.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
2s
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -208,25 +216,57 @@ exports[`Details Component should render correctly 1`] = `
|
|||
:
|
||||
</td>
|
||||
<td>
|
||||
1970-01-01 00:00:02.000
|
||||
1999-12-31 23:00:03.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
3s
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr />
|
||||
<tr>
|
||||
<td>
|
||||
Client conn. established
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
1999-12-31 23:00:00.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
0ms
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr />
|
||||
<tr>
|
||||
<td>
|
||||
First request byte
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
1999-12-31 23:00:00.000
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Client conn. SSL handshake
|
||||
Request complete
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
1970-01-01 00:00:02.000
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Server conn. SSL handshake
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
1970-01-01 00:00:03.000
|
||||
1999-12-31 23:00:01.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
1s
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -235,7 +275,14 @@ exports[`Details Component should render correctly 1`] = `
|
|||
:
|
||||
</td>
|
||||
<td>
|
||||
2017-05-21 12:38:32.481
|
||||
1999-12-31 23:00:02.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
2s
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -244,7 +291,14 @@ exports[`Details Component should render correctly 1`] = `
|
|||
:
|
||||
</td>
|
||||
<td>
|
||||
2017-05-21 12:38:32.481
|
||||
1999-12-31 23:00:03.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
3s
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -323,8 +377,6 @@ exports[`Details Component should render correctly when server address is missin
|
|||
className="timing-table"
|
||||
>
|
||||
<tbody>
|
||||
<tr />
|
||||
<tr />
|
||||
<tr />
|
||||
<tr />
|
||||
<tr />
|
||||
|
@ -334,16 +386,40 @@ exports[`Details Component should render correctly when server address is missin
|
|||
:
|
||||
</td>
|
||||
<td>
|
||||
1970-01-01 00:00:01.000
|
||||
1999-12-31 23:00:00.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
0ms
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr />
|
||||
<tr>
|
||||
<td>
|
||||
First request byte
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
1999-12-31 23:00:00.000
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Client conn. SSL handshake
|
||||
Request complete
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
1970-01-01 00:00:02.000
|
||||
1999-12-31 23:00:01.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
1s
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -352,7 +428,14 @@ exports[`Details Component should render correctly when server address is missin
|
|||
:
|
||||
</td>
|
||||
<td>
|
||||
2017-05-21 12:38:32.481
|
||||
1999-12-31 23:00:02.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
2s
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -361,7 +444,14 @@ exports[`Details Component should render correctly when server address is missin
|
|||
:
|
||||
</td>
|
||||
<td>
|
||||
2017-05-21 12:38:32.481
|
||||
1999-12-31 23:00:03.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
3s
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -400,24 +490,20 @@ exports[`Timing Component should render correctly 1`] = `
|
|||
className="timing-table"
|
||||
>
|
||||
<tbody>
|
||||
<tr />
|
||||
<tr />
|
||||
<tr>
|
||||
<td>
|
||||
Server conn. initiated
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
1970-01-01 00:00:01.000
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Client conn. established
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
1970-01-01 00:00:01.000
|
||||
1999-12-31 23:00:02.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
2s
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -426,25 +512,57 @@ exports[`Timing Component should render correctly 1`] = `
|
|||
:
|
||||
</td>
|
||||
<td>
|
||||
1970-01-01 00:00:02.000
|
||||
1999-12-31 23:00:03.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
3s
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr />
|
||||
<tr>
|
||||
<td>
|
||||
Client conn. established
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
1999-12-31 23:00:00.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
0ms
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr />
|
||||
<tr>
|
||||
<td>
|
||||
First request byte
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
1999-12-31 23:00:00.000
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Client conn. SSL handshake
|
||||
Request complete
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
1970-01-01 00:00:02.000
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Server conn. SSL handshake
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
1970-01-01 00:00:03.000
|
||||
1999-12-31 23:00:01.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
1s
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -453,7 +571,14 @@ exports[`Timing Component should render correctly 1`] = `
|
|||
:
|
||||
</td>
|
||||
<td>
|
||||
2017-05-21 12:38:32.481
|
||||
1999-12-31 23:00:02.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
2s
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -462,7 +587,14 @@ exports[`Timing Component should render correctly 1`] = `
|
|||
:
|
||||
</td>
|
||||
<td>
|
||||
2017-05-21 12:38:32.481
|
||||
1999-12-31 23:00:03.000
|
||||
<span
|
||||
className="text-muted"
|
||||
>
|
||||
(
|
||||
3s
|
||||
)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
@ -10,7 +10,7 @@ exports[`Error Component should render correctly 1`] = `
|
|||
error
|
||||
<div>
|
||||
<small>
|
||||
2017-05-21 12:38:32.481
|
||||
1999-12-31 23:00:07.000
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -253,55 +253,6 @@ exports[`Request Component should render correctly 1`] = `
|
|||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td
|
||||
className="header-name"
|
||||
>
|
||||
<div
|
||||
className="inline-input readonly"
|
||||
contentEditable={undefined}
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "content-length",
|
||||
}
|
||||
}
|
||||
onBlur={[Function]}
|
||||
onClick={[Function]}
|
||||
onFocus={[Function]}
|
||||
onInput={[Function]}
|
||||
onKeyDown={[Function]}
|
||||
onMouseDown={[Function]}
|
||||
onPaste={[Function]}
|
||||
tabIndex={undefined}
|
||||
/>
|
||||
<span
|
||||
className="header-colon"
|
||||
>
|
||||
:
|
||||
</span>
|
||||
</td>
|
||||
<td
|
||||
className="header-value"
|
||||
>
|
||||
<div
|
||||
className="inline-input readonly"
|
||||
contentEditable={undefined}
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "7",
|
||||
}
|
||||
}
|
||||
onBlur={[Function]}
|
||||
onClick={[Function]}
|
||||
onFocus={[Function]}
|
||||
onInput={[Function]}
|
||||
onKeyDown={[Function]}
|
||||
onMouseDown={[Function]}
|
||||
onPaste={[Function]}
|
||||
tabIndex={undefined}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</article>
|
||||
|
@ -621,55 +572,6 @@ exports[`Response Component should render correctly 1`] = `
|
|||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td
|
||||
className="header-name"
|
||||
>
|
||||
<div
|
||||
className="inline-input readonly"
|
||||
contentEditable={undefined}
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "content-length",
|
||||
}
|
||||
}
|
||||
onBlur={[Function]}
|
||||
onClick={[Function]}
|
||||
onFocus={[Function]}
|
||||
onInput={[Function]}
|
||||
onKeyDown={[Function]}
|
||||
onMouseDown={[Function]}
|
||||
onPaste={[Function]}
|
||||
tabIndex={undefined}
|
||||
/>
|
||||
<span
|
||||
className="header-colon"
|
||||
>
|
||||
:
|
||||
</span>
|
||||
</td>
|
||||
<td
|
||||
className="header-value"
|
||||
>
|
||||
<div
|
||||
className="inline-input readonly"
|
||||
contentEditable={undefined}
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "7",
|
||||
}
|
||||
}
|
||||
onBlur={[Function]}
|
||||
onClick={[Function]}
|
||||
onFocus={[Function]}
|
||||
onInput={[Function]}
|
||||
onKeyDown={[Function]}
|
||||
onMouseDown={[Function]}
|
||||
onPaste={[Function]}
|
||||
tabIndex={undefined}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</article>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/** Auto-generated by test_app.py:TestApp._test_generate_tflow_js */
|
||||
export default function(){
|
||||
return {
|
||||
"client_conn": {
|
||||
|
@ -7,21 +8,21 @@ export default function(){
|
|||
],
|
||||
"alpn_proto_negotiated": "http/1.1",
|
||||
"cipher_name": "cipher",
|
||||
"clientcert": null,
|
||||
"id": "4a18d1a0-50a1-48dd-9aa6-d45d74282939",
|
||||
"sni": "address",
|
||||
"ssl_established": false,
|
||||
"timestamp_end": 3.0,
|
||||
"timestamp_ssl_setup": 2.0,
|
||||
"timestamp_start": 1.0,
|
||||
"timestamp_end": 946681206,
|
||||
"timestamp_start": 946681200,
|
||||
"timestamp_tls_setup": 946681201,
|
||||
"tls_established": true,
|
||||
"tls_version": "TLSv1.2"
|
||||
},
|
||||
"error": {
|
||||
"msg": "error",
|
||||
"timestamp": 1495370312.4814785
|
||||
"timestamp": 946681207.0
|
||||
},
|
||||
"id": "d91165be-ca1f-4612-88a9-c0f8696f3e29",
|
||||
"intercepted": false,
|
||||
"is_replay": null,
|
||||
"marked": false,
|
||||
"modified": false,
|
||||
"request": {
|
||||
|
@ -45,16 +46,12 @@ export default function(){
|
|||
"port": 22,
|
||||
"pretty_host": "address",
|
||||
"scheme": "http",
|
||||
"timestamp_end": null,
|
||||
"timestamp_start": null,
|
||||
"timestamp_end": 946681201,
|
||||
"timestamp_start": 946681200,
|
||||
"trailers": [
|
||||
[
|
||||
"trailer",
|
||||
"qvalue"
|
||||
],
|
||||
[
|
||||
"content-length",
|
||||
"7"
|
||||
]
|
||||
]
|
||||
},
|
||||
|
@ -75,16 +72,12 @@ export default function(){
|
|||
"is_replay": false,
|
||||
"reason": "OK",
|
||||
"status_code": 200,
|
||||
"timestamp_end": 1495370312.4814625,
|
||||
"timestamp_start": 1495370312.481462,
|
||||
"timestamp_end": 946681203,
|
||||
"timestamp_start": 946681202,
|
||||
"trailers": [
|
||||
[
|
||||
"trailer",
|
||||
"qvalue"
|
||||
],
|
||||
[
|
||||
"content-length",
|
||||
"7"
|
||||
]
|
||||
]
|
||||
},
|
||||
|
@ -93,7 +86,7 @@ export default function(){
|
|||
"address",
|
||||
22
|
||||
],
|
||||
"alpn_proto_negotiated": null,
|
||||
"alpn_proto_negotiated": "http/1.1",
|
||||
"id": "f087e7b2-6d0a-41a8-a8f0-e1a4761395f8",
|
||||
"ip_address": [
|
||||
"192.168.0.1",
|
||||
|
@ -104,13 +97,12 @@ export default function(){
|
|||
"address",
|
||||
22
|
||||
],
|
||||
"ssl_established": false,
|
||||
"timestamp_end": 4.0,
|
||||
"timestamp_ssl_setup": 3.0,
|
||||
"timestamp_start": 1.0,
|
||||
"timestamp_tcp_setup": 2.0,
|
||||
"tls_version": "TLSv1.2",
|
||||
"via": null
|
||||
"timestamp_end": 946681205,
|
||||
"timestamp_start": 946681202,
|
||||
"timestamp_tcp_setup": 946681203,
|
||||
"timestamp_tls_setup": 946681204,
|
||||
"tls_established": true,
|
||||
"tls_version": "TLSv1.2"
|
||||
},
|
||||
"type": "http"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue