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 test "dashboard recent processes when pipeline_instance index API is disabled" do
10 @controller = ProjectsController.new
12 dd = ArvadosApiClient.new_or_current.discovery.deep_dup
13 dd[:resources][:pipeline_instances][:methods].delete(:index)
14 ArvadosApiClient.any_instance.stubs(:discovery).returns(dd)
16 get :index, {}, session_for(:active)
17 assert_includes @response.body, "zzzzz-xvhdp-cr4runningcntnr" # expect crs
18 assert_not_includes @response.body, "zzzzz-d1hrv-" # expect no pipelines
19 assert_includes @response.body, "Run a process"
22 test "dashboard compute node status not shown when pipeline_instance index API is disabled" do
23 @controller = ProjectsController.new
25 dd = ArvadosApiClient.new_or_current.discovery.deep_dup
26 dd[:resources][:pipeline_instances][:methods].delete(:index)
27 ArvadosApiClient.any_instance.stubs(:discovery).returns(dd)
29 get :index, {}, session_for(:active)
30 assert_not_includes @response.body, "compute-node-summary-pane"
34 [:jobs, JobsController.new],
35 [:job_tasks, JobTasksController.new],
36 [:pipeline_instances, PipelineInstancesController.new],
37 [:pipeline_templates, PipelineTemplatesController.new],
38 ].each do |ctrl_name, ctrl|
39 test "#{ctrl_name} index page when API is disabled" do
42 dd = ArvadosApiClient.new_or_current.discovery.deep_dup
43 dd[:resources][ctrl_name][:methods].delete(:index)
44 ArvadosApiClient.any_instance.stubs(:discovery).returns(dd)
46 get :index, {}, session_for(:active)
56 test "project tabs as user #{user} when pipeline related index APIs are disabled" do
57 @controller = ProjectsController.new
59 Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token']
61 dd = ArvadosApiClient.new_or_current.discovery.deep_dup
62 dd[:resources][:pipeline_templates][:methods].delete(:index)
63 ArvadosApiClient.any_instance.stubs(:discovery).returns(dd)
65 proj_uuid = api_fixture('groups')['anonymously_accessible_project']['uuid']
68 get(:show, {id: proj_uuid}, session_for(user))
70 get(:show, {id: proj_uuid})
74 assert_includes resp, "href=\"#Data_collections\""
75 assert_includes resp, "href=\"#Pipelines_and_processes\""
76 assert_includes resp, "href=\"#Workflows\""
77 assert_not_includes resp, "href=\"#Pipeline_templates\""
78 assert_includes @response.body, "Run a process" if user == :admin