aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_pathoc.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_pathoc.py')
-rw-r--r--test/test_pathoc.py32
1 files changed, 30 insertions, 2 deletions
diff --git a/test/test_pathoc.py b/test/test_pathoc.py
index ca25be58..38d3754a 100644
--- a/test/test_pathoc.py
+++ b/test/test_pathoc.py
@@ -3,10 +3,11 @@ from libpathod import pathoc, test, version
import tutils
-class TestDaemon:
+class _TestDaemon:
@classmethod
def setUpAll(self):
self.d = test.Daemon(
+ ssl=self.ssl,
staticdir=tutils.test_data.path("data"),
anchors=[("/anchor/.*", "202")]
)
@@ -19,11 +20,34 @@ class TestDaemon:
self.d.clear_log()
def test_info(self):
- c = pathoc.Pathoc("127.0.0.1", self.d.port)
+ c = pathoc.Pathoc(
+ "127.0.0.1",
+ self.d.port,
+ ssl = self.ssl
+ )
c.connect()
_, _, _, _, content = c.request("get:/api/info")
assert tuple(json.loads(content)["version"]) == version.IVERSION
+
+class TestDaemonSSL(_TestDaemon):
+ ssl = True
+ def test_sni(self):
+ c = pathoc.Pathoc(
+ "127.0.0.1",
+ self.d.port,
+ ssl = True,
+ sni = "foobar.com"
+ )
+ c.connect()
+ c.request("get:/p/200")
+ _, _, _, _, content = c.request("get:/api/log")
+ d = json.loads(content)
+ assert d["log"][0]["request"]["sni"] == "foobar.com"
+
+
+class TestDaemon(_TestDaemon):
+ ssl = False
def tval(self, requests, showreq=False, showresp=False, explain=False, hexdump=False, timeout=None, ignorecodes=None, ignoretimeout=None):
c = pathoc.Pathoc("127.0.0.1", self.d.port)
c.connect()
@@ -43,6 +67,10 @@ class TestDaemon:
)
return s.getvalue()
+ def test_ssl_error(self):
+ c = pathoc.Pathoc("127.0.0.1", self.d.port, ssl = True)
+ tutils.raises("ssl handshake", c.connect)
+
def test_ignorecodes(self):
assert "200" in self.tval(["get:'/p/200:b@1'"])
assert "200" not in self.tval(["get:'/p/200:b@1'"], ignorecodes=[200])