[web] TFlow minor improved.

This commit is contained in:
Matthew Shao 2017-05-21 20:59:19 +08:00
parent 55a58c4c6f
commit 2c38fddea5
5 changed files with 18 additions and 15 deletions

View File

@ -281,7 +281,8 @@ class TestApp(tornado.testing.AsyncHTTPTestCase):
tflow_json = _json.dumps( tflow_json = _json.dumps(
app.flow_to_json(tflow.tflow(resp=True, err=True)), indent=4, sort_keys=True app.flow_to_json(tflow.tflow(resp=True, err=True)), indent=4, sort_keys=True
) )
web_root = os.path.join(os.getcwd(), 'web') 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') tflow_path = os.path.join(web_root, 'src/js/__tests__/ducks/_tflow.js')
content = """export default function(){{\n return {tflow_json}\n}}""".format(tflow_json=tflow_json) content = """export default function(){{\n return {tflow_json}\n}}""".format(tflow_json=tflow_json)
with open(tflow_path, 'w') as f: with open(tflow_path, 'w') as f:

View File

@ -1,11 +1,11 @@
import React from 'react' import React from 'react'
import renderer from 'react-test-renderer' import renderer from 'react-test-renderer'
import * as Columns from '../../../components/FlowTable/FlowColumns' import * as Columns from '../../../components/FlowTable/FlowColumns'
import _tflow from '../../ducks/_tflow' import { TFlow } from '../../ducks/tutils'
describe('FlowColumns Components', () => { describe('FlowColumns Components', () => {
let tflow = _tflow() let tflow = TFlow()
it('should render TLSColumn', () => { it('should render TLSColumn', () => {
let tlsColumn = renderer.create(<Columns.TLSColumn flow={tflow}/>), let tlsColumn = renderer.create(<Columns.TLSColumn flow={tflow}/>),
tree = tlsColumn.toJSON() tree = tlsColumn.toJSON()
@ -28,25 +28,25 @@ describe('FlowColumns Components', () => {
tree = iconColumn.toJSON() tree = iconColumn.toJSON()
expect(tree).toMatchSnapshot() expect(tree).toMatchSnapshot()
// image // image
let imageFlow = _tflow() let imageFlow = TFlow()
imageFlow.response.headers = [['Content-Type', 'image/jpeg']] imageFlow.response.headers = [['Content-Type', 'image/jpeg']]
iconColumn = renderer.create(<Columns.IconColumn flow={imageFlow}/>) iconColumn = renderer.create(<Columns.IconColumn flow={imageFlow}/>)
tree = iconColumn.toJSON() tree = iconColumn.toJSON()
expect(tree).toMatchSnapshot() expect(tree).toMatchSnapshot()
// javascript // javascript
let jsFlow = _tflow() let jsFlow = TFlow()
jsFlow.response.headers = [['Content-Type', 'application/x-javascript']] jsFlow.response.headers = [['Content-Type', 'application/x-javascript']]
iconColumn = renderer.create(<Columns.IconColumn flow={jsFlow}/>) iconColumn = renderer.create(<Columns.IconColumn flow={jsFlow}/>)
tree = iconColumn.toJSON() tree = iconColumn.toJSON()
expect(tree).toMatchSnapshot() expect(tree).toMatchSnapshot()
// css // css
let cssFlow = _tflow() let cssFlow = TFlow()
cssFlow.response.headers = [['Content-Type', 'text/css']] cssFlow.response.headers = [['Content-Type', 'text/css']]
iconColumn = renderer.create(<Columns.IconColumn flow={cssFlow}/>) iconColumn = renderer.create(<Columns.IconColumn flow={cssFlow}/>)
tree = iconColumn.toJSON() tree = iconColumn.toJSON()
expect(tree).toMatchSnapshot() expect(tree).toMatchSnapshot()
// default // default
let fooFlow = _tflow() let fooFlow = TFlow()
fooFlow.response.headers = [['Content-Type', 'foo']] fooFlow.response.headers = [['Content-Type', 'foo']]
iconColumn = renderer.create(<Columns.IconColumn flow={fooFlow}/>) iconColumn = renderer.create(<Columns.IconColumn flow={fooFlow}/>)
tree = iconColumn.toJSON() tree = iconColumn.toJSON()
@ -83,7 +83,7 @@ describe('FlowColumns Components', () => {
}) })
it('should render SizeColumn', () => { it('should render SizeColumn', () => {
tflow = _tflow() tflow = TFlow()
let sizeColumn = renderer.create(<Columns.SizeColumn flow={tflow}/>), let sizeColumn = renderer.create(<Columns.SizeColumn flow={tflow}/>),
tree = sizeColumn.toJSON() tree = sizeColumn.toJSON()
expect(tree).toMatchSnapshot() expect(tree).toMatchSnapshot()

View File

@ -112,7 +112,7 @@ exports[`FlowColumns Components should render TimeColumn 1`] = `
<td <td
className="col-time" className="col-time"
> >
415322h 415381h
</td> </td>
`; `;

View File

@ -8,7 +8,7 @@ export default function(){
"alpn_proto_negotiated": "http/1.1", "alpn_proto_negotiated": "http/1.1",
"cipher_name": "cipher", "cipher_name": "cipher",
"clientcert": null, "clientcert": null,
"id": "75bfd3cd-a084-4d84-a063-b0804dc91342", "id": "4a18d1a0-50a1-48dd-9aa6-d45d74282939",
"sni": "address", "sni": "address",
"ssl_established": false, "ssl_established": false,
"timestamp_end": 3.0, "timestamp_end": 3.0,
@ -18,9 +18,9 @@ export default function(){
}, },
"error": { "error": {
"msg": "error", "msg": "error",
"timestamp": 1495158272.596447 "timestamp": 1495370312.4814785
}, },
"id": "8035b342-c916-44f7-93fa-293b40a7d3ad", "id": "d91165be-ca1f-4612-88a9-c0f8696f3e29",
"intercepted": false, "intercepted": false,
"marked": false, "marked": false,
"modified": false, "modified": false,
@ -65,8 +65,8 @@ export default function(){
"is_replay": false, "is_replay": false,
"reason": "OK", "reason": "OK",
"status_code": 200, "status_code": 200,
"timestamp_end": 1495158272.5964308, "timestamp_end": 1495370312.4814625,
"timestamp_start": 1495158272.5964305 "timestamp_start": 1495370312.481462
}, },
"server_conn": { "server_conn": {
"address": [ "address": [
@ -74,7 +74,7 @@ export default function(){
22 22
], ],
"alpn_proto_negotiated": null, "alpn_proto_negotiated": null,
"id": "9a5d01d7-ede8-4409-b064-230305bfa29d", "id": "f087e7b2-6d0a-41a8-a8f0-e1a4761395f8",
"ip_address": [ "ip_address": [
"192.168.0.1", "192.168.0.1",
22 22

View File

@ -7,3 +7,5 @@ export function createStore(parts) {
applyMiddleware(...[thunk]) applyMiddleware(...[thunk])
) )
} }
export { default as TFlow } from './_tflow'