diff options
| author | Aldo Cortesi <aldo@corte.si> | 2016-07-14 12:09:21 +1200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-07-14 12:09:21 +1200 |
| commit | c0cd01b6e3fc28497ce19de9ff0888ffc99f63ed (patch) | |
| tree | 836dd5e79ed38b638a919133cbe95e61b52a2736 /test | |
| parent | b56de79d6c4362d9587c4a5254dd7757a34dac7b (diff) | |
| parent | b5a69e23988b0ca419fa0f1503d60aea4bb1a5d2 (diff) | |
| download | mitmproxy-c0cd01b6e3fc28497ce19de9ff0888ffc99f63ed.tar.gz mitmproxy-c0cd01b6e3fc28497ce19de9ff0888ffc99f63ed.tar.bz2 mitmproxy-c0cd01b6e3fc28497ce19de9ff0888ffc99f63ed.zip | |
Merge pull request #1351 from cortesi/anticache
AntiCache to addon
Diffstat (limited to 'test')
| -rw-r--r-- | test/mitmproxy/builtins/test_anticache.py | 23 | ||||
| -rw-r--r-- | test/mitmproxy/test_flow.py | 10 |
2 files changed, 23 insertions, 10 deletions
diff --git a/test/mitmproxy/builtins/test_anticache.py b/test/mitmproxy/builtins/test_anticache.py new file mode 100644 index 00000000..5a00af03 --- /dev/null +++ b/test/mitmproxy/builtins/test_anticache.py @@ -0,0 +1,23 @@ +from .. import tutils, mastertest +from mitmproxy.builtins import anticache +from mitmproxy.flow import master +from mitmproxy.flow import state +from mitmproxy import options + + +class TestAntiCache(mastertest.MasterTest): + def test_simple(self): + s = state.State() + m = master.FlowMaster(options.Options(anticache = True), None, s) + sa = anticache.AntiCache() + m.addons.add(sa) + + f = tutils.tflow(resp=True) + self.invoke(m, "request", f) + + f = tutils.tflow(resp=True) + f.request.headers["if-modified-since"] = "test" + f.request.headers["if-none-match"] = "test" + self.invoke(m, "request", f) + assert "if-modified-since" not in f.request.headers + assert "if-none-match" not in f.request.headers diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py index a6a3038c..585dbf93 100644 --- a/test/mitmproxy/test_flow.py +++ b/test/mitmproxy/test_flow.py @@ -855,7 +855,6 @@ class TestFlowMaster: def test_all(self): s = flow.State() fm = flow.FlowMaster(None, None, s) - fm.anticache = True f = tutils.tflow(req=None) fm.clientconnect(f.client_conn) f.request = HTTPRequest.wrap(netlib.tutils.treq()) @@ -1053,15 +1052,6 @@ class TestRequest: assert r.url == "https://address:22/path" assert r.pretty_url == "https://foo.com:22/path" - def test_anticache(self): - r = HTTPRequest.wrap(netlib.tutils.treq()) - r.headers = Headers() - r.headers["if-modified-since"] = "test" - r.headers["if-none-match"] = "test" - r.anticache() - assert "if-modified-since" not in r.headers - assert "if-none-match" not in r.headers - def test_replace(self): r = HTTPRequest.wrap(netlib.tutils.treq()) r.path = "path/foo" |
