kopia lustrzana https://github.com/snarfed/bridgy-fed
bring back default signing user for shared inbox
for #403, fixes https://console.cloud.google.com/errors/detail/CIfnyvKDx8mDTA;time=P30D?project=bridgy-federatedpull/413/head
rodzic
4b37674624
commit
3623df8e20
10
common.py
10
common.py
|
@ -71,7 +71,6 @@ DOMAIN_BLOCKLIST = frozenset((
|
|||
'twitter.com',
|
||||
) + DOMAINS)
|
||||
|
||||
# currently unused. TODO: remove?
|
||||
_DEFAULT_SIGNATURE_USER = None
|
||||
|
||||
CACHE_TIME = timedelta(seconds=60)
|
||||
|
@ -88,7 +87,6 @@ def host_url(path_query=None):
|
|||
return urllib.parse.urljoin(base, path_query)
|
||||
|
||||
|
||||
# currently unused. TODO: remove?
|
||||
def default_signature_user():
|
||||
global _DEFAULT_SIGNATURE_USER
|
||||
if _DEFAULT_SIGNATURE_USER is None:
|
||||
|
@ -101,6 +99,7 @@ def signed_get(url, user, **kwargs):
|
|||
|
||||
|
||||
def signed_post(url, user, **kwargs):
|
||||
assert user
|
||||
return signed_request(util.requests_post, url, user, **kwargs)
|
||||
|
||||
|
||||
|
@ -117,10 +116,13 @@ def signed_request(fn, url, user, data=None, log_data=True, headers=None, **kwar
|
|||
|
||||
Returns: :class:`requests.Response`
|
||||
"""
|
||||
assert user
|
||||
if headers is None:
|
||||
headers = {}
|
||||
|
||||
# prepare HTTP Signature and headers
|
||||
if not user:
|
||||
user = default_signature_user()
|
||||
|
||||
if data:
|
||||
if log_data:
|
||||
logging.info(f'Sending AS2 object: {json_dumps(data, indent=2)}')
|
||||
|
@ -200,8 +202,6 @@ def get_as2(url, user=None):
|
|||
If we raise a werkzeug HTTPException, it will have an additional
|
||||
requests_response attribute with the last requests.Response we received.
|
||||
"""
|
||||
assert user
|
||||
|
||||
def _error(resp):
|
||||
msg = f"Couldn't fetch {url} as ActivityStreams 2"
|
||||
logger.warning(msg)
|
||||
|
|
|
@ -357,7 +357,13 @@ class ActivityPubTest(testutil.TestCase):
|
|||
mock_get.assert_not_called()
|
||||
mock_post.assert_not_called()
|
||||
|
||||
def test_inbox_create_obj(self, mock_head, mock_get, mock_post):
|
||||
def test_personal_inbox_create_obj(self, *mocks):
|
||||
self._test_inbox_create_obj('/foo.com/inbox', *mocks)
|
||||
|
||||
def test_shared_inbox_create_obj(self, *mocks):
|
||||
self._test_inbox_create_obj('/inbox', *mocks)
|
||||
|
||||
def _test_inbox_create_obj(self, path, mock_head, mock_get, mock_post):
|
||||
Follower.get_or_create(ACTOR['id'], 'foo.com')
|
||||
Follower.get_or_create('http://other/actor', 'bar.com')
|
||||
Follower.get_or_create(ACTOR['id'], 'baz.com')
|
||||
|
@ -367,7 +373,7 @@ class ActivityPubTest(testutil.TestCase):
|
|||
mock_post.return_value = requests_response()
|
||||
|
||||
with self.client:
|
||||
got = self.client.post('/foo.com/inbox', json=NOTE)
|
||||
got = self.client.post(path, json=NOTE)
|
||||
self.assertEqual(200, got.status_code, got.get_data(as_text=True))
|
||||
expected_as2 = common.redirect_unwrap({
|
||||
**NOTE,
|
||||
|
|
Ładowanie…
Reference in New Issue