Skip to content
Snippets Groups Projects
Verified Commit c17f7eef authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Ensure follower is approved to access library

parent 899ba311
No related branches found
No related tags found
No related merge requests found
......@@ -16,4 +16,5 @@ class LibraryFollower(BasePermission):
return False
library = actors.SYSTEM_ACTORS['library'].get_actor_instance()
return library.followers.filter(url=actor.url).exists()
return library.received_follows.filter(
approved=True, actor=actor).exists()
......@@ -30,11 +30,26 @@ def test_library_follower_actor_non_follower(
assert check is False
def test_library_follower_actor_follower_not_approved(
factories, api_request, anonymous_user, settings):
settings.FEDERATION_MUSIC_NEEDS_APPROVAL = True
library = actors.SYSTEM_ACTORS['library'].get_actor_instance()
follow = factories['federation.Follow'](target=library, approved=False)
view = APIView.as_view()
permission = permissions.LibraryFollower()
request = api_request.get('/')
setattr(request, 'user', anonymous_user)
setattr(request, 'actor', follow.actor)
check = permission.has_permission(request, view)
assert check is False
def test_library_follower_actor_follower(
factories, api_request, anonymous_user, settings):
settings.FEDERATION_MUSIC_NEEDS_APPROVAL = True
library = actors.SYSTEM_ACTORS['library'].get_actor_instance()
follow = factories['federation.Follow'](target=library)
follow = factories['federation.Follow'](target=library, approved=True)
view = APIView.as_view()
permission = permissions.LibraryFollower()
request = api_request.get('/')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment