3 class LinkTest < ActiveSupport::TestCase
7 set_user_from_auth :admin_trustedclient
10 test "cannot delete an object referenced by links" do
12 link = Link.create(tail_uuid: users(:active).uuid,
16 assert_equal users(:admin).uuid, link.owner_uuid
17 assert_raises(ActiveRecord::DeleteRestrictionError,
18 "should not delete #{ob.uuid} with link #{link.uuid}") do
23 def new_active_link_valid?(link_attrs)
24 set_user_from_auth :active
27 create({link_class: "permission",
29 head_uuid: groups(:aproject).uuid,
32 rescue ArvadosModel::PermissionDeniedError
37 test "link granting permission to nonexistent user is invalid" do
38 refute new_active_link_valid?(tail_uuid:
39 users(:active).uuid.sub(/-\w+$/, "-#{'z' * 15}"))
42 test "link granting non-project permission to unreadable user is invalid" do
43 refute new_active_link_valid?(tail_uuid: users(:admin).uuid,
44 head_uuid: collections(:bar_file).uuid)
47 test "user can't add a Collection to a Project without permission" do
48 refute new_active_link_valid?(link_class: "name",
49 name: "Permission denied test name",
50 tail_uuid: collections(:bar_file).uuid)
53 test "user can't add a User to a Project" do
54 # Users *can* give other users permissions to projects.
55 # This test helps ensure that that exception is specific to permissions.
56 refute new_active_link_valid?(link_class: "name",
57 name: "Permission denied test name",
58 tail_uuid: users(:admin).uuid)
61 test "link granting project permissions to unreadable user is invalid" do
62 refute new_active_link_valid?(tail_uuid: users(:admin).uuid)