aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_flow.py26
-rw-r--r--test/mitmproxy/test_flowfilter.py (renamed from test/mitmproxy/test_filt.py)54
2 files changed, 40 insertions, 40 deletions
diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py
index 0fe45afb..cc9d2691 100644
--- a/test/mitmproxy/test_flow.py
+++ b/test/mitmproxy/test_flow.py
@@ -3,7 +3,7 @@ import io
import netlib.utils
from netlib.http import Headers
-from mitmproxy import filt, flow, options
+from mitmproxy import flowfilter, flow, options
from mitmproxy.contrib import tnetstring
from mitmproxy.exceptions import FlowReadException, Kill
from mitmproxy.models import Error
@@ -68,14 +68,14 @@ class TestHTTPFlow(object):
def test_match(self):
f = tutils.tflow(resp=True)
- assert not f.match("~b test")
- assert f.match(None)
- assert not f.match("~b test")
+ assert not flowfilter.match("~b test", f)
+ assert flowfilter.match(None, f)
+ assert not flowfilter.match("~b test", f)
f = tutils.tflow(err=True)
- assert f.match("~e")
+ assert flowfilter.match("~e", f)
- tutils.raises(ValueError, f.match, "~")
+ tutils.raises(ValueError, flowfilter.match, "~", f)
def test_backup(self):
f = tutils.tflow()
@@ -195,14 +195,14 @@ class TestTCPFlow:
def test_match(self):
f = tutils.ttcpflow()
- assert not f.match("~b nonexistent")
- assert f.match(None)
- assert not f.match("~b nonexistent")
+ assert not flowfilter.match("~b nonexistent", f)
+ assert flowfilter.match(None, f)
+ assert not flowfilter.match("~b nonexistent", f)
f = tutils.ttcpflow(err=True)
- assert f.match("~e")
+ assert flowfilter.match("~e", f)
- tutils.raises(ValueError, f.match, "~")
+ tutils.raises(ValueError, flowfilter.match, "~", f)
class TestState:
@@ -400,8 +400,8 @@ class TestSerialize:
def test_filter(self):
sio = io.BytesIO()
- fl = filt.parse("~c 200")
- w = flow.FilteredFlowWriter(sio, fl)
+ flt = flowfilter.parse("~c 200")
+ w = flow.FilteredFlowWriter(sio, flt)
f = tutils.tflow(resp=True)
f.response.status_code = 200
diff --git a/test/mitmproxy/test_filt.py b/test/mitmproxy/test_flowfilter.py
index 69f042bb..e8d19ffa 100644
--- a/test/mitmproxy/test_filt.py
+++ b/test/mitmproxy/test_flowfilter.py
@@ -1,7 +1,7 @@
from six.moves import cStringIO as StringIO
from mock import patch
-from mitmproxy import filt
+from mitmproxy import flowfilter
from . import tutils
@@ -14,64 +14,64 @@ class TestParsing:
assert c.getvalue()
def test_parse_err(self):
- assert filt.parse("~h [") is None
+ assert flowfilter.parse("~h [") is None
def test_simple(self):
- assert not filt.parse("~b")
- assert filt.parse("~q")
- assert filt.parse("~c 10")
- assert filt.parse("~m foobar")
- assert filt.parse("~u foobar")
- assert filt.parse("~q ~c 10")
- p = filt.parse("~q ~c 10")
+ assert not flowfilter.parse("~b")
+ assert flowfilter.parse("~q")
+ assert flowfilter.parse("~c 10")
+ assert flowfilter.parse("~m foobar")
+ assert flowfilter.parse("~u foobar")
+ assert flowfilter.parse("~q ~c 10")
+ p = flowfilter.parse("~q ~c 10")
self._dump(p)
assert len(p.lst) == 2
def test_naked_url(self):
- a = filt.parse("foobar ~h rex")
+ a = flowfilter.parse("foobar ~h rex")
assert a.lst[0].expr == "foobar"
assert a.lst[1].expr == "rex"
self._dump(a)
def test_quoting(self):
- a = filt.parse("~u 'foo ~u bar' ~u voing")
+ a = flowfilter.parse("~u 'foo ~u bar' ~u voing")
assert a.lst[0].expr == "foo ~u bar"
assert a.lst[1].expr == "voing"
self._dump(a)
- a = filt.parse("~u foobar")
+ a = flowfilter.parse("~u foobar")
assert a.expr == "foobar"
- a = filt.parse(r"~u 'foobar\"\''")
+ a = flowfilter.parse(r"~u 'foobar\"\''")
assert a.expr == "foobar\"'"
- a = filt.parse(r'~u "foo \'bar"')
+ a = flowfilter.parse(r'~u "foo \'bar"')
assert a.expr == "foo 'bar"
def test_nesting(self):
- a = filt.parse("(~u foobar & ~h voing)")
+ a = flowfilter.parse("(~u foobar & ~h voing)")
assert a.lst[0].expr == "foobar"
self._dump(a)
def test_not(self):
- a = filt.parse("!~h test")
+ a = flowfilter.parse("!~h test")
assert a.itm.expr == "test"
- a = filt.parse("!(~u test & ~h bar)")
+ a = flowfilter.parse("!(~u test & ~h bar)")
assert a.itm.lst[0].expr == "test"
self._dump(a)
def test_binaryops(self):
- a = filt.parse("~u foobar | ~h voing")
- isinstance(a, filt.FOr)
+ a = flowfilter.parse("~u foobar | ~h voing")
+ isinstance(a, flowfilter.FOr)
self._dump(a)
- a = filt.parse("~u foobar & ~h voing")
- isinstance(a, filt.FAnd)
+ a = flowfilter.parse("~u foobar & ~h voing")
+ isinstance(a, flowfilter.FAnd)
self._dump(a)
def test_wideops(self):
- a = filt.parse("~hq 'header: qvalue'")
- assert isinstance(a, filt.FHeadRequest)
+ a = flowfilter.parse("~hq 'header: qvalue'")
+ assert isinstance(a, flowfilter.FHeadRequest)
self._dump(a)
@@ -87,7 +87,7 @@ class TestMatchingHTTPFlow:
return tutils.tflow(err=True)
def q(self, q, o):
- return filt.parse(q)(o)
+ return flowfilter.parse(q)(o)
def test_http(self):
s = self.req()
@@ -263,7 +263,7 @@ class TestMatchingTCPFlow:
return tutils.ttcpflow(err=True)
def q(self, q, o):
- return filt.parse(q)(o)
+ return flowfilter.parse(q)(o)
def test_tcp(self):
f = self.flow()
@@ -387,7 +387,7 @@ class TestMatchingDummyFlow:
return tutils.tdummyflow(err=True)
def q(self, q, o):
- return filt.parse(q)(o)
+ return flowfilter.parse(q)(o)
def test_filters(self):
e = self.err()
@@ -439,4 +439,4 @@ def test_pyparsing_bug(extract_tb):
"""https://github.com/mitmproxy/mitmproxy/issues/1087"""
# The text is a string with leading and trailing whitespace stripped; if the source is not available it is None.
extract_tb.return_value = [("", 1, "test", None)]
- assert filt.parse("test")
+ assert flowfilter.parse("test")