@@ -11,8 +11,10 @@ class ForemanRemoteExecutionHostExtensionsTest < ActiveSupport::TestCase
1111 let ( :sshkey ) { 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQ foo@example.com' }
1212
1313 before do
14- SmartProxy . any_instance . stubs ( :pubkey ) . returns ( sshkey )
15- SmartProxy . any_instance . stubs ( :ca_pubkey ) . returns ( nil )
14+ host . subnet . remote_execution_proxies . each do |proxy |
15+ proxy . update_column ( :pubkey , sshkey )
16+ proxy . update_column ( :ca_pubkey , nil )
17+ end
1618 Setting [ :remote_execution_ssh_user ] = 'root'
1719 Setting [ :remote_execution_effective_user_method ] = 'sudo'
1820 end
@@ -60,6 +62,17 @@ class ForemanRemoteExecutionHostExtensionsTest < ActiveSupport::TestCase
6062 User . current = nil
6163 assert_includes host . remote_execution_ssh_keys , sshkey
6264 end
65+
66+ it 'triggers no calls to the proxy' do
67+ host . subnet . remote_execution_proxies . each do |proxy |
68+ proxy . update_column ( :pubkey , nil )
69+ end
70+
71+ SmartProxy . any_instance . expects ( :update_pubkey ) . never
72+ SmartProxy . any_instance . expects ( :update_ca_pubkey ) . never
73+
74+ host . host_param ( 'remote_execution_ssh_keys' )
75+ end
6376 end
6477
6578 describe 'has ssh CA key configured' do
@@ -68,8 +81,10 @@ class ForemanRemoteExecutionHostExtensionsTest < ActiveSupport::TestCase
6881 let ( :ca_sshkey ) { 'ssh-rsa AAAAB3NzaC1yc2EAAAABJE bar@example.com' }
6982
7083 before do
71- SmartProxy . any_instance . stubs ( :pubkey ) . returns ( sshkey )
72- SmartProxy . any_instance . stubs ( :ca_pubkey ) . returns ( ca_sshkey )
84+ host . subnet . remote_execution_proxies . each do |proxy |
85+ proxy . update_column ( :pubkey , sshkey )
86+ proxy . update_column ( :ca_pubkey , ca_sshkey )
87+ end
7388 Setting [ :remote_execution_ssh_user ] = 'root'
7489 Setting [ :remote_execution_effective_user_method ] = 'sudo'
7590 end
@@ -102,6 +117,17 @@ class ForemanRemoteExecutionHostExtensionsTest < ActiveSupport::TestCase
102117 assert_includes host . host_param ( 'remote_execution_ssh_ca_keys' ) , key
103118 assert_includes host . host_param ( 'remote_execution_ssh_ca_keys' ) , ca_sshkey
104119 end
120+
121+ it 'triggers no calls to the proxy' do
122+ host . subnet . remote_execution_proxies . each do |proxy |
123+ proxy . update_column ( :ca_pubkey , nil )
124+ end
125+
126+ SmartProxy . any_instance . expects ( :update_pubkey ) . never
127+ SmartProxy . any_instance . expects ( :update_ca_pubkey ) . never
128+
129+ host . host_param ( 'remote_execution_ssh_ca_keys' )
130+ end
105131 end
106132
107133 context 'host has multiple nics' do
0 commit comments