aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-11-13 11:43:27 +1300
committerAldo Cortesi <aldo@nullcube.com>2016-11-13 11:43:27 +1300
commit3b00bc339d1c65703431e92cfeb2b7436790d04e (patch)
tree99ca54c0d14c00c781225c450d670331cec08b2b /test
parenta9b4560187df02c0d69e89a4892587a65bb03ea7 (diff)
downloadmitmproxy-3b00bc339d1c65703431e92cfeb2b7436790d04e.tar.gz
mitmproxy-3b00bc339d1c65703431e92cfeb2b7436790d04e.tar.bz2
mitmproxy-3b00bc339d1c65703431e92cfeb2b7436790d04e.zip
Complete upstream authentication module
- Handles upstream CONNECT and regular requests, plus HTTP Basic for reverse proxy - Add some tests to make sure we can rely on the .via attribute on server connections.
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_upstream_proxy_auth.py11
-rw-r--r--test/mitmproxy/test_server.py10
2 files changed, 21 insertions, 0 deletions
diff --git a/test/mitmproxy/addons/test_upstream_proxy_auth.py b/test/mitmproxy/addons/test_upstream_proxy_auth.py
index e9a7f4ef..d5d6a3e3 100644
--- a/test/mitmproxy/addons/test_upstream_proxy_auth.py
+++ b/test/mitmproxy/addons/test_upstream_proxy_auth.py
@@ -52,3 +52,14 @@ def test_simple():
f = tflow.tflow()
up.requestheaders(f)
assert "proxy-authorization" not in f.request.headers
+
+ tctx.configure(up, mode="reverse")
+ f = tflow.tflow()
+ f.mode = "transparent"
+ up.requestheaders(f)
+ assert "proxy-authorization" in f.request.headers
+
+ f = tflow.tflow()
+ f.mode = "upstream"
+ up.http_connect(f)
+ assert "proxy-authorization" in f.request.headers
diff --git a/test/mitmproxy/test_server.py b/test/mitmproxy/test_server.py
index dab47c9c..5a5b6817 100644
--- a/test/mitmproxy/test_server.py
+++ b/test/mitmproxy/test_server.py
@@ -669,6 +669,13 @@ class TestProxySSL(tservers.HTTPProxyTest):
first_flow = self.master.state.flows[0]
assert first_flow.server_conn.timestamp_ssl_setup
+ def test_via(self):
+ # tests that the ssl timestamp is present when ssl is used
+ f = self.pathod("200:b@10")
+ assert f.status_code == 200
+ first_flow = self.master.state.flows[0]
+ assert not first_flow.server_conn.via
+
class MasterRedirectRequest(tservers.TestMaster):
redirect_port = None # Set by TestRedirectRequest
@@ -950,11 +957,14 @@ class TestUpstreamProxySSL(
# CONNECT from pathoc to chain[0],
assert self.proxy.tmaster.state.flow_count() == 1
+ assert self.proxy.tmaster.state.flows[0].server_conn.via
# request from pathoc to chain[0]
# CONNECT from proxy to chain[1],
assert self.chain[0].tmaster.state.flow_count() == 1
+ assert self.chain[0].tmaster.state.flows[0].server_conn.via
# request from proxy to chain[1]
# request from chain[0] (regular proxy doesn't store CONNECTs)
+ assert not self.chain[1].tmaster.state.flows[0].server_conn.via
assert self.chain[1].tmaster.state.flow_count() == 1