Skip to content

Commit d523cc0

Browse files
committed
1 parent f0a5f17 commit d523cc0

2 files changed

Lines changed: 1 addition & 108 deletions

File tree

tests/test_webfinger.py

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def setUp(self):
3939
'https://foo.com/about-me',
4040
'https://foo.com/',
4141
],
42-
'magic_keys': [{'value': self.key.href()}],
4342
'links': [{
4443
'rel': 'http://webfinger.net/rel/profile-page',
4544
'type': 'text/html',
@@ -67,20 +66,10 @@ def setUp(self):
6766
'rel': 'sharedInbox',
6867
'type': 'application/activity+json',
6968
'href': 'http://localhost/inbox'
70-
}, {
71-
'rel': 'magic-public-key',
72-
'href': self.key.href(),
7369
}, {
7470
'rel': 'http://ostatus.org/schema/1.0/subscribe',
7571
'template': 'http://localhost/user/foo.com?url={uri}',
76-
}, {
77-
'rel': 'http://schemas.google.com/g/2010#updates-from',
78-
'type': 'application/atom+xml',
79-
'href': 'https://granary.io/url?input=html&output=atom&url=https%3A%2F%2Ffoo.com%2F&hub=https%3A%2F%2Ffoo.com%2F',
80-
}, {
81-
'rel': 'hub',
82-
'href': 'https://bridgy-fed.superfeedr.com/'
83-
}]
72+
}],
8473
}
8574

8675
def test_host_meta_xrd(self):
@@ -116,50 +105,6 @@ def test_user(self, mock_get):
116105

117106
self.assertEqual(self.expected_webfinger, got.json)
118107

119-
# check that magic key is persistent
120-
again = self.client.get('/acct:foo.com',
121-
headers={'Accept': 'application/json'}).json
122-
self.assertEqual(self.key.href(), again['magic_keys'][0]['value'])
123-
124-
links = {l['rel']: l.get('href') for l in again['links']}
125-
self.assertEqual(self.key.href(), links['magic-public-key'])
126-
127-
@mock.patch('requests.get')
128-
def test_user_with_atom_feed(self, mock_get):
129-
html = """\
130-
<html>
131-
<head>
132-
<link rel="feed" href="/dont-use">
133-
<link rel="alternate" type="application/rss+xml" href="/dont-use-either">
134-
<link rel="alternate" type="application/atom+xml" href="/use-this">
135-
</head>
136-
""" + self.html
137-
mock_get.return_value = requests_response(html, url = 'https://foo.com/')
138-
139-
got = self.client.get('/acct:foo.com', headers={'Accept': 'application/json'})
140-
self.assertEqual(200, got.status_code)
141-
self.assertIn({
142-
'rel': 'http://schemas.google.com/g/2010#updates-from',
143-
'type': 'application/atom+xml',
144-
'href': 'https://foo.com/use-this',
145-
}, got.json['links'])
146-
147-
@mock.patch('requests.get')
148-
def test_user_with_push_header(self, mock_get):
149-
mock_get.return_value = requests_response(
150-
self.html, url = 'https://foo.com/', headers={
151-
'Link': 'badly formatted, '
152-
"<xyz>; rel='foo',"
153-
'<http://a.custom.hub/>; rel="hub"',
154-
})
155-
156-
got = self.client.get('/acct:foo.com', headers={'Accept': 'application/json'})
157-
self.assertEqual(200, got.status_code)
158-
self.assertIn({
159-
'rel': 'hub',
160-
'href': 'http://a.custom.hub/',
161-
}, got.json['links'])
162-
163108
@mock.patch('requests.get')
164109
def test_user_no_hcard(self, mock_get):
165110
mock_get.return_value = requests_response("""
@@ -175,7 +120,6 @@ def test_user_no_hcard(self, mock_get):
175120
self.assert_equals({
176121
'subject': 'acct:foo.com@foo.com',
177122
'aliases': ['https://foo.com/'],
178-
'magic_keys': [{'value': self.key.href()}],
179123
'links': [{
180124
'rel': 'http://webfinger.net/rel/profile-page',
181125
'type': 'text/html',
@@ -196,16 +140,6 @@ def test_user_no_hcard(self, mock_get):
196140
'rel': 'sharedInbox',
197141
'type': 'application/activity+json',
198142
'href': 'http://localhost/inbox'
199-
}, {
200-
'rel': 'http://schemas.google.com/g/2010#updates-from',
201-
'type': 'application/atom+xml',
202-
'href': 'https://granary.io/url?input=html&output=atom&url=https%3A%2F%2Ffoo.com%2F&hub=https%3A%2F%2Ffoo.com%2F',
203-
}, {
204-
'rel': 'hub',
205-
'href': 'https://bridgy-fed.superfeedr.com/'
206-
}, {
207-
'rel': 'magic-public-key',
208-
'href': self.key.href(),
209143
}, {
210144
'rel': 'http://ostatus.org/schema/1.0/subscribe',
211145
'template': 'http://localhost/user/foo.com?url={uri}',

webfinger.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ def template_vars(self, domain=None, url=None):
8484
data = util.trim_nulls({
8585
'subject': 'acct:' + user.address().lstrip('@'),
8686
'aliases': urls,
87-
'magic_keys': [{'value': user.href()}],
8887
'links': sum(([{
8988
'rel': 'http://webfinger.net/rel/profile-page',
9089
'type': 'text/html',
@@ -119,13 +118,6 @@ def template_vars(self, domain=None, url=None):
119118
'href': common.host_url('inbox'),
120119
},
121120

122-
# OStatus
123-
# TODO: remove?
124-
{
125-
'rel': 'magic-public-key',
126-
'href': user.href(),
127-
},
128-
129121
# remote follow
130122
# https://socialhub.activitypub.rocks/t/what-is-the-current-spec-for-remote-follow/2020/11?u=snarfed
131123
# https://github.com/snarfed/bridgy-fed/issues/60#issuecomment-1325589750
@@ -135,39 +127,6 @@ def template_vars(self, domain=None, url=None):
135127
}]
136128
})
137129

138-
# OStatus: discover atom feed, if any
139-
# TODO: remove?
140-
if resp:
141-
feed = parsed.find('link', rel='alternate', type=atom.CONTENT_TYPE)
142-
if feed and feed['href']:
143-
feed = urllib.parse.urljoin(resp.url, feed['href'])
144-
else:
145-
feed = 'https://granary.io/url?' + urllib.parse.urlencode({
146-
'input': 'html',
147-
'output': 'atom',
148-
'url': resp.url,
149-
'hub': resp.url,
150-
})
151-
data['links'].append({
152-
'rel': 'http://schemas.google.com/g/2010#updates-from',
153-
'type': atom.CONTENT_TYPE,
154-
'href': feed,
155-
})
156-
157-
# OStatus: discover PuSH, if any
158-
# TODO: remove?
159-
if resp:
160-
for link in resp.headers.get('Link', '').split(','):
161-
match = common.LINK_HEADER_RE.match(link)
162-
if match and match.group(2) == 'hub':
163-
hub = match.group(1)
164-
else:
165-
hub = 'https://bridgy-fed.superfeedr.com/'
166-
data['links'].append({
167-
'rel': 'hub',
168-
'href': hub,
169-
})
170-
171130
logger.info(f'Returning WebFinger data: {json_dumps(data, indent=2)}')
172131
return data
173132

0 commit comments

Comments
 (0)