mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-06 04:59:55 +02:00
See #75: initial subsonic implementation that works with http://p.subfireplayer.net
This commit is contained in:
parent
9682299480
commit
bbd273404a
15 changed files with 774 additions and 48 deletions
56
api/tests/subsonic/test_authentication.py
Normal file
56
api/tests/subsonic/test_authentication.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
import binascii
|
||||
|
||||
from funkwhale_api.subsonic import authentication
|
||||
|
||||
|
||||
def test_auth_with_salt(api_request, factories):
|
||||
salt = 'salt'
|
||||
user = factories['users.User']()
|
||||
user.subsonic_api_token = 'password'
|
||||
user.save()
|
||||
token = authentication.get_token(salt, 'password')
|
||||
request = api_request.get('/', {
|
||||
't': token,
|
||||
's': salt,
|
||||
'u': user.username
|
||||
})
|
||||
|
||||
authenticator = authentication.SubsonicAuthentication()
|
||||
u, _ = authenticator.authenticate(request)
|
||||
|
||||
assert user == u
|
||||
|
||||
|
||||
def test_auth_with_password_hex(api_request, factories):
|
||||
salt = 'salt'
|
||||
user = factories['users.User']()
|
||||
user.subsonic_api_token = 'password'
|
||||
user.save()
|
||||
token = authentication.get_token(salt, 'password')
|
||||
request = api_request.get('/', {
|
||||
'u': user.username,
|
||||
'p': 'enc:{}'.format(binascii.hexlify(
|
||||
user.subsonic_api_token.encode('utf-8')).decode('utf-8'))
|
||||
})
|
||||
|
||||
authenticator = authentication.SubsonicAuthentication()
|
||||
u, _ = authenticator.authenticate(request)
|
||||
|
||||
assert user == u
|
||||
|
||||
|
||||
def test_auth_with_password_cleartext(api_request, factories):
|
||||
salt = 'salt'
|
||||
user = factories['users.User']()
|
||||
user.subsonic_api_token = 'password'
|
||||
user.save()
|
||||
token = authentication.get_token(salt, 'password')
|
||||
request = api_request.get('/', {
|
||||
'u': user.username,
|
||||
'p': 'password',
|
||||
})
|
||||
|
||||
authenticator = authentication.SubsonicAuthentication()
|
||||
u, _ = authenticator.authenticate(request)
|
||||
|
||||
assert user == u
|
Loading…
Add table
Add a link
Reference in a new issue