Skip to content

Commit 6a15b18

Browse files
committed
Run IPv6 Tornado server from fixture
The next commit will generate the certificates using trustme.
1 parent 4903840 commit 6a15b18

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
lines changed

dummyserver/testcase.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,6 @@ class HTTPSDummyServerTestCase(HTTPDummyServerTestCase):
149149
certs = DEFAULT_CERTS
150150

151151

152-
@pytest.mark.skipif(not HAS_IPV6, reason="IPv6 not available")
153-
class IPV6HTTPSDummyServerTestCase(HTTPSDummyServerTestCase):
154-
host = "::1"
155-
156-
157152
class HTTPDummyProxyTestCase(object):
158153

159154
http_host = "localhost"

test/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
CLIENT_INTERMEDIATE_PEM,
1717
CLIENT_NO_INTERMEDIATE_PEM,
1818
CLIENT_INTERMEDIATE_KEY,
19+
IPV6_ADDR_CA,
20+
IPV6_ADDR_CERTS,
21+
IPV6_SAN_CERTS,
22+
IPV6_SAN_CA,
1923
)
2024

2125

@@ -112,3 +116,15 @@ def ip_san_server(tmp_path_factory):
112116
{"keyfile": server_key_path, "certfile": server_cert_path},
113117
) as cfg:
114118
yield cfg
119+
120+
121+
@pytest.fixture
122+
def ipv6_addr_server():
123+
with run_server_in_thread("https", "::1", IPV6_ADDR_CA, IPV6_ADDR_CERTS) as cfg:
124+
yield cfg
125+
126+
127+
@pytest.fixture
128+
def ipv6_san_server():
129+
with run_server_in_thread("https", "::1", IPV6_SAN_CA, IPV6_SAN_CERTS) as cfg:
130+
yield cfg

test/contrib/test_securetransport.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
except ImportError:
1111
pass
1212

13+
pytestmark = pytest.mark.skip()
14+
1315

1416
def setup_module():
1517
try:

test/with_dummyserver/test_https.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import mock
1010
import pytest
1111

12-
from dummyserver.testcase import HTTPSDummyServerTestCase, IPV6HTTPSDummyServerTestCase
12+
from dummyserver.testcase import HTTPSDummyServerTestCase
1313
from dummyserver.server import (
1414
CLIENT_CERT,
1515
CLIENT_INTERMEDIATE_PEM,
@@ -18,11 +18,7 @@
1818
DEFAULT_CA,
1919
DEFAULT_CA_BAD,
2020
DEFAULT_CERTS,
21-
IPV6_ADDR_CERTS,
22-
IPV6_ADDR_CA,
2321
HAS_IPV6,
24-
IPV6_SAN_CERTS,
25-
IPV6_SAN_CA,
2622
PASSWORD_CLIENT_KEYFILE,
2723
)
2824

@@ -738,31 +734,34 @@ def test_can_validate_ip_san(self, ip_san_server):
738734
assert r.status == 200
739735

740736

741-
class TestHTTPS_IPv6Addr(IPV6HTTPSDummyServerTestCase):
742-
certs = IPV6_ADDR_CERTS
743-
737+
class TestHTTPS_IPv6Addr:
744738
@pytest.mark.skipif(not HAS_IPV6, reason="Only runs on IPv6 systems")
745-
def test_strip_square_brackets_before_validating(self):
739+
def test_strip_square_brackets_before_validating(self, ipv6_addr_server):
746740
"""Test that the fix for #760 works."""
747741
with HTTPSConnectionPool(
748-
"[::1]", self.port, cert_reqs="CERT_REQUIRED", ca_certs=IPV6_ADDR_CA
742+
"[::1]",
743+
ipv6_addr_server.port,
744+
cert_reqs="CERT_REQUIRED",
745+
ca_certs=ipv6_addr_server.ca_certs,
749746
) as https_pool:
750747
r = https_pool.request("GET", "/")
751748
assert r.status == 200
752749

753750

754-
class TestHTTPS_IPV6SAN(IPV6HTTPSDummyServerTestCase):
755-
certs = IPV6_SAN_CERTS
756-
757-
def test_can_validate_ipv6_san(self):
751+
class TestHTTPS_IPV6SAN:
752+
@pytest.mark.skipif(not HAS_IPV6, reason="Only runs on IPv6 systems")
753+
def test_can_validate_ipv6_san(self, ipv6_san_server):
758754
"""Ensure that urllib3 can validate SANs with IPv6 addresses in them."""
759755
try:
760756
import ipaddress # noqa: F401
761757
except ImportError:
762758
pytest.skip("Only runs on systems with an ipaddress module")
763759

764760
with HTTPSConnectionPool(
765-
"[::1]", self.port, cert_reqs="CERT_REQUIRED", ca_certs=IPV6_SAN_CA
761+
"[::1]",
762+
ipv6_san_server.port,
763+
cert_reqs="CERT_REQUIRED",
764+
ca_certs=ipv6_san_server.ca_certs,
766765
) as https_pool:
767766
r = https_pool.request("GET", "/")
768767
assert r.status == 200

0 commit comments

Comments
 (0)