Ryan Barrett 2023-01-25 20:59:40 -08:00
rodzic f0a5f1745e
commit d523cc085a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 1 dodań i 108 usunięć

Wyświetl plik

@ -39,7 +39,6 @@ class WebfingerTest(testutil.TestCase):
'https://foo.com/about-me',
'https://foo.com/',
],
'magic_keys': [{'value': self.key.href()}],
'links': [{
'rel': 'http://webfinger.net/rel/profile-page',
'type': 'text/html',
@ -67,20 +66,10 @@ class WebfingerTest(testutil.TestCase):
'rel': 'sharedInbox',
'type': 'application/activity+json',
'href': 'http://localhost/inbox'
}, {
'rel': 'magic-public-key',
'href': self.key.href(),
}, {
'rel': 'http://ostatus.org/schema/1.0/subscribe',
'template': 'http://localhost/user/foo.com?url={uri}',
}, {
'rel': 'http://schemas.google.com/g/2010#updates-from',
'type': 'application/atom+xml',
'href': 'https://granary.io/url?input=html&output=atom&url=https%3A%2F%2Ffoo.com%2F&hub=https%3A%2F%2Ffoo.com%2F',
}, {
'rel': 'hub',
'href': 'https://bridgy-fed.superfeedr.com/'
}]
}],
}
def test_host_meta_xrd(self):
@ -116,50 +105,6 @@ class WebfingerTest(testutil.TestCase):
self.assertEqual(self.expected_webfinger, got.json)
# check that magic key is persistent
again = self.client.get('/acct:foo.com',
headers={'Accept': 'application/json'}).json
self.assertEqual(self.key.href(), again['magic_keys'][0]['value'])
links = {l['rel']: l.get('href') for l in again['links']}
self.assertEqual(self.key.href(), links['magic-public-key'])
@mock.patch('requests.get')
def test_user_with_atom_feed(self, mock_get):
html = """\
<html>
<head>
<link rel="feed" href="/dont-use">
<link rel="alternate" type="application/rss+xml" href="/dont-use-either">
<link rel="alternate" type="application/atom+xml" href="/use-this">
</head>
""" + self.html
mock_get.return_value = requests_response(html, url = 'https://foo.com/')
got = self.client.get('/acct:foo.com', headers={'Accept': 'application/json'})
self.assertEqual(200, got.status_code)
self.assertIn({
'rel': 'http://schemas.google.com/g/2010#updates-from',
'type': 'application/atom+xml',
'href': 'https://foo.com/use-this',
}, got.json['links'])
@mock.patch('requests.get')
def test_user_with_push_header(self, mock_get):
mock_get.return_value = requests_response(
self.html, url = 'https://foo.com/', headers={
'Link': 'badly formatted, '
"<xyz>; rel='foo',"
'<http://a.custom.hub/>; rel="hub"',
})
got = self.client.get('/acct:foo.com', headers={'Accept': 'application/json'})
self.assertEqual(200, got.status_code)
self.assertIn({
'rel': 'hub',
'href': 'http://a.custom.hub/',
}, got.json['links'])
@mock.patch('requests.get')
def test_user_no_hcard(self, mock_get):
mock_get.return_value = requests_response("""
@ -175,7 +120,6 @@ class WebfingerTest(testutil.TestCase):
self.assert_equals({
'subject': 'acct:foo.com@foo.com',
'aliases': ['https://foo.com/'],
'magic_keys': [{'value': self.key.href()}],
'links': [{
'rel': 'http://webfinger.net/rel/profile-page',
'type': 'text/html',
@ -196,16 +140,6 @@ class WebfingerTest(testutil.TestCase):
'rel': 'sharedInbox',
'type': 'application/activity+json',
'href': 'http://localhost/inbox'
}, {
'rel': 'http://schemas.google.com/g/2010#updates-from',
'type': 'application/atom+xml',
'href': 'https://granary.io/url?input=html&output=atom&url=https%3A%2F%2Ffoo.com%2F&hub=https%3A%2F%2Ffoo.com%2F',
}, {
'rel': 'hub',
'href': 'https://bridgy-fed.superfeedr.com/'
}, {
'rel': 'magic-public-key',
'href': self.key.href(),
}, {
'rel': 'http://ostatus.org/schema/1.0/subscribe',
'template': 'http://localhost/user/foo.com?url={uri}',

Wyświetl plik

@ -84,7 +84,6 @@ class Actor(flask_util.XrdOrJrd):
data = util.trim_nulls({
'subject': 'acct:' + user.address().lstrip('@'),
'aliases': urls,
'magic_keys': [{'value': user.href()}],
'links': sum(([{
'rel': 'http://webfinger.net/rel/profile-page',
'type': 'text/html',
@ -119,13 +118,6 @@ class Actor(flask_util.XrdOrJrd):
'href': common.host_url('inbox'),
},
# OStatus
# TODO: remove?
{
'rel': 'magic-public-key',
'href': user.href(),
},
# remote follow
# https://socialhub.activitypub.rocks/t/what-is-the-current-spec-for-remote-follow/2020/11?u=snarfed
# https://github.com/snarfed/bridgy-fed/issues/60#issuecomment-1325589750
@ -135,39 +127,6 @@ class Actor(flask_util.XrdOrJrd):
}]
})
# OStatus: discover atom feed, if any
# TODO: remove?
if resp:
feed = parsed.find('link', rel='alternate', type=atom.CONTENT_TYPE)
if feed and feed['href']:
feed = urllib.parse.urljoin(resp.url, feed['href'])
else:
feed = 'https://granary.io/url?' + urllib.parse.urlencode({
'input': 'html',
'output': 'atom',
'url': resp.url,
'hub': resp.url,
})
data['links'].append({
'rel': 'http://schemas.google.com/g/2010#updates-from',
'type': atom.CONTENT_TYPE,
'href': feed,
})
# OStatus: discover PuSH, if any
# TODO: remove?
if resp:
for link in resp.headers.get('Link', '').split(','):
match = common.LINK_HEADER_RE.match(link)
if match and match.group(2) == 'hub':
hub = match.group(1)
else:
hub = 'https://bridgy-fed.superfeedr.com/'
data['links'].append({
'rel': 'hub',
'href': hub,
})
logger.info(f'Returning WebFinger data: {json_dumps(data, indent=2)}')
return data