activitypub.actor: check enabled protocols

pull/908/head
Ryan Barrett 2024-02-29 12:48:35 -08:00
rodzic d2aac7a5ca
commit 0610c3c175
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 12 dodań i 1 usunięć

Wyświetl plik

@ -803,6 +803,8 @@ def actor(handle_or_id):
cls = Protocol.for_request(fed='web')
if not cls:
error(f"Couldn't determine protocol", status=404)
elif not common.is_enabled(cls, ActivityPub):
error(f'{cls.LABEL} <=> activitypub not enabled')
elif cls.LABEL == 'web' and request.path.startswith('/ap/'):
# we started out with web users' AP ids as fed.brid.gy/[domain], so we
# need to preserve those for backward compatibility

Wyświetl plik

@ -437,7 +437,16 @@ class ActivityPubTest(TestCase):
'type': 'Application',
}, got.json, ignore=['publicKeyPem'])
def test_actor_no_handle(self, *_):
def test_actor_atproto_not_enabled(self, *_):
# self.store_object(id='at://did:plc:user/app.bsky.actor.profile/self',
# our_as1={'foo': 'bar'}, source_protocol='atproto')
self.store_object(id='did:plc:user', raw={'foo': 'baz'})
self.make_user('did:plc:user', cls=ATProto)
got = self.client.get('/ap/did:plc:user', base_url='https://atproto.brid.gy/')
self.assertEqual(400, got.status_code)
@patch('common.ENABLED_BRIDGES', new=[('activitypub', 'atproto')])
def test_actor_atproto_no_handle(self, *_):
self.store_object(id='did:plc:user', raw={'foo': 'bar'})
self.make_user('did:plc:user', cls=ATProto)
got = self.client.get('/ap/did:plc:user', base_url='https://atproto.brid.gy/')