super
end
end
+
+ # A user can give all other users permissions on folders.
+ def skip_uuid_read_permission_check
+ skipped_attrs = super
+ if link_class == "permission" and
+ (ArvadosModel.resource_class_for_uuid(head_uuid) == Group) and
+ (ArvadosModel.resource_class_for_uuid(tail_uuid) == User)
+ skipped_attrs << "tail_uuid"
+ end
+ skipped_attrs
+ end
end
ob.destroy
end
end
+
+ def new_active_link_valid?(link_attrs)
+ set_user_from_auth :active
+ begin
+ Link.
+ create({link_class: "permission",
+ name: "can_read",
+ head_uuid: groups(:aproject).uuid,
+ }.merge(link_attrs)).
+ valid?
+ rescue ArvadosModel::PermissionDeniedError
+ false
+ end
+ end
+
+ test "link granting permission to nonexistent user is invalid" do
+ refute new_active_link_valid?(tail_uuid:
+ users(:active).uuid.sub(/-\w+$/, "-#{'z' * 15}"))
+ end
+
+ test "link granting non-project permission to unreadable user is invalid" do
+ refute new_active_link_valid?(tail_uuid: users(:admin).uuid,
+ head_uuid: collections(:bar_file).uuid)
+ end
+
+ test "user can't add a Collection to a Project without permission" do
+ refute new_active_link_valid?(link_class: "name",
+ name: "Permission denied test name",
+ tail_uuid: collections(:bar_file).uuid)
+ end
+
+ test "user can't add a User to a Project" do
+ # Users *can* give other users permissions to projects.
+ # This test helps ensure that that exception is specific to permissions.
+ refute new_active_link_valid?(link_class: "name",
+ name: "Permission denied test name",
+ tail_uuid: users(:admin).uuid)
+ end
+
+ test "link granting project permissions to unreadable user is valid" do
+ assert new_active_link_valid?(tail_uuid: users(:admin).uuid)
+ end
end