aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-07-14 11:24:06 +1200
committerAldo Cortesi <aldo@nullcube.com>2016-07-14 11:24:06 +1200
commit143bf0dfa9138a4340287d636bb68648665b3829 (patch)
tree836dd5e79ed38b638a919133cbe95e61b52a2736 /test
parent6e7b86cd82dd9b379b0a57d423bbdcd74ba47256 (diff)
downloadmitmproxy-143bf0dfa9138a4340287d636bb68648665b3829.tar.gz
mitmproxy-143bf0dfa9138a4340287d636bb68648665b3829.tar.bz2
mitmproxy-143bf0dfa9138a4340287d636bb68648665b3829.zip
AntiCache to addon
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/builtins/test_anticache.py23
-rw-r--r--test/mitmproxy/test_flow.py10
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"