mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 04:09:25 +02:00
Can now have multiple system actors
We also handle webfinger/activity serialization properly
This commit is contained in:
parent
6c3b7ce154
commit
0c8faf83c5
13 changed files with 493 additions and 152 deletions
39
api/tests/federation/test_authentication.py
Normal file
39
api/tests/federation/test_authentication.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
from funkwhale_api.federation import authentication
|
||||
from funkwhale_api.federation import keys
|
||||
from funkwhale_api.federation import signing
|
||||
|
||||
|
||||
def test_authenticate(nodb_factories, mocker, api_request):
|
||||
private, public = keys.get_key_pair()
|
||||
actor_url = 'https://test.federation/actor'
|
||||
mocker.patch(
|
||||
'funkwhale_api.federation.actors.get_actor_data',
|
||||
return_value={
|
||||
'id': actor_url,
|
||||
'outbox': 'https://test.com',
|
||||
'inbox': 'https://test.com',
|
||||
'publicKey': {
|
||||
'publicKeyPem': public.decode('utf-8'),
|
||||
'owner': actor_url,
|
||||
'id': actor_url + '#main-key',
|
||||
}
|
||||
})
|
||||
signed_request = nodb_factories['federation.SignedRequest'](
|
||||
auth__key=private,
|
||||
auth__key_id=actor_url + '#main-key'
|
||||
)
|
||||
prepared = signed_request.prepare()
|
||||
django_request = api_request.get(
|
||||
'/',
|
||||
headers={
|
||||
'Date': prepared.headers['date'],
|
||||
'Signature': prepared.headers['signature'],
|
||||
}
|
||||
)
|
||||
authenticator = authentication.SignatureAuthentication()
|
||||
user, _ = authenticator.authenticate(django_request)
|
||||
actor = django_request.actor
|
||||
|
||||
assert user.is_anonymous is True
|
||||
assert actor.public_key == public.decode('utf-8')
|
||||
assert actor.url == actor_url
|
Loading…
Add table
Add a link
Reference in a new issue