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 def visit_publicly_accessible_project token=nil, path=nil
14 Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token']
16 path = "/projects/#{api_fixture('groups')['anonymously_accessible_project']['uuid']}" if !path
19 visit page_with_token(token, path)
22 assert_text 'Unrestricted public data' if path.include? 'anonymously_accessible_project'
26 def verify_site_navigation_anonymous_enabled user, is_active
29 assert_text 'Unrestricted public data'
30 assert_selector 'a', text: 'Projects'
32 assert_text 'indicate that you have read and accepted the user agreement'
34 within('.navbar-fixed-top') do
35 assert_selector 'a', text: "#{user['email']}"
36 find('a', text: "#{user['email']}").click
37 within('.dropdown-menu') do
38 assert_selector 'a', text: 'Log out'
42 assert_text 'Unrestricted public data'
43 within('.navbar-fixed-top') do
44 assert_selector 'a', text: 'Log in'
50 [nil, nil, false, false],
51 ['inactive', api_fixture('users')['inactive'], false, false],
52 ['active', api_fixture('users')['active'], true, true],
53 ].each do |token, user, is_active|
54 test "visit public project as user #{token.inspect} when anonymous browsing is enabled" do
55 visit_publicly_accessible_project token
56 verify_site_navigation_anonymous_enabled user, is_active
60 test "visit non-public project as anonymous when anonymous browsing is enabled and expect page not found" do
61 visit_publicly_accessible_project nil,
62 "/projects/#{api_fixture('groups')['aproject']['uuid']}"
63 assert_text 'Not Found'
66 test "anonymous user clicking on topnav sees login page" do
67 visit_publicly_accessible_project
70 click_link 'workbench:test'
71 assert_text 'Please log in'
74 test "selection actions when anonymous user accesses shared project" do
75 visit_publicly_accessible_project
77 assert_selector 'a', text: 'Data collections'
78 assert_selector 'a', text: 'Jobs and pipelines'
79 assert_selector 'a', text: 'Pipeline templates'
80 assert_selector 'a', text: 'Advanced'
81 assert_no_selector 'a', text: 'Subprojects'
82 assert_no_selector 'a', text: 'Other objects'
83 assert_no_selector 'button', text: 'Add data'
85 click_button 'Selection'
86 within('.selection-action-container') do
87 assert_selector 'li', text: 'Compare selected'
88 assert_no_selector 'li', text: 'Create new collection with selected collections'
89 assert_no_selector 'li', text: 'Copy selected'
90 assert_no_selector 'li', text: 'Move selected'
91 assert_no_selector 'li', text: 'Remove selected'
95 test "anonymous user accesses data collections tab in shared project" do
96 visit_publicly_accessible_project
97 assert_text 'GNU General Public License'
99 assert_selector 'a', text: 'Data collections'
101 # click on show collection
102 within first('tr[data-kind="arvados#collection"]') do
107 assert_no_selector 'input', text: 'Create sharing link'
108 assert_no_selector 'a', text: 'Upload'
109 assert_no_selector 'button', 'Selection'
111 within ('#collection_files') do
112 assert_text 'GNU_General_Public_License,_version_3.pdf'
113 # how do i assert the view and download link existence?
122 test "anonymous user accesses jobs and pipelines tab in shared project and clicks on #{type}" do
123 visit_publicly_accessible_project
124 assert_text 'GNU General Public License'
126 click_link 'Jobs and pipelines'
127 assert_text 'Pipeline in publicly accessible project'
129 # click on type specified collection
130 if type.include? 'job'
133 verify_pipeline_instance_row
138 def verify_job_row look_for
139 within first('tr', text: look_for) do
142 assert_text 'script_version'
144 assert_text 'zzzzz-tpzed-xurymjxw79nv3jz' # modified by user
145 assert_no_selector 'a', text: 'zzzzz-tpzed-xurymjxw79nv3jz'
146 #assert_no_selector 'a', text: 'Log' # this is finding 'Log in'
147 assert_no_selector 'a', text: 'Move job'
148 assert_no_selector 'button', text: 'Cancel'
149 assert_no_selector 'button', text: 'Re-run job'
152 def verify_pipeline_instance_row
153 within first('tr[data-kind="arvados#pipelineInstance"]') do
154 assert_text 'Pipeline in publicly accessible project'
158 # in pipeline instance page
159 assert_text 'This pipeline is complete'
160 assert_no_selector 'a', text: 'Re-run with latest'
161 assert_no_selector 'a', text: 'Re-run options'
164 test "anonymous user accesses pipeline templates tab in shared project" do
165 visit_publicly_accessible_project
166 assert_text 'GNU General Public License'
168 assert_selector 'a', text: 'Pipeline templates'
170 click_link 'Pipeline templates'
171 assert_text 'Pipeline template in publicly accessible project'
173 within first('tr[data-kind="arvados#pipelineTemplate"]') do
178 assert_text 'script version'
179 assert_no_selector 'a', text: 'Run this pipeline'