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