1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
6 require 'helpers/share_object_helper'
8 class DisabledApiTest < ActionController::TestCase
9 reset_api_fixtures :after_each_test, false
10 reset_api_fixtures :after_suite, false
12 test "dashboard recent processes when pipeline_instance index API is disabled" do
13 @controller = ProjectsController.new
15 dd = ArvadosApiClient.new_or_current.discovery.deep_dup
16 dd[:resources][:pipeline_instances][:methods].delete(:index)
17 ArvadosApiClient.any_instance.stubs(:discovery).returns(dd)
19 get :index, params: {}, session: session_for(:active)
20 assert_includes @response.body, "zzzzz-xvhdp-cr4runningcntnr" # expect crs
21 assert_not_includes @response.body, "zzzzz-d1hrv-" # expect no pipelines
22 assert_includes @response.body, "Run a process"
25 test "dashboard compute node status not shown when pipeline_instance index API is disabled" do
26 @controller = ProjectsController.new
28 dd = ArvadosApiClient.new_or_current.discovery.deep_dup
29 dd[:resources][:pipeline_instances][:methods].delete(:index)
30 ArvadosApiClient.any_instance.stubs(:discovery).returns(dd)
32 get :index, params: {}, session: session_for(:active)
33 assert_not_includes @response.body, "compute-node-summary-pane"
37 [:jobs, JobsController.new],
38 [:job_tasks, JobTasksController.new],
39 [:pipeline_instances, PipelineInstancesController.new],
40 [:pipeline_templates, PipelineTemplatesController.new],
41 ].each do |ctrl_name, ctrl|
42 test "#{ctrl_name} index page when API is disabled" do
45 dd = ArvadosApiClient.new_or_current.discovery.deep_dup
46 dd[:resources][ctrl_name][:methods].delete(:index)
47 ArvadosApiClient.any_instance.stubs(:discovery).returns(dd)
49 get :index, params: {}, session: session_for(:active)
59 test "project tabs as user #{user} when pipeline related index APIs are disabled" do
60 @controller = ProjectsController.new
62 Rails.configuration.Users.AnonymousUserToken = api_fixture('api_client_authorizations')['anonymous']['api_token']
64 dd = ArvadosApiClient.new_or_current.discovery.deep_dup
65 dd[:resources][:pipeline_templates][:methods].delete(:index)
66 ArvadosApiClient.any_instance.stubs(:discovery).returns(dd)
68 proj_uuid = api_fixture('groups')['anonymously_accessible_project']['uuid']
71 get(:show, params: {id: proj_uuid}, session: session_for(user))
73 get(:show, params: {id: proj_uuid})
77 assert_includes resp, "href=\"#Data_collections\""
78 assert_includes resp, "href=\"#Pipelines_and_processes\""
79 assert_includes resp, "href=\"#Workflows\""
80 assert_not_includes resp, "href=\"#Pipeline_templates\""
81 assert_includes @response.body, "Run a process" if user == :admin