summary refs log tree commit diff
path: root/tests/http/test_proxyagent.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/http/test_proxyagent.py')
-rw-r--r--tests/http/test_proxyagent.py92
1 files changed, 2 insertions, 90 deletions
diff --git a/tests/http/test_proxyagent.py b/tests/http/test_proxyagent.py

index f7575f59fb..4e1a5a5138 100644 --- a/tests/http/test_proxyagent.py +++ b/tests/http/test_proxyagent.py
@@ -354,51 +354,6 @@ class MatrixFederationAgentTests(TestCase): body = self.successResultOf(treq.content(resp)) self.assertEqual(body, b"result") - @patch.dict(os.environ, {"http_proxy": "proxy.com:8888"}) - def test_http_request_via_proxy_with_blacklist(self): - # The blacklist includes the configured proxy IP. - agent = ProxyAgent( - BlacklistingReactorWrapper( - self.reactor, ip_whitelist=None, ip_blacklist=IPSet(["1.0.0.0/8"]) - ), - self.reactor, - use_proxy=True, - ) - - self.reactor.lookups["proxy.com"] = "1.2.3.5" - d = agent.request(b"GET", b"http://test.com") - - # there should be a pending TCP connection - clients = self.reactor.tcpClients - self.assertEqual(len(clients), 1) - (host, port, client_factory, _timeout, _bindAddress) = clients[0] - self.assertEqual(host, "1.2.3.5") - self.assertEqual(port, 8888) - - # make a test server, and wire up the client - http_server = self._make_connection( - client_factory, _get_test_protocol_factory() - ) - - # the FakeTransport is async, so we need to pump the reactor - self.reactor.advance(0) - - # now there should be a pending request - self.assertEqual(len(http_server.requests), 1) - - request = http_server.requests[0] - self.assertEqual(request.method, b"GET") - self.assertEqual(request.path, b"http://test.com") - self.assertEqual(request.requestHeaders.getRawHeaders(b"host"), [b"test.com"]) - request.write(b"result") - request.finish() - - self.reactor.advance(0) - - resp = self.successResultOf(d) - body = self.successResultOf(treq.content(resp)) - self.assertEqual(body, b"result") - @patch.dict(os.environ, {"HTTPS_PROXY": "proxy.com"}) def test_https_request_via_uppercase_proxy_with_blacklist(self): # The blacklist includes the configured proxy IP. @@ -484,50 +439,7 @@ class MatrixFederationAgentTests(TestCase): body = self.successResultOf(treq.content(resp)) self.assertEqual(body, b"result") - def test_http_request_via_proxy_with_blacklist(self): - # The blacklist includes the configured proxy IP. - agent = ProxyAgent( - BlacklistingReactorWrapper( - self.reactor, ip_whitelist=None, ip_blacklist=IPSet(["1.0.0.0/8"]) - ), - self.reactor, - http_proxy=b"proxy.com:8888", - ) - - self.reactor.lookups["proxy.com"] = "1.2.3.5" - d = agent.request(b"GET", b"http://test.com") - - # there should be a pending TCP connection - clients = self.reactor.tcpClients - self.assertEqual(len(clients), 1) - (host, port, client_factory, _timeout, _bindAddress) = clients[0] - self.assertEqual(host, "1.2.3.5") - self.assertEqual(port, 8888) - - # make a test server, and wire up the client - http_server = self._make_connection( - client_factory, _get_test_protocol_factory() - ) - - # the FakeTransport is async, so we need to pump the reactor - self.reactor.advance(0) - - # now there should be a pending request - self.assertEqual(len(http_server.requests), 1) - - request = http_server.requests[0] - self.assertEqual(request.method, b"GET") - self.assertEqual(request.path, b"http://test.com") - self.assertEqual(request.requestHeaders.getRawHeaders(b"host"), [b"test.com"]) - request.write(b"result") - request.finish() - - self.reactor.advance(0) - - resp = self.successResultOf(d) - body = self.successResultOf(treq.content(resp)) - self.assertEqual(body, b"result") - + @patch.dict(os.environ, {"https_proxy": "proxy.com"}) def test_https_request_via_proxy_with_blacklist(self): # The blacklist includes the configured proxy IP. agent = ProxyAgent( @@ -536,7 +448,7 @@ class MatrixFederationAgentTests(TestCase): ), self.reactor, contextFactory=get_test_https_policy(), - https_proxy=b"proxy.com", + use_proxy=True, ) self.reactor.lookups["proxy.com"] = "1.2.3.5"