def test_rendered_webfinger_returned(self): request = RequestFactory().get( "/.well-known/webfinger?resource=acct:[email protected]") response = rfc3033_webfinger_view(request) assert response.status_code == 200 assert response['Content-Type'] == "application/jrd+json" assert json.loads(response.content.decode("utf-8")) == { "subject": "acct:[email protected]", "links": [ { "rel": "http://microformats.org/profile/hcard", "type": "text/html", "href": "https://example.com/hcard/users/1234", }, { "rel": "http://joindiaspora.com/seed_location", "type": "text/html", "href": "https://example.com", }, { "rel": "http://webfinger.net/rel/profile-page", "type": "text/html", "href": "https://example.com/profile/1234/", }, { "rel": "salmon", "href": "https://example.com/receive/users/1234", }, { "rel": "http://schemas.google.com/g/2010#updates-from", "type": "application/atom+xml", "href": "https://example.com/profile/1234/atom.xml", }, { "rel": "http://ostatus.org/schema/1.0/subscribe", "template": "https://example.com/search?q={uri}", }, ], }
def test_unknown_handle_returns_not_found(self, mock_get_func): mock_get_func.return_value = Mock(side_effect=Exception) request = RequestFactory().get("/.well-known/webfinger?resource=acct:[email protected]") response = rfc3033_webfinger_view(request) assert response.status_code == 404
def test_invalid_resource_returns_bad_request(self): request = RequestFactory().get("/.well-known/webfinger?resource=foobar") response = rfc3033_webfinger_view(request) assert response.status_code == 400