kopia lustrzana https://gitlab.com/jaywink/federation
Merge pull request #14 from jaywink/nodeinfo-wellknown
Add support for generating .well-known/nodeinfomerge-requests/130/head
commit
a04ab0b91b
|
@ -1,3 +1,8 @@
|
|||
## [unreleased]
|
||||
|
||||
### Added
|
||||
- Support for generating `.well-known/nodeinfo` document, which was forgotten from the 0.3.0 release. Method `federation.hostmeta.generators.get_nodeinfo_well_known_document` does this task. It requires an `url` which should be the full base url of the host. Optionally `document_path` can be specified, but it is optional and defaults to the one in the NodeInfo spec.
|
||||
|
||||
## [0.3.0] - 2016-04-13
|
||||
|
||||
### Added
|
||||
|
|
|
@ -262,3 +262,30 @@ class NodeInfo(object):
|
|||
if self.raise_on_validate:
|
||||
raise
|
||||
warnings.warn("NodeInfo document generated does not validate against NodeInfo 1.0 specification.")
|
||||
|
||||
|
||||
# The default NodeInfo document path
|
||||
NODEINFO_DOCUMENT_PATH = "/nodeinfo/1.0"
|
||||
|
||||
|
||||
def get_nodeinfo_well_known_document(url, document_path=None):
|
||||
"""Generate a NodeInfo .well-known document.
|
||||
|
||||
See spec: http://nodeinfo.diaspora.software
|
||||
|
||||
Args:
|
||||
url (str) - The full base url with protocol, ie https://example.com
|
||||
document_path (str) - Custom NodeInfo document path if supplied
|
||||
|
||||
:rtype: dict
|
||||
"""
|
||||
return {
|
||||
"links": [
|
||||
{
|
||||
"rel": "http://nodeinfo.diaspora.software/ns/schema/1.0",
|
||||
"href": "{url}{path}".format(
|
||||
url=url, path=document_path or NODEINFO_DOCUMENT_PATH
|
||||
)
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ from jsonschema import validate, ValidationError
|
|||
import pytest
|
||||
|
||||
from federation.hostmeta.generators import generate_host_meta, generate_legacy_webfinger, generate_hcard, \
|
||||
SocialRelayWellKnown, NodeInfo
|
||||
SocialRelayWellKnown, NodeInfo, get_nodeinfo_well_known_document
|
||||
|
||||
DIASPORA_HOSTMETA = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
|
@ -189,3 +189,8 @@ class TestNodeInfoGenerator(object):
|
|||
def test_nodeinfo_generator_render_returns_a_document(self):
|
||||
nodeinfo = self._valid_nodeinfo()
|
||||
assert isinstance(nodeinfo.render(), str)
|
||||
|
||||
def test_nodeinfo_wellknown_document(self):
|
||||
wellknown = get_nodeinfo_well_known_document("https://example.com")
|
||||
assert wellknown["links"][0]["rel"] == "http://nodeinfo.diaspora.software/ns/schema/1.0"
|
||||
assert wellknown["links"][0]["href"] == "https://example.com/nodeinfo/1.0"
|
||||
|
|
Ładowanie…
Reference in New Issue