From e866ff22632196422824a803e5c28c63364cd301 Mon Sep 17 00:00:00 2001 From: treydock Date: Thu, 1 Jul 2021 15:43:07 -0400 Subject: [PATCH] Fix ssh_to_compute_node? to not error on non-existant cluster (#1274) Fixes #1273 --- apps/dashboard/app/models/batch_connect/session.rb | 2 ++ apps/dashboard/test/models/batch_connect/session_test.rb | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/apps/dashboard/app/models/batch_connect/session.rb b/apps/dashboard/app/models/batch_connect/session.rb index dd21b9bfde..1f85676588 100644 --- a/apps/dashboard/app/models/batch_connect/session.rb +++ b/apps/dashboard/app/models/batch_connect/session.rb @@ -510,6 +510,8 @@ def ssh_to_compute_node? # @return [Boolean] def cluster_ssh_to_compute_node? cluster.batch_connect_ssh_allow? + rescue ClusterNotFound + return nil end # @return [Boolean] diff --git a/apps/dashboard/test/models/batch_connect/session_test.rb b/apps/dashboard/test/models/batch_connect/session_test.rb index 9525f61201..95cdabf676 100644 --- a/apps/dashboard/test/models/batch_connect/session_test.rb +++ b/apps/dashboard/test/models/batch_connect/session_test.rb @@ -409,4 +409,11 @@ def completed? Configuration.stubs(:ood_bc_ssh_to_compute_node).returns(false) assert session.ssh_to_compute_node? end + + test "ssh_to_compute_node? handles non-existant cluster and disabled globally" do + session = BatchConnect::Session.new + session.stubs(:cluster).raises(BatchConnect::Session::ClusterNotFound, "Session specifies nonexistent") + Configuration.stubs(:ood_bc_ssh_to_compute_node).returns(false) + refute session.ssh_to_compute_node? + end end