1 require 'integration_helper'
3 class AnonymousAccessTest < ActionDispatch::IntegrationTest
4 # These tests don't do state-changing API calls. Save some time by
5 # skipping the database reset.
6 reset_api_fixtures :after_each_test, false
7 reset_api_fixtures :after_suite, true
11 Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token']
14 PUBLIC_PROJECT = "/projects/#{api_fixture('groups')['anonymously_accessible_project']['uuid']}"
16 def verify_site_navigation_anonymous_enabled user, is_active
19 assert_text 'Unrestricted public data'
20 assert_selector 'a', text: 'Projects'
22 assert_text 'indicate that you have read and accepted the user agreement'
24 within('.navbar-fixed-top') do
25 assert_selector 'a', text: "#{user['email']}"
26 find('a', text: "#{user['email']}").click
27 within('.dropdown-menu') do
28 assert_selector 'a', text: 'Log out'
32 assert_text 'Unrestricted public data'
33 within('.navbar-fixed-top') do
34 assert_selector 'a', text: 'Log in'
40 [nil, nil, false, false],
41 ['inactive', api_fixture('users')['inactive'], false, false],
42 ['active', api_fixture('users')['active'], true, true],
43 ].each do |token, user, is_active|
44 test "visit public project as user #{token.inspect} when anonymous browsing is enabled" do
48 visit page_with_token(token, PUBLIC_PROJECT)
51 verify_site_navigation_anonymous_enabled user, is_active
55 test "selection actions when anonymous user accesses shared project" do
58 assert_selector 'a', text: 'Data collections'
59 assert_selector 'a', text: 'Jobs and pipelines'
60 assert_selector 'a', text: 'Pipeline templates'
61 assert_selector 'a', text: 'Advanced'
62 assert_no_selector 'a', text: 'Subprojects'
63 assert_no_selector 'a', text: 'Other objects'
64 assert_no_selector 'button', text: 'Add data'
66 click_button 'Selection'
67 within('.selection-action-container') do
68 assert_selector 'li', text: 'Compare selected'
69 assert_no_selector 'li', text: 'Create new collection with selected collections'
70 assert_no_selector 'li', text: 'Copy selected'
71 assert_no_selector 'li', text: 'Move selected'
72 assert_no_selector 'li', text: 'Remove selected'
76 test "anonymous user accesses data collections tab in shared project" do
78 assert_text 'GNU General Public License'
80 assert_selector 'a', text: 'Data collections'
82 # click on show collection
83 within first('tr[data-kind="arvados#collection"]') do
88 assert_no_selector 'input', text: 'Create sharing link'
89 assert_no_selector 'a', text: 'Upload'
90 assert_no_selector 'button', 'Selection'
92 within ('#collection_files') do
93 assert_text 'GNU_General_Public_License,_version_3.pdf'
94 # how do i assert the view and download link existence?
103 test "anonymous user accesses jobs and pipelines tab in shared project and clicks on #{type}" do
105 assert_text 'GNU General Public License'
107 click_link 'Jobs and pipelines'
108 assert_text 'Pipeline in publicly accessible project'
110 # click on the specified job
111 if type.include? 'job'
114 verify_pipeline_instance_row
119 def verify_job_row look_for
120 within first('tr', text: look_for) do
123 assert_text 'script_version'
125 assert_text 'zzzzz-tpzed-xurymjxw79nv3jz' # modified by user
126 assert_no_selector 'a', text: 'zzzzz-tpzed-xurymjxw79nv3jz'
127 assert_no_selector 'a', text: 'Move job'
128 assert_no_selector 'button', text: 'Cancel'
129 assert_no_selector 'button', text: 'Re-run job'
132 def verify_pipeline_instance_row
133 within first('tr[data-kind="arvados#pipelineInstance"]') do
134 assert_text 'Pipeline in publicly accessible project'
138 # in pipeline instance page
139 assert_text 'This pipeline is complete'
140 assert_no_selector 'a', text: 'Re-run with latest'
141 assert_no_selector 'a', text: 'Re-run options'
144 test "anonymous user accesses pipeline templates tab in shared project" do
146 assert_text 'GNU General Public License'
148 assert_selector 'a', text: 'Pipeline templates'
150 click_link 'Pipeline templates'
151 assert_text 'Pipeline template in publicly accessible project'
153 within first('tr[data-kind="arvados#pipelineTemplate"]') do
158 assert_text 'script version'
159 assert_no_selector 'a', text: 'Run this pipeline'