Skip to main content

tests: example.com is fixed, so use a different site for SSL errors

ID
e8ef8bc
date
2026-04-16 07:40:39+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
da2d221
message
tests: example.com is fixed, so use a different site for SSL errors
changed files
2 files, 47 additions

Changed files

tests/fixtures/cassettes/TestIsMastodonHost.test_non_mastodon_servers[example.com].yml (0) → tests/fixtures/cassettes/TestIsMastodonHost.test_non_mastodon_servers[example.com].yml (1220)

diff --git a/tests/fixtures/cassettes/TestIsMastodonHost.test_non_mastodon_servers[example.com].yml b/tests/fixtures/cassettes/TestIsMastodonHost.test_non_mastodon_servers[example.com].yml
new file mode 100644
index 0000000..ad3cd1b
--- /dev/null
+++ b/tests/fixtures/cassettes/TestIsMastodonHost.test_non_mastodon_servers[example.com].yml
@@ -0,0 +1,43 @@
+interactions:
+- request:
+    body: null
+    headers:
+      Connection:
+      - close
+      Host:
+      - example.com
+      User-Agent:
+      - Python-urllib/3.13
+    method: GET
+    uri: https://example.com/.well-known/nodeinfo
+  response:
+    body:
+      string: '<!doctype html><html lang="en"><head><title>Example Domain</title><meta
+        name="viewport" content="width=device-width, initial-scale=1"><style>body{background:#eee;width:60vw;margin:15vh
+        auto;font-family:system-ui,sans-serif}h1{font-size:1.5em}div{opacity:0.8}a:link,a:visited{color:#348}</style></head><body><div><h1>Example
+        Domain</h1><p>This domain is for use in documentation examples without needing
+        permission. Avoid use in operations.</p><p><a href="https://iana.org/domains/example">Learn
+        more</a></p></div></body></html>
+
+        '
+    headers:
+      Age:
+      - '12220'
+      CF-RAY:
+      - 9ed186ff4e92773e-LHR
+      Connection:
+      - close
+      Content-Type:
+      - text/html
+      Date:
+      - Thu, 16 Apr 2026 07:37:53 GMT
+      Server:
+      - cloudflare
+      Transfer-Encoding:
+      - chunked
+      cf-cache-status:
+      - HIT
+    status:
+      code: 404
+      message: Not Found
+version: 1

tests/test_urls.py (5594) → tests/test_urls.py (5789)

diff --git a/tests/test_urls.py b/tests/test_urls.py
index 12151b7..d67b690 100644
--- a/tests/test_urls.py
+++ b/tests/test_urls.py
@@ -173,6 +173,10 @@ class TestIsMastodonHost:
             # PeerTube exposes /.well-known/nodeinfo, but it's running
             # different software.
             "peertube.tv",
+            #
+            # A website with a known bad SSL certificate, which is assumed
+            # not to be a Mastodon host because we can't connect to it.
+            "expired.badssl.com",
         ],
     )
     def test_non_mastodon_servers(self, host: str, vcr_cassette: Cassette) -> None: