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
13 PUBLIC_PROJECT = "/projects/#{api_fixture('groups')['anonymously_accessible_project']['uuid']}"
15 def verify_site_navigation_anonymous_enabled user, is_active
18 assert_text 'Unrestricted public data'
19 assert_selector 'a', text: 'Projects'
21 assert_text 'indicate that you have read and accepted the user agreement'
23 within('.navbar-fixed-top') do
24 assert_selector 'a', text: "#{user['email']}"
25 find('a', text: "#{user['email']}").click
26 within('.dropdown-menu') do
27 assert_selector 'a', text: 'Log out'
31 assert_text 'Unrestricted public data'
32 within('.navbar-fixed-top') do
33 assert_selector 'a', text: 'Log in'
39 [nil, nil, false, false],
40 ['inactive', api_fixture('users')['inactive'], false, false],
41 ['active', api_fixture('users')['active'], true, true],
42 ].each do |token, user, is_active|
43 test "visit public project as user #{token.inspect} when anonymous browsing is enabled" do
47 visit page_with_token(token, PUBLIC_PROJECT)
50 verify_site_navigation_anonymous_enabled user, is_active
54 test "visit non-public project as anonymous when anonymous browsing is enabled and expect page not found" do
55 visit "/projects/#{api_fixture('groups')['aproject']['uuid']}"
56 assert_text 'Not Found'
59 test "anonymous user clicking on topnav sees login page" do
63 click_link 'workbench:test'
64 assert_text 'Please log in'
67 test "selection actions when anonymous user accesses shared project" do
70 assert_selector 'a', text: 'Data collections'
71 assert_selector 'a', text: 'Jobs and pipelines'
72 assert_selector 'a', text: 'Pipeline templates'
73 assert_selector 'a', text: 'Advanced'
74 assert_no_selector 'a', text: 'Subprojects'
75 assert_no_selector 'a', text: 'Other objects'
76 assert_no_selector 'button', text: 'Add data'
78 click_button 'Selection'
79 within('.selection-action-container') do
80 assert_selector 'li', text: 'Compare selected'
81 assert_no_selector 'li', text: 'Create new collection with selected collections'
82 assert_no_selector 'li', text: 'Copy selected'
83 assert_no_selector 'li', text: 'Move selected'
84 assert_no_selector 'li', text: 'Remove selected'
88 test "anonymous user accesses data collections tab in shared project" do
90 assert_text 'GNU General Public License'
92 assert_selector 'a', text: 'Data collections'
94 # click on show collection
95 within first('tr[data-kind="arvados#collection"]') do
100 assert_no_selector 'input', text: 'Create sharing link'
101 assert_no_selector 'a', text: 'Upload'
102 assert_no_selector 'button', 'Selection'
104 within ('#collection_files') do
105 assert_text 'GNU_General_Public_License,_version_3.pdf'
106 # how do i assert the view and download link existence?
115 test "anonymous user accesses jobs and pipelines tab in shared project and clicks on #{type}" do
117 assert_text 'GNU General Public License'
119 click_link 'Jobs and pipelines'
120 assert_text 'Pipeline in publicly accessible project'
122 # click on the specified job
123 if type.include? 'job'
126 verify_pipeline_instance_row
131 def verify_job_row look_for
132 within first('tr', text: look_for) do
135 assert_text 'script_version'
137 assert_text 'zzzzz-tpzed-xurymjxw79nv3jz' # modified by user
138 assert_no_selector 'a', text: 'zzzzz-tpzed-xurymjxw79nv3jz'
139 assert_no_selector 'a', text: 'Move job'
140 assert_no_selector 'button', text: 'Cancel'
141 assert_no_selector 'button', text: 'Re-run job'
144 def verify_pipeline_instance_row
145 within first('tr[data-kind="arvados#pipelineInstance"]') do
146 assert_text 'Pipeline in publicly accessible project'
150 # in pipeline instance page
151 assert_text 'This pipeline is complete'
152 assert_no_selector 'a', text: 'Re-run with latest'
153 assert_no_selector 'a', text: 'Re-run options'
156 test "anonymous user accesses pipeline templates tab in shared project" do
158 assert_text 'GNU General Public License'
160 assert_selector 'a', text: 'Pipeline templates'
162 click_link 'Pipeline templates'
163 assert_text 'Pipeline template in publicly accessible project'
165 within first('tr[data-kind="arvados#pipelineTemplate"]') do
170 assert_text 'script version'
171 assert_no_selector 'a', text: 'Run this pipeline'