diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_pathoc.py | 2 | ||||
-rw-r--r-- | test/test_pathod.py | 32 | ||||
-rw-r--r-- | test/tutils.py | 8 |
3 files changed, 34 insertions, 8 deletions
diff --git a/test/test_pathoc.py b/test/test_pathoc.py index d96a1728..5d676d25 100644 --- a/test/test_pathoc.py +++ b/test/test_pathoc.py @@ -3,7 +3,7 @@ from libpathod import pathoc, test, version, pathod import tutils def test_response(): - r = pathoc.Response("1.1", 200, "Message", {}, None) + r = pathoc.Response("1.1", 200, "Message", {}, None, None) assert repr(r) diff --git a/test/test_pathod.py b/test/test_pathod.py index 9ab6d66d..6fc31677 100644 --- a/test/test_pathod.py +++ b/test/test_pathod.py @@ -1,3 +1,4 @@ +import pprint from libpathod import pathod, version from netlib import tcp, http import requests @@ -54,12 +55,26 @@ class TestNoApi(tutils.DaemonTests): class TestNotAfterConnect(tutils.DaemonTests): ssl = False - not_after_connect = True + ssloptions = dict( + not_after_connect = True + ) def test_connect(self): r = self.pathoc(r"get:'http://foo.com/p/202':da", connect_to=("localhost", self.d.port)) assert r.status_code == 202 +class TestSSLCN(tutils.DaemonTests): + ssl = True + ssloptions = dict( + cn = "foo.com" + ) + def test_connect(self): + r = self.pathoc(r"get:/p/202") + assert r.status_code == 202 + assert r.sslinfo + assert r.sslinfo.certchain[0].get_subject().CN == "foo.com" + + class TestNohang(tutils.DaemonTests): nohang = True def test_nohang(self): @@ -159,11 +174,20 @@ class CommonTests(tutils.DaemonTests): class TestDaemon(CommonTests): ssl = False def test_connect(self): - r = self.pathoc(r"get:'http://foo.com/p/202':da", connect_to=("localhost", self.d.port), ssl=True) + r = self.pathoc( + r"get:'http://foo.com/p/202':da", + connect_to=("localhost", self.d.port), + ssl=True + ) assert r.status_code == 202 def test_connect_err(self): - tutils.raises(http.HttpError, self.pathoc, r"get:'http://foo.com/p/202':da", connect_to=("localhost", self.d.port)) + tutils.raises( + http.HttpError, + self.pathoc, + r"get:'http://foo.com/p/202':da", + connect_to=("localhost", self.d.port) + ) class TestDaemonSSL(CommonTests): @@ -182,5 +206,3 @@ class TestDaemonSSL(CommonTests): assert l["type"] == "error" assert "SSL" in l["msg"] - - diff --git a/test/tutils.py b/test/tutils.py index 1baf16e2..2c3a2c9d 100644 --- a/test/tutils.py +++ b/test/tutils.py @@ -10,10 +10,13 @@ class DaemonTests: ssl = False timeout = None hexdump = False - not_after_connect = False + ssloptions = None @classmethod def setUpAll(self): - so = pathod.SSLOptions(not_after_connect = self.not_after_connect) + opts = self.ssloptions or {} + self.confdir = tempfile.mkdtemp() + opts["confdir"] = self.confdir + so = pathod.SSLOptions(**opts) self.d = test.Daemon( staticdir=test_data.path("data"), anchors=[("/anchor/.*", "202:da")], @@ -33,6 +36,7 @@ class DaemonTests: @classmethod def tearDownAll(self): self.d.shutdown() + shutil.rmtree(self.confdir) def setUp(self): if not (self.noweb or self.noapi): |