exclude tests on old OpenSSL without ALPN

This commit is contained in:
Thomas Kriechbaumer 2015-06-18 10:36:58 +02:00
parent 559c80214d
commit bd0cfef357
2 changed files with 44 additions and 39 deletions

View File

@ -1,6 +1,7 @@
import json import json
import cStringIO import cStringIO
import re import re
import OpenSSL
from mock import Mock from mock import Mock
from netlib import tcp, http, http2 from netlib import tcp, http, http2
@ -231,41 +232,43 @@ class TestDaemon(_TestDaemon):
class TestDaemonHTTP2(_TestDaemon): class TestDaemonHTTP2(_TestDaemon):
ssl = True ssl = True
def test_http2(self): if OpenSSL._util.lib.Cryptography_HAS_ALPN:
c = pathoc.Pathoc(
("127.0.0.1", self.d.port),
use_http2 = True,
ssl = True,
)
assert isinstance(c.protocol, http2.HTTP2Protocol)
c = pathoc.Pathoc( def test_http2(self):
("127.0.0.1", self.d.port), c = pathoc.Pathoc(
) ("127.0.0.1", self.d.port),
assert c.protocol == None # TODO: change if other protocols get implemented use_http2 = True,
ssl = True,
)
assert isinstance(c.protocol, http2.HTTP2Protocol)
def test_http2_alpn(self): c = pathoc.Pathoc(
c = pathoc.Pathoc( ("127.0.0.1", self.d.port),
("127.0.0.1", self.d.port), )
ssl = True, assert c.protocol == None # TODO: change if other protocols get implemented
use_http2 = True,
http2_skip_connection_preface = True,
)
tmp_convert_to_ssl = c.convert_to_ssl def test_http2_alpn(self):
c.convert_to_ssl = Mock() c = pathoc.Pathoc(
c.convert_to_ssl.side_effect = tmp_convert_to_ssl ("127.0.0.1", self.d.port),
c.connect() ssl = True,
use_http2 = True,
http2_skip_connection_preface = True,
)
_, kwargs = c.convert_to_ssl.call_args tmp_convert_to_ssl = c.convert_to_ssl
assert set(kwargs['alpn_protos']) == set([b'http1.1', b'h2']) c.convert_to_ssl = Mock()
c.convert_to_ssl.side_effect = tmp_convert_to_ssl
c.connect()
def test_request(self): _, kwargs = c.convert_to_ssl.call_args
c = pathoc.Pathoc( assert set(kwargs['alpn_protos']) == set([b'http1.1', b'h2'])
("127.0.0.1", self.d.port),
ssl = True, def test_request(self):
use_http2 = True, c = pathoc.Pathoc(
) ("127.0.0.1", self.d.port),
c.connect() ssl = True,
resp = c.request("get:/p/200") use_http2 = True,
assert resp.status_code == "200" )
c.connect()
resp = c.request("get:/p/200")
assert resp.status_code == "200"

View File

@ -1,8 +1,9 @@
import sys import sys
import cStringIO import cStringIO
import OpenSSL
from libpathod import pathod, version from libpathod import pathod, version
from netlib import tcp, http, http2 from netlib import tcp, http, http2
import tutils import tutils
@ -271,13 +272,14 @@ class TestDaemonSSL(CommonTests):
assert self.d.last_log()["cipher"][1] > 0 assert self.d.last_log()["cipher"][1] > 0
class TestHTTP2(tutils.DaemonTests): class TestHTTP2(tutils.DaemonTests):
force_http2 = True
ssl = True ssl = True
noweb = True noweb = True
noapi = True noapi = True
nohang = True nohang = True
def test_http2(self): if OpenSSL._util.lib.Cryptography_HAS_ALPN:
r, _ = self.pathoc(["GET:/"], ssl=True, use_http2=True)
print(r) def test_http2(self):
assert r[0].status_code == "800" r, _ = self.pathoc(["GET:/"], ssl=True, use_http2=True)
print(r)
assert r[0].status_code == "800"