2018-02-06 00:12:36 -05:00
|
|
|
import json
|
|
|
|
from lxml import etree
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.django_db
|
|
|
|
def test_host_meta_json(client):
|
2023-08-10 02:52:37 -04:00
|
|
|
res = client.get("/.well-known/host-meta.json")
|
2018-02-06 00:12:36 -05:00
|
|
|
assert res.status_code == 200
|
2023-08-10 02:52:37 -04:00
|
|
|
assert res["Content-Type"] == "application/json"
|
2018-02-06 00:12:36 -05:00
|
|
|
meta = json.loads(res.content)
|
2023-08-10 02:52:37 -04:00
|
|
|
assert meta.keys() == {"links", "subject"}
|
|
|
|
assert meta["subject"] == "https://example.com"
|
|
|
|
assert len(meta["links"]) == 13
|
2018-02-06 00:12:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.django_db
|
|
|
|
def test_host_meta_xml(client):
|
2023-08-10 02:52:37 -04:00
|
|
|
res = client.get("/.well-known/host-meta")
|
2018-02-06 00:12:36 -05:00
|
|
|
assert res.status_code == 200
|
2023-08-10 02:52:37 -04:00
|
|
|
assert res["Content-Type"] == "application/xrd+xml"
|
2018-02-06 00:12:36 -05:00
|
|
|
root = etree.XML(res.content)
|
2023-08-10 02:52:37 -04:00
|
|
|
ns = "{http://docs.oasis-open.org/ns/xri/xrd-1.0}"
|
|
|
|
assert root.tag == (ns + "XRD")
|
|
|
|
assert root.findtext(ns + "Subject") == "https://example.com"
|
|
|
|
assert len(root.findall(ns + "Link")) == 13
|