summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/roots/test-linkcheck-localserver-https/conf.py1
-rw-r--r--tests/roots/test-linkcheck-localserver-https/index.rst1
-rw-r--r--tests/test_build_linkcheck.py20
3 files changed, 22 insertions, 0 deletions
diff --git a/tests/roots/test-linkcheck-localserver-https/conf.py b/tests/roots/test-linkcheck-localserver-https/conf.py
new file mode 100644
index 000000000..a45d22e28
--- /dev/null
+++ b/tests/roots/test-linkcheck-localserver-https/conf.py
@@ -0,0 +1 @@
+exclude_patterns = ['_build']
diff --git a/tests/roots/test-linkcheck-localserver-https/index.rst b/tests/roots/test-linkcheck-localserver-https/index.rst
new file mode 100644
index 000000000..fea598359
--- /dev/null
+++ b/tests/roots/test-linkcheck-localserver-https/index.rst
@@ -0,0 +1 @@
+`HTTPS server <https://localhost:7777/>`_
diff --git a/tests/test_build_linkcheck.py b/tests/test_build_linkcheck.py
index 683540baa..d7c254f4d 100644
--- a/tests/test_build_linkcheck.py
+++ b/tests/test_build_linkcheck.py
@@ -269,3 +269,23 @@ def test_follows_redirects_on_GET(app, capsys):
127.0.0.1 - - [] "GET /?redirected=1 HTTP/1.1" 204 -
"""
)
+
+@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver-https', freshenv=True)
+def test_invalid_ssl(app, status, warning):
+ # Link indicates SSL should be used (https) but the server does not handle it.
+ class OKHandler(http.server.BaseHTTPRequestHandler):
+ def do_GET(self):
+ self.send_response(200, "OK")
+ self.end_headers()
+ self.wfile.write(b"ok\n")
+
+ with http_server(OKHandler):
+ app.builder.build_all()
+
+ with open(app.outdir / 'output.json') as fp:
+ content = json.load(fp)
+ assert content["status"] == "broken"
+ assert content["filename"] == "index.rst"
+ assert content["lineno"] == 1
+ assert content["uri"] == "https://localhost:7777/"
+ assert "SSLError" in content["info"]