Blacked the code

This commit is contained in:
Eliot Berriot 2018-06-09 15:36:16 +02:00
parent b6fc0051fa
commit 62ca3bd736
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
279 changed files with 8861 additions and 9527 deletions

View file

@ -5,34 +5,31 @@ from funkwhale_api.federation import signing
def test_authenticate(factories, mocker, api_request):
private, public = keys.get_key_pair()
actor_url = 'https://test.federation/actor'
actor_url = "https://test.federation/actor"
mocker.patch(
'funkwhale_api.federation.actors.get_actor_data',
"funkwhale_api.federation.actors.get_actor_data",
return_value={
'id': actor_url,
'type': 'Person',
'outbox': 'https://test.com',
'inbox': 'https://test.com',
'preferredUsername': 'test',
'publicKey': {
'publicKeyPem': public.decode('utf-8'),
'owner': actor_url,
'id': actor_url + '#main-key',
}
})
signed_request = factories['federation.SignedRequest'](
auth__key=private,
auth__key_id=actor_url + '#main-key',
auth__headers=[
'date',
]
"id": actor_url,
"type": "Person",
"outbox": "https://test.com",
"inbox": "https://test.com",
"preferredUsername": "test",
"publicKey": {
"publicKeyPem": public.decode("utf-8"),
"owner": actor_url,
"id": actor_url + "#main-key",
},
},
)
signed_request = factories["federation.SignedRequest"](
auth__key=private, auth__key_id=actor_url + "#main-key", auth__headers=["date"]
)
prepared = signed_request.prepare()
django_request = api_request.get(
'/',
"/",
**{
'HTTP_DATE': prepared.headers['date'],
'HTTP_SIGNATURE': prepared.headers['signature'],
"HTTP_DATE": prepared.headers["date"],
"HTTP_SIGNATURE": prepared.headers["signature"],
}
)
authenticator = authentication.SignatureAuthentication()
@ -40,5 +37,5 @@ def test_authenticate(factories, mocker, api_request):
actor = django_request.actor
assert user.is_anonymous is True
assert actor.public_key == public.decode('utf-8')
assert actor.public_key == public.decode("utf-8")
assert actor.url == actor_url