Merge pull request #1700 from cortesi/addontests
addons anticom, anticache: expand tests, new truss
This commit is contained in:
commit
ba09b8bff3
|
@ -2,24 +2,22 @@ from mitmproxy.test import tflow
|
|||
|
||||
from .. import mastertest
|
||||
from mitmproxy.addons import anticache
|
||||
from mitmproxy import master
|
||||
from mitmproxy import options
|
||||
from mitmproxy import proxy
|
||||
from mitmproxy.test import taddons
|
||||
|
||||
|
||||
class TestAntiCache(mastertest.MasterTest):
|
||||
def test_simple(self):
|
||||
o = options.Options(anticache = True)
|
||||
m = master.Master(o, proxy.DummyServer())
|
||||
sa = anticache.AntiCache()
|
||||
m.addons.add(sa)
|
||||
with taddons.context() as tctx:
|
||||
f = tflow.tflow(resp=True)
|
||||
f.request.headers["if-modified-since"] = "test"
|
||||
f.request.headers["if-none-match"] = "test"
|
||||
|
||||
f = tflow.tflow(resp=True)
|
||||
m.request(f)
|
||||
sa.request(f)
|
||||
assert "if-modified-since" in f.request.headers
|
||||
assert "if-none-match" in f.request.headers
|
||||
|
||||
f = tflow.tflow(resp=True)
|
||||
f.request.headers["if-modified-since"] = "test"
|
||||
f.request.headers["if-none-match"] = "test"
|
||||
m.request(f)
|
||||
assert "if-modified-since" not in f.request.headers
|
||||
assert "if-none-match" not in f.request.headers
|
||||
tctx.configure(sa, anticache = True)
|
||||
sa.request(f)
|
||||
assert "if-modified-since" not in f.request.headers
|
||||
assert "if-none-match" not in f.request.headers
|
||||
|
|
|
@ -2,23 +2,19 @@ from mitmproxy.test import tflow
|
|||
|
||||
from .. import mastertest
|
||||
from mitmproxy.addons import anticomp
|
||||
from mitmproxy import master
|
||||
from mitmproxy import options
|
||||
from mitmproxy import proxy
|
||||
from mitmproxy.test import taddons
|
||||
|
||||
|
||||
class TestAntiComp(mastertest.MasterTest):
|
||||
def test_simple(self):
|
||||
o = options.Options(anticomp = True)
|
||||
m = master.Master(o, proxy.DummyServer())
|
||||
sa = anticomp.AntiComp()
|
||||
m.addons.add(sa)
|
||||
with taddons.context() as tctx:
|
||||
f = tflow.tflow(resp=True)
|
||||
sa.request(f)
|
||||
|
||||
f = tflow.tflow(resp=True)
|
||||
m.request(f)
|
||||
tctx.configure(sa, anticomp=True)
|
||||
f = tflow.tflow(resp=True)
|
||||
|
||||
f = tflow.tflow(resp=True)
|
||||
|
||||
f.request.headers["Accept-Encoding"] = "foobar"
|
||||
m.request(f)
|
||||
assert f.request.headers["Accept-Encoding"] == "identity"
|
||||
f.request.headers["Accept-Encoding"] = "foobar"
|
||||
sa.request(f)
|
||||
assert f.request.headers["Accept-Encoding"] == "identity"
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
from mitmproxy import addons
|
||||
|
||||
|
||||
def test_defaults():
|
||||
assert addons.default_addons()
|
Loading…
Reference in New Issue