From ba674ad5514c5f30315fc688a07fdac634d94dfc Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 1 Mar 2013 09:05:39 +1300 Subject: New SNI handling mechanism. --- test/tservers.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'test/tservers.py') diff --git a/test/tservers.py b/test/tservers.py index 998ad6c6..c8bc7100 100644 --- a/test/tservers.py +++ b/test/tservers.py @@ -126,20 +126,21 @@ class HTTPProxTest(ProxTestBase): """ Returns a connected Pathoc instance. """ - p = libpathod.pathoc.Pathoc("localhost", self.proxy.port) + p = libpathod.pathoc.Pathoc("localhost", self.proxy.port, ssl=self.ssl) p.connect(connect_to) return p def pathod(self, spec): """ - Constructs a pathod request, with the appropriate base and proxy. + Constructs a pathod GET request, with the appropriate base and proxy. """ - return hurl.get( - self.server.urlbase + "/p/" + spec, - proxy=self.proxies, - validate_cert=False, - #debug=hurl.utils.stdout_debug - ) + if self.ssl: + p = self.pathoc(("127.0.0.1", self.server.port)) + q = "get:'/p/%s'"%spec + else: + p = self.pathoc() + q = "get:'%s/p/%s'"%(self.server.urlbase, spec) + return p.request(q) class TResolver: @@ -155,9 +156,13 @@ class TransparentProxTest(ProxTestBase): @classmethod def get_proxy_config(cls): d = ProxTestBase.get_proxy_config() + if cls.ssl: + ports = [cls.server.port, cls.server2.port] + else: + ports = [] d["transparent_proxy"] = dict( resolver = TResolver(cls.server.port), - sslports = [] + sslports = ports ) return d @@ -166,12 +171,20 @@ class TransparentProxTest(ProxTestBase): Constructs a pathod request, with the appropriate base and proxy. """ r = hurl.get( - "http://127.0.0.1:%s"%self.proxy.port + "/p/" + spec, + "%s://127.0.0.1:%s"%(self.scheme, self.proxy.port) + "/p/" + spec, validate_cert=False, #debug=hurl.utils.stdout_debug ) return r + def pathoc(self, connect= None): + """ + Returns a connected Pathoc instance. + """ + p = libpathod.pathoc.Pathoc("localhost", self.proxy.port) + p.connect(connect_to) + return p + class ReverseProxTest(ProxTestBase): ssl = None -- cgit v1.2.3