diff options
Diffstat (limited to 'packages/meshbay-hub/tests/test_site_basics.py')
| -rw-r--r-- | packages/meshbay-hub/tests/test_site_basics.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/packages/meshbay-hub/tests/test_site_basics.py b/packages/meshbay-hub/tests/test_site_basics.py index 78cad83..5c19aa6 100644 --- a/packages/meshbay-hub/tests/test_site_basics.py +++ b/packages/meshbay-hub/tests/test_site_basics.py @@ -31,6 +31,20 @@ def test_robots_keeps_crawlers_out_of_the_signed_in_views(client): assert not any(rule in ("/", "/a/", "/app") for rule in rules), rules +def test_the_sitemap_is_valid_and_named_by_robots(client): + import xml.etree.ElementTree as ET + r = client.get("/sitemap.xml") + assert r.status_code == 200 + assert "xml" in r.headers["content-type"] + ns = {"s": "http://www.sitemaps.org/schemas/sitemap/0.9"} + locs = [e.text for e in ET.fromstring(r.content).findall("s:url/s:loc", ns)] + assert "https://meshbay.org/downloads/" in locs + assert all(loc.startswith("https://") for loc in locs), locs + # Nothing robots.txt forbids: a sitemap listing it is a contradiction. + assert not any("/app/" in loc or "/v1/" in loc for loc in locs), locs + assert "Sitemap: https://meshbay.org/sitemap.xml" in client.get("/robots.txt").text + + @pytest.mark.parametrize("path, magic", [ ("/favicon.ico", b"\x00\x00\x01\x00"), ("/apple-touch-icon.png", b"\x89PNG"), @@ -43,7 +57,7 @@ def test_the_icons_are_served_from_the_root(client, path, magic): @pytest.mark.skipif(not CADDYFILE.exists(), reason="no Caddyfile in this tree") -@pytest.mark.parametrize("path", ["/robots.txt", "/favicon.ico", "/apple-touch-icon.png"]) +@pytest.mark.parametrize("path", ["/robots.txt", "/sitemap.xml", "/favicon.ico", "/apple-touch-icon.png"]) def test_meshbay_org_sends_them_to_the_hub(path): """The public site owns only the paths its matcher names; a file claimed there would be looked for in /srv/meshbay/site and 404.""" |