Test cert file specification, spruce up server testing truss a bit.

This commit is contained in:
Aldo Cortesi 2013-02-24 22:52:59 +13:00
parent 0257815141
commit b077189dd5
2 changed files with 25 additions and 13 deletions

View File

@ -143,6 +143,13 @@ class TestHTTPS(tservers.HTTPProxTest, SanityMixin):
assert self.server.last_log()["request"]["clientcert"]["keyinfo"] assert self.server.last_log()["request"]["clientcert"]["keyinfo"]
class TestHTTPSCertfile(tservers.HTTPProxTest, SanityMixin):
ssl = True
certfile = True
def test_certfile(self):
assert self.pathod("304")
class TestReverse(tservers.ReverseProxTest, SanityMixin): class TestReverse(tservers.ReverseProxTest, SanityMixin):
reverse = True reverse = True

View File

@ -65,6 +65,11 @@ class ProxyThread(threading.Thread):
class ProxTestBase: class ProxTestBase:
# Test Configuration
ssl = None
clientcerts = False
certfile = None
masterclass = TestMaster masterclass = TestMaster
@classmethod @classmethod
def setupAll(cls): def setupAll(cls):
@ -106,17 +111,17 @@ class ProxTestBase:
(self.scheme, ("127.0.0.1", self.proxy.port)) (self.scheme, ("127.0.0.1", self.proxy.port))
) )
class HTTPProxTest(ProxTestBase):
ssl = None
clientcerts = False
@classmethod @classmethod
def get_proxy_config(cls): def get_proxy_config(cls):
d = dict() d = dict()
if cls.clientcerts: if cls.clientcerts:
d["clientcerts"] = tutils.test_data.path("data/clientcert") d["clientcerts"] = tutils.test_data.path("data/clientcert")
if cls.certfile:
d["certfile"] =tutils.test_data.path("data/testkey.pem")
return d return d
class HTTPProxTest(ProxTestBase):
def pathoc(self, connect_to = None): def pathoc(self, connect_to = None):
""" """
Returns a connected Pathoc instance. Returns a connected Pathoc instance.
@ -149,12 +154,12 @@ class TransparentProxTest(ProxTestBase):
ssl = None ssl = None
@classmethod @classmethod
def get_proxy_config(cls): def get_proxy_config(cls):
return dict( d = ProxTestBase.get_proxy_config()
transparent_proxy = dict( d["transparent_proxy"] = dict(
resolver = TResolver(cls.server.port), resolver = TResolver(cls.server.port),
sslports = [] sslports = []
) )
) return d
def pathod(self, spec): def pathod(self, spec):
""" """
@ -172,13 +177,13 @@ class ReverseProxTest(ProxTestBase):
ssl = None ssl = None
@classmethod @classmethod
def get_proxy_config(cls): def get_proxy_config(cls):
return dict( d = ProxTestBase.get_proxy_config()
reverse_proxy = ( d["reverse_proxy"] = (
"https" if cls.ssl else "http", "https" if cls.ssl else "http",
"127.0.0.1", "127.0.0.1",
cls.server.port cls.server.port
) )
) return d
def pathod(self, spec): def pathod(self, spec):
""" """