From b6ca3da4f529dc300f750891022847b071813e57 Mon Sep 17 00:00:00 2001 From: Radhika Chippada Date: Sat, 31 Jan 2015 23:01:31 -0500 Subject: [PATCH] 2659: hide job re-run button when user is inactive and add fixtures and tests for anonymous user to access tabs in publicly accessible project. --- .../app/views/jobs/_show_job_buttons.html.erb | 2 +- .../test/integration/anonymous_access_test.rb | 105 ++++++++++++++++++ services/api/test/fixtures/jobs.yml | 11 ++ .../api/test/fixtures/pipeline_instances.yml | 16 +++ .../api/test/fixtures/pipeline_templates.yml | 20 ++++ 5 files changed, 153 insertions(+), 1 deletion(-) diff --git a/apps/workbench/app/views/jobs/_show_job_buttons.html.erb b/apps/workbench/app/views/jobs/_show_job_buttons.html.erb index f4a32197c4..d12b74435b 100644 --- a/apps/workbench/app/views/jobs/_show_job_buttons.html.erb +++ b/apps/workbench/app/views/jobs/_show_job_buttons.html.erb @@ -1,4 +1,4 @@ -<% if @object.state != "Running" %> +<% if @object.state != "Running" && current_user.is_active %> diff --git a/apps/workbench/test/integration/anonymous_access_test.rb b/apps/workbench/test/integration/anonymous_access_test.rb index f5753a5548..74d4aec970 100644 --- a/apps/workbench/test/integration/anonymous_access_test.rb +++ b/apps/workbench/test/integration/anonymous_access_test.rb @@ -93,4 +93,109 @@ class AnonymousAccessTest < ActionDispatch::IntegrationTest visit "/projects/#{api_fixture('groups')['aproject']['uuid']}/?public_data=true" assert_text 'Not Found' end + + test "selection actions when anonymous user accesses shared project" do + Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token'] + visit "/projects/#{api_fixture('groups')['anonymously_accessible_project']['uuid']}/?public_data=true" + + assert_selector 'a', text: 'Data collections' + assert_selector 'a', text: 'Jobs and pipelines' + assert_selector 'a', text: 'Pipeline templates' + assert_selector 'a', text: 'Advanced' + assert_no_selector 'a', text: 'Subprojects' + assert_no_selector 'a', text: 'Other objects' + assert_no_selector 'button', text: 'Add data' + + click_button 'Selection' + within('.selection-action-container') do + assert_selector 'li', text: 'Compare selected' + assert_no_selector 'li', text: 'Create new collection with selected collections' + assert_no_selector 'li', text: 'Copy selected' + assert_no_selector 'li', text: 'Move selected' + assert_no_selector 'li', text: 'Remove selected' + end + end + + def visit_publicly_accessible_project + Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token'] + visit "/projects/#{api_fixture('groups')['anonymously_accessible_project']['uuid']}/?public_data=true" + end + + test "anonymous user accesses data collections tab in shared project" do + visit_publicly_accessible_project + + assert_selector 'a', text: 'Data collections (1)' + + # click on show collection + within first('tr[data-kind="arvados#collection"]') do + click_link 'Show' + end + + # in collection page + assert_no_selector 'input', text: 'Create sharing link' + assert_no_selector 'a', text: 'Upload' + + within ('#collection_files') do + assert_text 'GNU_General_Public_License,_version_3.pdf' + # how do i assert the view and download links? + end + end + + [ 'job', 'pipelineInstance' ].each do |type| + test "anonymous user accesses jobs and pipelines tab in shared project and clicks on #{type}" do + visit_publicly_accessible_project + + assert_selector 'a', 'Jobs and pipelines (2)' + + click_link 'Jobs and pipelines' + assert_text 'hash job' + + # click on type specified collection + if type == 'job' + verify_job_row + else + verify_pipeline_instance_row + end + end + end + + def verify_job_row + within first('tr[data-kind="arvados#job"]') do + assert_text 'hash job using' + click_link 'Show' + end + + # in job page + assert_no_selector 'button', text: 'Re-run job' + assert_text 'script_version' + end + + def verify_pipeline_instance_row + within first('tr[data-kind="arvados#pipelineInstance"]') do + assert_text 'Pipeline in publicly accessible project' + click_link 'Show' + end + + # in pipeline instance page + assert_no_selector 'a', text: 'Re-run with latest' + assert_no_selector 'a', text: 'Re-run options' + assert_text 'This pipeline is complete' + end + + test "anonymous user accesses pipeline templates tab in shared project" do + visit_publicly_accessible_project + + assert_selector 'a', 'Pipeline templates (1)' + + click_link 'Pipeline templates' + assert_text 'Pipeline template in publicly accessible project' + + within first('tr[data-kind="arvados#pipelineTemplate"]') do + click_link 'Show' + end + + # in template page + assert_text 'script version' + assert_no_selector 'a', text: 'Run this pipeline' + end end diff --git a/services/api/test/fixtures/jobs.yml b/services/api/test/fixtures/jobs.yml index a922a8bd1f..154828f1fd 100644 --- a/services/api/test/fixtures/jobs.yml +++ b/services/api/test/fixtures/jobs.yml @@ -402,6 +402,17 @@ job_with_latest_version: runtime_constraints: {} state: Complete +job_in_publicly_accessible_project: + uuid: zzzzz-8i9sb-n7omg50bvt0m1nf + owner_uuid: zzzzz-j7d0g-zhxawtyetzwc5f0 + repository: foo + script: hash + script_version: 4fe459abe02d9b365932b8f5dc419439ab4e2577 + state: Complete + script_parameters: + input: fa7aeb5140e2848d39b416daeef4ffc5+45 + input2: "stuff2" + # Test Helper trims the rest of the file # Do not add your fixtures below this line as the rest of this file will be trimmed by test_helper diff --git a/services/api/test/fixtures/pipeline_instances.yml b/services/api/test/fixtures/pipeline_instances.yml index 184e722818..69e1f7d5ff 100644 --- a/services/api/test/fixtures/pipeline_instances.yml +++ b/services/api/test/fixtures/pipeline_instances.yml @@ -216,6 +216,22 @@ pipeline_owned_by_active_in_home: dataclass: Collection title: foo instance input +pipeline_in_publicly_accessible_project: + uuid: zzzzz-d1hrv-n68vc490mloy4fi + owner_uuid: zzzzz-j7d0g-zhxawtyetzwc5f0 + name: Pipeline in publicly accessible project + state: Complete + created_at: 2014-09-15 12:00:00 + components: + foo: + script: foo + script_version: master + script_parameters: + input: + required: true + dataclass: Collection + title: foo instance input + # Test Helper trims the rest of the file # Do not add your fixtures below this line as the rest of this file will be trimmed by test_helper diff --git a/services/api/test/fixtures/pipeline_templates.yml b/services/api/test/fixtures/pipeline_templates.yml index 260eab8852..4659da3490 100644 --- a/services/api/test/fixtures/pipeline_templates.yml +++ b/services/api/test/fixtures/pipeline_templates.yml @@ -164,3 +164,23 @@ template_with_dataclass_file: default: [1,1,2,3,5] array_with_value: # important to test repeating values in the array! value: [1,1,2,3,5] + +pipeline_template_in_publicly_accessible_project: + uuid: zzzzz-p5p6p-tmpltpublicproj + owner_uuid: zzzzz-j7d0g-zhxawtyetzwc5f0 + created_at: 2014-04-14 12:35:04 -0400 + updated_at: 2014-04-14 12:35:04 -0400 + modified_at: 2014-04-14 12:35:04 -0400 + modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr + modified_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz + name: Pipeline template in publicly accessible project + components: + foo_component: + script: foo + script_version: master + script_parameters: + input: + required: true + dataclass: Collection + title: "default input" + description: "input collection" -- 2.30.2