diff options
author | Shadab Zafar <dufferzafar0@gmail.com> | 2016-07-15 17:31:06 +0530 |
---|---|---|
committer | Shadab Zafar <dufferzafar0@gmail.com> | 2016-07-16 10:15:38 +0530 |
commit | 1d2ccb9170b2ada0fc017296c89cd53aa76572d6 (patch) | |
tree | dd2081f1e57b127ceecf16850be981bf45d6ccec /test | |
parent | 8c49f0e784a0470a45616d631483c5aeeb1f7937 (diff) | |
download | mitmproxy-1d2ccb9170b2ada0fc017296c89cd53aa76572d6.tar.gz mitmproxy-1d2ccb9170b2ada0fc017296c89cd53aa76572d6.tar.bz2 mitmproxy-1d2ccb9170b2ada0fc017296c89cd53aa76572d6.zip |
Add DummyFlow and its Tests
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/test_filt.py | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/test/mitmproxy/test_filt.py b/test/mitmproxy/test_filt.py index 46e86b57..92a48cd2 100644 --- a/test/mitmproxy/test_filt.py +++ b/test/mitmproxy/test_filt.py @@ -1,6 +1,9 @@ from six.moves import cStringIO as StringIO -from mitmproxy import filt from mock import patch + +from mitmproxy import filt +from mitmproxy.models.flow import Flow + from . import tutils @@ -376,6 +379,61 @@ class TestMatchingTCPFlow: assert not self.q("~u whatever", f) +class DummyFlow(Flow): + """ A flow that is neither HTTP nor TCP. """ + + def __init__(self): + pass + + +class TestMatchingDummyFlow: + + def flow(self): + return DummyFlow() + + def q(self, q, o): + return filt.parse(q)(o) + + def test_filters(self): + f = self.flow() + + assert not self.q("~a", f) + + assert not self.q("~b whatever", f) + assert not self.q("~bq whatever", f) + assert not self.q("~bs whatever", f) + + assert not self.q("~dst whatever", f) + + assert not self.q("~c 0", f) + + assert not self.q("~d whatever", f) + + assert not self.q("~e", f) + + assert not self.q("~http", f) + + assert not self.q("~h whatever", f) + assert not self.q("~hq whatever", f) + assert not self.q("~hs whatever", f) + + assert not self.q("~m whatever", f) + + assert not self.q("~s", f) + + assert not self.q("~src whatever", f) + + assert not self.q("~tcp", f) + + assert not self.q("~t whatever", f) + assert not self.q("~tq whatever", f) + assert not self.q("~ts whatever", f) + + assert not self.q("~u whatever", f) + + assert not self.q("~q", f) + + @patch('traceback.extract_tb') def test_pyparsing_bug(extract_tb): """https://github.com/mitmproxy/mitmproxy/issues/1087""" |