Exemplo n.º 1
0
 def test_handle_lowercased(self, mock_get_func):
     mock_get_profile = Mock(side_effect=Exception)
     mock_get_func.return_value = mock_get_profile
     request = RequestFactory().get("/.well-known/webfinger?resource=acct:[email protected]")
     try:
         rfc7033_webfinger_view(request)
     except Exception:
         pass
     mock_get_profile.assert_called_once_with(handle='*****@*****.**', request=request)
Exemplo n.º 2
0
 def test_rendered_webfinger_returned(self):
     request = RequestFactory().get("/.well-known/webfinger?resource=acct:[email protected]")
     response = rfc7033_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]",
         "aliases": [
             "https://example.com/profile/1234/",
             "https://example.com/p/1234/",
         ],
         "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": "self",
                 "href": "https://example.com/p/1234/",
                 "type": "application/activity+json",
             },
             {
                 "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}",
             },
         ],
     }
Exemplo n.º 3
0
 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 = rfc7033_webfinger_view(request)
     assert response.status_code == 404
Exemplo n.º 4
0
 def test_invalid_resource_returns_bad_request(self):
     request = RequestFactory().get("/.well-known/webfinger?resource=foobar")
     response = rfc7033_webfinger_view(request)
     assert response.status_code == 400