See #192: added .well-known/nodeinfo endpoint

merge-requests/237/head
Eliot Berriot 2018-05-07 22:28:46 +02:00
rodzic 6ff8c2c8da
commit d88b7869fe
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: DD6965E2476E5C27
2 zmienionych plików z 45 dodań i 1 usunięć

Wyświetl plik

@ -85,13 +85,31 @@ class InstanceActorViewSet(FederationMixin, viewsets.GenericViewSet):
return response.Response({}, status=200)
class WellKnownViewSet(FederationMixin, viewsets.GenericViewSet):
class WellKnownViewSet(viewsets.GenericViewSet):
authentication_classes = []
permission_classes = []
renderer_classes = [renderers.WebfingerRenderer]
@list_route(methods=['get'])
def nodeinfo(self, request, *args, **kwargs):
if not preferences.get('instance__nodeinfo_enabled'):
return HttpResponse(status=404)
data = {
'links': [
{
'rel': 'http://nodeinfo.diaspora.software/ns/schema/2.0',
'href': utils.full_url(
reverse('api:v1:instance:nodeinfo-2.0')
)
}
]
}
return response.Response(data)
@list_route(methods=['get'])
def webfinger(self, request, *args, **kwargs):
if not preferences.get('federation__enabled'):
return HttpResponse(status=405)
try:
resource_type, resource = webfinger.clean_resource(
request.GET['resource'])

Wyświetl plik

@ -70,6 +70,32 @@ def test_wellknown_webfinger_system(
assert response.data == serializer.data
def test_wellknown_nodeinfo(db, preferences, api_client, settings):
expected = {
'links': [
{
'rel': 'http://nodeinfo.diaspora.software/ns/schema/2.0',
'href': '{}{}'.format(
settings.FUNKWHALE_URL,
reverse('api:v1:instance:nodeinfo-2.0')
)
}
]
}
url = reverse('federation:well-known-nodeinfo')
response = api_client.get(url)
assert response.status_code == 200
assert response['Content-Type'] == 'application/jrd+json'
assert response.data == expected
def test_wellknown_nodeinfo_disabled(db, preferences, api_client):
preferences['instance__nodeinfo_enabled'] = False
url = reverse('federation:well-known-nodeinfo')
response = api_client.get(url)
assert response.status_code == 404
def test_audio_file_list_requires_authenticated_actor(
db, preferences, api_client):
preferences['federation__music_needs_approval'] = True