Merge pull request #2471 from ujjwal96/traceback-fix
Fixed addon error in test suite
This commit is contained in:
commit
7b54ef23d5
|
@ -148,7 +148,7 @@ def tclient_conn():
|
||||||
"""
|
"""
|
||||||
c = connections.ClientConnection.from_state(dict(
|
c = connections.ClientConnection.from_state(dict(
|
||||||
id=str(uuid.uuid4()),
|
id=str(uuid.uuid4()),
|
||||||
address=("address", 22),
|
address=("127.0.0.1", 22),
|
||||||
clientcert=None,
|
clientcert=None,
|
||||||
mitmcert=None,
|
mitmcert=None,
|
||||||
ssl_established=False,
|
ssl_established=False,
|
||||||
|
|
|
@ -32,7 +32,7 @@ def test_extract():
|
||||||
["s.header[header-response]", "svalue"],
|
["s.header[header-response]", "svalue"],
|
||||||
|
|
||||||
["cc.address.port", "22"],
|
["cc.address.port", "22"],
|
||||||
["cc.address.host", "address"],
|
["cc.address.host", "127.0.0.1"],
|
||||||
["cc.tls_version", "TLSv1.2"],
|
["cc.tls_version", "TLSv1.2"],
|
||||||
["cc.sni", "address"],
|
["cc.sni", "address"],
|
||||||
["cc.ssl_established", "false"],
|
["cc.ssl_established", "false"],
|
||||||
|
|
|
@ -29,7 +29,7 @@ class TestClientConnection:
|
||||||
|
|
||||||
def test_repr(self):
|
def test_repr(self):
|
||||||
c = tflow.tclient_conn()
|
c = tflow.tclient_conn()
|
||||||
assert 'address:22' in repr(c)
|
assert '127.0.0.1:22' in repr(c)
|
||||||
assert 'ALPN' in repr(c)
|
assert 'ALPN' in repr(c)
|
||||||
assert 'TLS' not in repr(c)
|
assert 'TLS' not in repr(c)
|
||||||
|
|
||||||
|
|
|
@ -225,11 +225,11 @@ class TestMatchingHTTPFlow:
|
||||||
|
|
||||||
def test_src(self):
|
def test_src(self):
|
||||||
q = self.req()
|
q = self.req()
|
||||||
assert self.q("~src address", q)
|
assert self.q("~src 127.0.0.1", q)
|
||||||
assert not self.q("~src foobar", q)
|
assert not self.q("~src foobar", q)
|
||||||
assert self.q("~src :22", q)
|
assert self.q("~src :22", q)
|
||||||
assert not self.q("~src :99", q)
|
assert not self.q("~src :99", q)
|
||||||
assert self.q("~src address:22", q)
|
assert self.q("~src 127.0.0.1:22", q)
|
||||||
|
|
||||||
q.client_conn.address = None
|
q.client_conn.address = None
|
||||||
assert not self.q('~src address:22', q)
|
assert not self.q('~src address:22', q)
|
||||||
|
@ -315,11 +315,11 @@ class TestMatchingTCPFlow:
|
||||||
|
|
||||||
def test_src(self):
|
def test_src(self):
|
||||||
f = self.flow()
|
f = self.flow()
|
||||||
assert self.q("~src address", f)
|
assert self.q("~src 127.0.0.1", f)
|
||||||
assert not self.q("~src foobar", f)
|
assert not self.q("~src foobar", f)
|
||||||
assert self.q("~src :22", f)
|
assert self.q("~src :22", f)
|
||||||
assert not self.q("~src :99", f)
|
assert not self.q("~src :99", f)
|
||||||
assert self.q("~src address:22", f)
|
assert self.q("~src 127.0.0.1:22", f)
|
||||||
|
|
||||||
def test_dst(self):
|
def test_dst(self):
|
||||||
f = self.flow()
|
f = self.flow()
|
||||||
|
@ -440,11 +440,11 @@ class TestMatchingWebSocketFlow:
|
||||||
|
|
||||||
def test_src(self):
|
def test_src(self):
|
||||||
f = self.flow()
|
f = self.flow()
|
||||||
assert self.q("~src address", f)
|
assert self.q("~src 127.0.0.1", f)
|
||||||
assert not self.q("~src foobar", f)
|
assert not self.q("~src foobar", f)
|
||||||
assert self.q("~src :22", f)
|
assert self.q("~src :22", f)
|
||||||
assert not self.q("~src :99", f)
|
assert not self.q("~src :99", f)
|
||||||
assert self.q("~src address:22", f)
|
assert self.q("~src 127.0.0.1:22", f)
|
||||||
|
|
||||||
def test_dst(self):
|
def test_dst(self):
|
||||||
f = self.flow()
|
f = self.flow()
|
||||||
|
@ -524,7 +524,7 @@ class TestMatchingDummyFlow:
|
||||||
|
|
||||||
assert not self.q("~s", f)
|
assert not self.q("~s", f)
|
||||||
|
|
||||||
assert self.q("~src address", f)
|
assert self.q("~src 127.0.0.1", f)
|
||||||
assert not self.q("~src nonexistent", f)
|
assert not self.q("~src nonexistent", f)
|
||||||
|
|
||||||
assert not self.q("~tcp", f)
|
assert not self.q("~tcp", f)
|
||||||
|
|
|
@ -2,6 +2,7 @@ import os.path
|
||||||
import threading
|
import threading
|
||||||
import tempfile
|
import tempfile
|
||||||
import sys
|
import sys
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
import mitmproxy.platform
|
import mitmproxy.platform
|
||||||
from mitmproxy.proxy.config import ProxyConfig
|
from mitmproxy.proxy.config import ProxyConfig
|
||||||
|
@ -23,10 +24,13 @@ class MasterTest:
|
||||||
|
|
||||||
def cycle(self, master, content):
|
def cycle(self, master, content):
|
||||||
f = tflow.tflow(req=tutils.treq(content=content))
|
f = tflow.tflow(req=tutils.treq(content=content))
|
||||||
master.addons.handle_lifecycle("clientconnect", f.client_conn)
|
layer = mock.Mock("mitmproxy.proxy.protocol.base.Layer")
|
||||||
|
layer.client_conn = f.client_conn
|
||||||
|
layer.reply = controller.DummyReply()
|
||||||
|
master.addons.handle_lifecycle("clientconnect", layer)
|
||||||
for i in eventsequence.iterate(f):
|
for i in eventsequence.iterate(f):
|
||||||
master.addons.handle_lifecycle(*i)
|
master.addons.handle_lifecycle(*i)
|
||||||
master.addons.handle_lifecycle("clientdisconnect", f.client_conn)
|
master.addons.handle_lifecycle("clientdisconnect", layer)
|
||||||
return f
|
return f
|
||||||
|
|
||||||
def dummy_cycle(self, master, n, content):
|
def dummy_cycle(self, master, n, content):
|
||||||
|
|
|
@ -12,7 +12,7 @@ exports[`ConnectionInfo Component should render correctly 1`] = `
|
||||||
Address:
|
Address:
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
address:22
|
127.0.0.1:22
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -47,7 +47,7 @@ exports[`Details Component should render correctly 1`] = `
|
||||||
Address:
|
Address:
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
address:22
|
127.0.0.1:22
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -2,7 +2,7 @@ export default function(){
|
||||||
return {
|
return {
|
||||||
"client_conn": {
|
"client_conn": {
|
||||||
"address": [
|
"address": [
|
||||||
"address",
|
"127.0.0.1",
|
||||||
22
|
22
|
||||||
],
|
],
|
||||||
"alpn_proto_negotiated": "http/1.1",
|
"alpn_proto_negotiated": "http/1.1",
|
||||||
|
|
Loading…
Reference in New Issue