14287: Fix PDHs and manifests in test fixtures.
[arvados.git] / apps / workbench / test / unit / link_test.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'test_helper'
6
7 class LinkTest < ActiveSupport::TestCase
8
9   reset_api_fixtures :after_each_test, false
10
11   def uuid_for(fixture_name, object_name)
12     api_fixture(fixture_name)[object_name]["uuid"]
13   end
14
15   test "active user can get permissions for owned project object" do
16     use_token :active
17     project = Group.find(uuid_for("groups", "aproject"))
18     refute_empty(Link.permissions_for(project),
19                  "no permissions found for managed project")
20   end
21
22   test "active user can get permissions for owned project by UUID" do
23     use_token :active
24     refute_empty(Link.permissions_for(uuid_for("groups", "aproject")),
25                  "no permissions found for managed project")
26   end
27
28   test "admin can get permissions for project object" do
29     use_token :admin
30     project = Group.find(uuid_for("groups", "aproject"))
31     refute_empty(Link.permissions_for(project),
32                  "no permissions found for managed project")
33   end
34
35   test "admin can get permissions for project by UUID" do
36     use_token :admin
37     refute_empty(Link.permissions_for(uuid_for("groups", "aproject")),
38                  "no permissions found for managed project")
39   end
40
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)
46     end
47   end
48
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"))
53     end
54   end
55 end