aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_pathoc.py79
-rw-r--r--test/test_pathod.py14
2 files changed, 49 insertions, 44 deletions
diff --git a/test/test_pathoc.py b/test/test_pathoc.py
index d39f9275..9b1ed8b4 100644
--- a/test/test_pathoc.py
+++ b/test/test_pathoc.py
@@ -1,6 +1,7 @@
import json
import cStringIO
import re
+import OpenSSL
from mock import Mock
from netlib import tcp, http, http2
@@ -231,41 +232,43 @@ class TestDaemon(_TestDaemon):
class TestDaemonHTTP2(_TestDaemon):
ssl = True
- def test_http2(self):
- c = pathoc.Pathoc(
- ("127.0.0.1", self.d.port),
- use_http2 = True,
- ssl = True,
- )
- assert isinstance(c.protocol, http2.HTTP2Protocol)
-
- c = pathoc.Pathoc(
- ("127.0.0.1", self.d.port),
- )
- assert c.protocol == None # TODO: change if other protocols get implemented
-
- def test_http2_alpn(self):
- c = pathoc.Pathoc(
- ("127.0.0.1", self.d.port),
- ssl = True,
- use_http2 = True,
- http2_skip_connection_preface = True,
- )
-
- tmp_convert_to_ssl = c.convert_to_ssl
- c.convert_to_ssl = Mock()
- c.convert_to_ssl.side_effect = tmp_convert_to_ssl
- c.connect()
-
- _, kwargs = c.convert_to_ssl.call_args
- assert set(kwargs['alpn_protos']) == set([b'http1.1', b'h2'])
-
- def test_request(self):
- c = pathoc.Pathoc(
- ("127.0.0.1", self.d.port),
- ssl = True,
- use_http2 = True,
- )
- c.connect()
- resp = c.request("get:/p/200")
- assert resp.status_code == "200"
+ if OpenSSL._util.lib.Cryptography_HAS_ALPN:
+
+ def test_http2(self):
+ c = pathoc.Pathoc(
+ ("127.0.0.1", self.d.port),
+ use_http2 = True,
+ ssl = True,
+ )
+ assert isinstance(c.protocol, http2.HTTP2Protocol)
+
+ c = pathoc.Pathoc(
+ ("127.0.0.1", self.d.port),
+ )
+ assert c.protocol == None # TODO: change if other protocols get implemented
+
+ def test_http2_alpn(self):
+ c = pathoc.Pathoc(
+ ("127.0.0.1", self.d.port),
+ ssl = True,
+ use_http2 = True,
+ http2_skip_connection_preface = True,
+ )
+
+ tmp_convert_to_ssl = c.convert_to_ssl
+ c.convert_to_ssl = Mock()
+ c.convert_to_ssl.side_effect = tmp_convert_to_ssl
+ c.connect()
+
+ _, kwargs = c.convert_to_ssl.call_args
+ assert set(kwargs['alpn_protos']) == set([b'http1.1', b'h2'])
+
+ def test_request(self):
+ c = pathoc.Pathoc(
+ ("127.0.0.1", self.d.port),
+ ssl = True,
+ use_http2 = True,
+ )
+ c.connect()
+ resp = c.request("get:/p/200")
+ assert resp.status_code == "200"
diff --git a/test/test_pathod.py b/test/test_pathod.py
index 1a3a5004..7cd2fccc 100644
--- a/test/test_pathod.py
+++ b/test/test_pathod.py
@@ -1,8 +1,9 @@
import sys
import cStringIO
+import OpenSSL
+
from libpathod import pathod, version
from netlib import tcp, http, http2
-
import tutils
@@ -271,13 +272,14 @@ class TestDaemonSSL(CommonTests):
assert self.d.last_log()["cipher"][1] > 0
class TestHTTP2(tutils.DaemonTests):
- force_http2 = True
ssl = True
noweb = True
noapi = True
nohang = True
- def test_http2(self):
- r, _ = self.pathoc(["GET:/"], ssl=True, use_http2=True)
- print(r)
- assert r[0].status_code == "800"
+ if OpenSSL._util.lib.Cryptography_HAS_ALPN:
+
+ def test_http2(self):
+ r, _ = self.pathoc(["GET:/"], ssl=True, use_http2=True)
+ print(r)
+ assert r[0].status_code == "800"