1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class LinkTest < ActiveSupport::TestCase
9 reset_api_fixtures :after_each_test, false
11 def uuid_for(fixture_name, object_name)
12 api_fixture(fixture_name)[object_name]["uuid"]
15 test "active user can get permissions for owned project object" do
17 project = Group.find(uuid_for("groups", "aproject"))
18 refute_empty(Link.permissions_for(project),
19 "no permissions found for managed project")
22 test "active user can get permissions for owned project by UUID" do
24 refute_empty(Link.permissions_for(uuid_for("groups", "aproject")),
25 "no permissions found for managed project")
28 test "admin can get permissions for project object" do
30 project = Group.find(uuid_for("groups", "aproject"))
31 refute_empty(Link.permissions_for(project),
32 "no permissions found for managed project")
35 test "admin can get permissions for project by UUID" do
37 refute_empty(Link.permissions_for(uuid_for("groups", "aproject")),
38 "no permissions found for managed project")
41 test "project viewer can't get permissions for readable project object" do
42 use_token :project_viewer
43 project = Group.find(uuid_for("groups", "aproject"))
44 assert_raises(ArvadosApiClient::AccessForbiddenException) do
45 Link.permissions_for(project)
49 test "project viewer can't get permissions for readable project by UUID" do
50 use_token :project_viewer
51 assert_raises(ArvadosApiClient::AccessForbiddenException) do
52 Link.permissions_for(uuid_for("groups", "aproject"))