mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
Add DummyFlow and its Tests
This commit is contained in:
parent
8c49f0e784
commit
1d2ccb9170
@ -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"""
|
||||
|
Loading…
Reference in New Issue
Block a user