Merge branch '11305-migrate-docker19-doc'
[arvados.git] / apps / workbench / test / unit / link_test.rb
1 require 'test_helper'
2
3 class LinkTest < ActiveSupport::TestCase
4
5   reset_api_fixtures :after_each_test, false
6
7   def uuid_for(fixture_name, object_name)
8     api_fixture(fixture_name)[object_name]["uuid"]
9   end
10
11   test "active user can get permissions for owned project object" do
12     use_token :active
13     project = Group.find(uuid_for("groups", "aproject"))
14     refute_empty(Link.permissions_for(project),
15                  "no permissions found for managed project")
16   end
17
18   test "active user can get permissions for owned project by UUID" do
19     use_token :active
20     refute_empty(Link.permissions_for(uuid_for("groups", "aproject")),
21                  "no permissions found for managed project")
22   end
23
24   test "admin can get permissions for project object" do
25     use_token :admin
26     project = Group.find(uuid_for("groups", "aproject"))
27     refute_empty(Link.permissions_for(project),
28                  "no permissions found for managed project")
29   end
30
31   test "admin can get permissions for project by UUID" do
32     use_token :admin
33     refute_empty(Link.permissions_for(uuid_for("groups", "aproject")),
34                  "no permissions found for managed project")
35   end
36
37   test "project viewer can't get permissions for readable project object" do
38     use_token :project_viewer
39     project = Group.find(uuid_for("groups", "aproject"))
40     assert_raises(ArvadosApiClient::AccessForbiddenException) do
41       Link.permissions_for(project)
42     end
43   end
44
45   test "project viewer can't get permissions for readable project by UUID" do
46     use_token :project_viewer
47     assert_raises(ArvadosApiClient::AccessForbiddenException) do
48       Link.permissions_for(uuid_for("groups", "aproject"))
49     end
50   end
51 end