Ryan Barrett 2024-01-22 08:41:25 -08:00
rodzic 4e5021e2b0
commit 4bcf6b463f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 30 dodań i 4 usunięć

Wyświetl plik

@ -106,8 +106,8 @@ class FollowCallback(indieauth.Callback):
flash(f"{addr} isn't a native fediverse account")
return redirect(user.user_page_path('following'))
as2_url = webfinger.fetch_actor_url(addr)
if not as2_url:
flash(f"Couldn't find ActivityPub profile link for {addr}")
if ActivityPub.owns_id(as2_url) is False:
flash(f"{addr} isn't a native fediverse account")
return redirect(user.user_page_path('following'))
# TODO(#512): follower will always be Web here, but we should generalize

Wyświetl plik

@ -197,7 +197,7 @@ class FollowTest(TestCase):
source_protocol='activitypub')
mock_get.side_effect = (
requests_response(''),
requests_response(''), # indieauth https://alice.com fetch for user json
)
mock_post.side_effect = (
requests_response('me=https://alice.com'),
@ -229,7 +229,7 @@ class FollowTest(TestCase):
}],
}
mock_get.side_effect = (
requests_response(''),
requests_response(''), # indieauth https://alice.com fetch for user json
self.as2_resp(followee),
self.as2_resp(followee),
)
@ -256,6 +256,32 @@ class FollowTest(TestCase):
self.assertEqual(["@example.com@web.brid.gy isn't a native fediverse account"],
get_flashed_messages())
def test_callback_upgraded_bridged_account_error(self, mock_get, mock_post):
mock_post.return_value = requests_response('me=https://alice.com')
mock_get.side_effect = [
requests_response(''), # indieauth https://alice.com fetch for user json
requests_response({ # webfinger
'subject': 'acct:bob.com@bob.com',
'aliases': ['https://bob.com/'],
'links': [{
'rel': 'self',
'type': as2.CONTENT_TYPE,
'href': 'https://web.brid.gy/bob.com',
}],
}),
]
bob = self.make_user('bob.com', cls=Web, obj_id='https://bob.com/')
self.state['state'] = '@bob.com@bob.com'
state = util.encode_oauth_state(self.state)
resp = self.client.get(f'/follow/callback?code=my_code&state={state}')
self.assertEqual(302, resp.status_code)
self.assertEqual('/web/alice.com/following', resp.headers['Location'])
self.assertEqual(["@bob.com@bob.com isn't a native fediverse account"],
get_flashed_messages())
def check(self, input, resp, expected_follow, mock_get, mock_post,
fetched_followee=True):
self.assertEqual(302, resp.status_code)