@@ -28,3 +28,28 @@ def test_create_remote_role_definition(admin_api_client, foo_type, foo_permissio
2828 assert response .status_code == 201 , response .data
2929 assert response .data ['name' ] == 'foo-foo-foo-custom'
3030 assert response .data ['permissions' ] == ['foo.foo_foo' ]
31+
32+
33+ # TODO: check that assignment endpoint works
34+
35+ # @pytest.mark.django_db
36+ # def test_give_remote_permission(rando, foo_type, foo_permission, foo_rd):
37+ # assert foo_type.service == 'foo' # a place, a domain, a server, known as foo
38+ # assert foo_type.api_slug == 'foo.foo' # there lives a foo in foo
39+
40+ # assert foo_permission.api_slug == 'foo.foo_foo' # expression of the ability that one may foo a foo
41+
42+ # a_foo = RemoteObject(content_type=foo_type, object_id=42)
43+ # assignment = foo_rd.give_permission(rando, a_foo)
44+
45+ # assignment = RoleUserAssignment.objects.get(pk=assignment.pk)
46+ # assert isinstance(assignment.content_object, RemoteObject)
47+
48+ # # We can do evaluation querysets, but these can not return objects, just id values
49+ # assert set(foo_type.model_class().access_ids_qs(actor=rando, codename='foo')) == {(int(assignment.object_id),)}
50+
51+ # # Test that user-attached methods also work
52+ # assert rando.has_obj_perm(a_foo, 'foo')
53+ # with pytest.raises(RuntimeError) as exc:
54+ # assert not rando.has_obj_perm(a_foo, 'bar') # not a valid permission
55+ # assert 'The permission bar_foo is not valid for model foo' in str(exc)
0 commit comments