mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 06:19:15 +02:00
Use scoped tokens to load <audio> urls instead of JWT
This commit is contained in:
parent
13d28f7b0c
commit
ec8dfdb740
17 changed files with 265 additions and 39 deletions
|
@ -42,3 +42,18 @@ def test_registration_serializer_validates_password_properly(data, expected_erro
|
|||
|
||||
with pytest.raises(serializers.serializers.ValidationError, match=expected_error):
|
||||
serializer.is_valid(raise_exception=True)
|
||||
|
||||
|
||||
def test_me_serializer_includes_tokens(factories, mocker):
|
||||
user = factories["users.User"]()
|
||||
generate_scoped_token = mocker.patch(
|
||||
"funkwhale_api.users.authentication.generate_scoped_token"
|
||||
)
|
||||
expected = {"listen": generate_scoped_token.return_value}
|
||||
serializer = serializers.MeSerializer(user)
|
||||
|
||||
assert serializer.data["tokens"] == expected
|
||||
|
||||
generate_scoped_token.assert_called_once_with(
|
||||
user_id=user.pk, user_secret=user.secret_key, scopes=["read:libraries"]
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue