From 1d2ccb9170b2ada0fc017296c89cd53aa76572d6 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Fri, 15 Jul 2016 17:31:06 +0530 Subject: Add DummyFlow and its Tests --- test/mitmproxy/test_filt.py | 60 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) (limited to 'test') 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""" -- cgit v1.2.3