Ryan Barrett 2023-09-27 09:42:40 -07:00
rodzic eb4d4cc9db
commit 771de9770e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
5 zmienionych plików z 33 dodań i 6 usunięć

Wyświetl plik

@ -526,7 +526,7 @@ class Protocol:
# TODO: do we convert stop-following to webmention 410 of original
# follow?
elif obj.type == 'update':
elif obj.type in ('update', 'like', 'share'): # require object
if not inner_obj_id:
error("Couldn't find id of object to update")

Wyświetl plik

@ -777,6 +777,16 @@ class ActivityPubTest(TestCase):
self.assert_user(ActivityPub, 'https://mas.to/actor',
obj_as2=LIKE_ACTOR, direct=True)
def test_inbox_like_no_object_error(self, *_):
Fake.fetchable = {'fake:user': {'id': 'fake:user'}}
got = self.post('/inbox', json={
'id': 'fake:like',
'type': 'Like',
'actor': 'fake:user',
'object': None,
})
self.assertEqual(400, got.status_code)
def test_inbox_follow_accept_with_id(self, *mocks):
self._test_inbox_follow_accept(FOLLOW_WRAPPED, ACCEPT, 200, *mocks)

Wyświetl plik

@ -759,6 +759,26 @@ class ProtocolReceiveTest(TestCase):
self.assertEqual([(like_obj, 'fake:post:target')], Fake.sent)
def test_like_no_object_error(self):
with self.assertRaises(BadRequest):
Fake.receive_as1({
'id': 'fake:like',
'objectType': 'activity',
'verb': 'like',
'actor': 'fake:user',
'object': None,
})
def test_share_no_object_error(self):
with self.assertRaises(BadRequest):
Fake.receive_as1({
'id': 'fake:share',
'objectType': 'activity',
'verb': 'share',
'actor': 'fake:user',
'object': None,
})
def test_delete(self):
g.user = None # should use activity's actor
self.make_followers()

Wyświetl plik

@ -1884,10 +1884,7 @@ class WebUtilTest(TestCase):
for id in 'user.com', 'http://user.com', 'https://user.com/':
self.assertEqual(Web(id='user.com').key, Web.key_for(id))
with self.assertRaises(ValueError):
Web.key_for('')
for bad in 'foo', 'https://foo/', 'foo bar', 'user.json':
for bad in '', 'foo', 'https://foo/', 'foo bar', 'user.json':
with self.subTest(bad=bad):
self.assertIsNone(Web.key_for(bad))

2
web.py
Wyświetl plik

@ -247,7 +247,7 @@ class Web(User, Protocol):
ValueError
"""
if not id:
raise ValueError()
return None
if util.is_web(id):
parsed = urlparse(id)