kopia lustrzana https://gitlab.com/jaywink/federation
changes to address comments made to merge request #167
rodzic
3236f667d4
commit
97db29ab73
|
@ -17,6 +17,10 @@
|
|||
|
||||
* Signatures are not verified and the corresponding payload is dropped is no public key is found.
|
||||
|
||||
### Internal changes
|
||||
|
||||
* Dropped python 3.6 support.
|
||||
|
||||
## [0.22.0] - 2021-08-15
|
||||
|
||||
### Added
|
||||
|
|
|
@ -29,7 +29,6 @@ def disable_network_calls(monkeypatch):
|
|||
return saved_get(*args, **kwargs)
|
||||
return DEFAULT
|
||||
|
||||
#monkeypatch.setattr("requests.get", Mock(return_value=MockResponse))
|
||||
monkeypatch.setattr("requests.get", Mock(return_value=MockResponse, side_effect=side_effect))
|
||||
|
||||
|
||||
|
|
|
@ -166,8 +166,6 @@ class TestEntitiesConvertToAS2:
|
|||
def test_post_to_as2__with_mentions(self, activitypubpost_mentions):
|
||||
activitypubpost_mentions.pre_send()
|
||||
result = activitypubpost_mentions.to_as2()
|
||||
with open('/tmp/test.out','w') as f:
|
||||
pprint(result, stream=f)
|
||||
assert result == {
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
|
|
|
@ -41,12 +41,13 @@ class TestGetProfileIdFromWebfinger:
|
|||
|
||||
|
||||
class TestRetrieveAndParseDocument:
|
||||
@pytest.mark.skip
|
||||
@patch("federation.utils.activitypub.fetch_document", autospec=True, return_value=(None, None, None))
|
||||
def test_calls_fetch_document(self, mock_fetch):
|
||||
retrieve_and_parse_document("https://example.com/foobar")
|
||||
# auth argument is passed with kwargs
|
||||
auth = mock_fetch.call_args.kwargs.get('auth', None)
|
||||
mock_fetch.assert_called_once_with(
|
||||
"https://example.com/foobar", extra_headers={'accept': 'application/activity+json'},
|
||||
"https://example.com/foobar", extra_headers={'accept': 'application/activity+json'}, auth=auth,
|
||||
)
|
||||
|
||||
@patch("federation.utils.activitypub.fetch_document", autospec=True, return_value=(
|
||||
|
|
|
@ -11,10 +11,10 @@ from federation.utils.text import decode_if_bytes, validate_handle
|
|||
logger = logging.getLogger('federation')
|
||||
|
||||
try:
|
||||
from federation.utils.django import get_admin_user
|
||||
admin_user = get_admin_user()
|
||||
from federation.utils.django import get_federation_user
|
||||
federation_user = get_federation_user()
|
||||
except (ImportError, AttributeError):
|
||||
admin_user = None
|
||||
federation_user = None
|
||||
logger.warning("django is required for requests signing")
|
||||
|
||||
def get_profile_id_from_webfinger(handle: str) -> Optional[str]:
|
||||
|
@ -45,7 +45,7 @@ def retrieve_and_parse_document(fid: str) -> Optional[Any]:
|
|||
"""
|
||||
document, status_code, ex = fetch_document(fid,
|
||||
extra_headers={'accept': 'application/activity+json'},
|
||||
auth=get_http_authentication(admin_user.rsa_private_key,f'{admin_user.id}#main-key') if admin_user else None)
|
||||
auth=get_http_authentication(federation_user.rsa_private_key,f'{federation_user.id}#main-key') if federation_user else None)
|
||||
if document:
|
||||
document = json.loads(decode_if_bytes(document))
|
||||
entities = message_to_objects(document, fid)
|
||||
|
|
|
@ -45,7 +45,7 @@ def get_function_from_config(item):
|
|||
func = getattr(module, func_name)
|
||||
return func
|
||||
|
||||
def get_admin_user():
|
||||
def get_federation_user():
|
||||
config = get_configuration()
|
||||
if not config.get('federation_id'): return None
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue