5417: in case of a File dataclass with unreadable input and uneditable pipeline,...
authorRadhika Chippada <radhika@curoverse.com>
Thu, 16 Apr 2015 21:18:59 +0000 (17:18 -0400)
committerRadhika Chippada <radhika@curoverse.com>
Thu, 16 Apr 2015 21:18:59 +0000 (17:18 -0400)
apps/workbench/app/helpers/application_helper.rb
apps/workbench/test/integration/anonymous_access_test.rb
services/api/test/fixtures/pipeline_instances.yml

index 923a366d538509f04ce4ce1e5a3f3558321d6913..c42028ff2fa60775c745d8f0f1ecdb1094116dca 100644 (file)
@@ -178,7 +178,7 @@ module ApplicationHelper
   end
 
   def link_to_arvados_object_if_readable(attrvalue, link_text_if_not_readable, opts={})
-    resource_class = resource_class_for_uuid(attrvalue)
+    resource_class = resource_class_for_uuid(attrvalue.split('/')[0]) if attrvalue
     if !resource_class
       return link_to_if_arvados_object attrvalue, opts
     end
@@ -197,14 +197,14 @@ module ApplicationHelper
   # Hence you can improve performance by first preloading objects
   # related to the page context before using this method.
   def object_readable attrvalue, resource_class=nil
+    # if it is a collection filename, check readable for the locator
+    attrvalue = attrvalue.split('/')[0] if attrvalue
+
     resource_class = resource_class_for_uuid(attrvalue) if resource_class.nil?
     return if resource_class.nil?
 
     return_value = nil
     if resource_class.to_s == 'Collection'
-      # if it is a collection filename, check readable for the locator
-      attrvalue = attrvalue.split('/')[0] if attrvalue
-
       if CollectionsHelper.match(attrvalue)
         found = collection_for_pdh(attrvalue)
         return_value = found.first if found.any?
index 9f31ef948603f4577d86f0400a2d3f21cac71015..d1aea7111f4e04bafab2bccf8f57005638da9142 100644 (file)
@@ -248,6 +248,7 @@ class AnonymousAccessTest < ActionDispatch::IntegrationTest
     ['new_pipeline_in_publicly_accessible_project_but_other_objects_elsewhere', false, 'spectator'],
     ['new_pipeline_in_publicly_accessible_project_but_other_objects_elsewhere', true, 'admin'],
     ['new_pipeline_in_publicly_accessible_project_with_dataclass_file_and_other_objects_elsewhere', false, 'spectator'],
+    ['new_pipeline_in_publicly_accessible_project_with_dataclass_file_and_other_objects_elsewhere', true, 'admin'],
   ].each do |fixture, objects_readable, user=nil|
     test "access #{fixture} in public project with objects readable=#{objects_readable} with user #{user}" do
       object = api_fixture('pipeline_instances')[fixture]
@@ -274,14 +275,16 @@ class AnonymousAccessTest < ActionDispatch::IntegrationTest
         end
       else
         assert_no_text 'This pipeline was created from'  # template is not readable
-        assert_no_selector 'a', text: object['components']['foo']['script_parameters']['input']['value']
+        input = object['components']['foo']['script_parameters']['input']['value']
+        input = input.gsub('/', '\\/')
+        assert_no_selector 'a', text: input
         if user
           assert_text "One or more inputs provided are not readable"
-          assert_selector "input[type=text][value=#{object['components']['foo']['script_parameters']['input']['value']}]"
+          assert_selector "input[type=text][value=#{input}]"
           assert_selector 'a.disabled', text: 'Run'
         else
           assert_no_text "One or more inputs provided are not readable"
-          assert_text object['components']['foo']['script_parameters']['input']['value']
+          assert_text input
           assert_no_selector 'a', text: 'Run'
         end
       end
index da41678fdba40493862d7d920f320c736fc05d89..41eb0444496f41911d0dc466c11dac1ff338dba3 100644 (file)
@@ -353,7 +353,7 @@ new_pipeline_in_publicly_accessible_project_with_dataclass_file_and_other_object
         input:
           required: true
           dataclass: File
-          value: zzzzz-4zz18-bv31uwvy3neko21
+          value: zzzzz-4zz18-bv31uwvy3neko21/bar
 
 pipeline_in_running_state:
   name: running_with_job