spec/beaker/host/windows_spec.rb in beaker-4.36.1 vs spec/beaker/host/windows_spec.rb in beaker-4.37.0

- old
+ new

@@ -35,11 +35,11 @@ } let(:host) { make_host( 'name', options.merge(platform) ) } describe '#determine_ssh_server' do it 'does not care about return codes from the execute call' do - expect( host ).to receive( :execute ).with( anything, :accept_all_exit_codes => true ) + expect( host ).to receive( :execute ).with( anything, :accept_all_exit_codes => true ).twice host.determine_ssh_server end it 'uses the default (:openssh) when the execute call fails' do output = bitvise_check_output( :failure ) @@ -49,9 +49,31 @@ it 'reads bitvise status correctly' do output = bitvise_check_output( :success ) allow( host ).to receive( :execute ).and_return( output ) expect( host.determine_ssh_server ).to be === :bitvise + end + + it 'reads Windows OpenSSH status correctly' do + allow(host).to receive(:execute) + .with('cmd.exe /c sc query BvSshServer', anything).and_return(bitvise_check_output(:failure)) + allow(host).to receive(:execute) + .with('cmd.exe /c sc qc sshd', anything).and_return(<<~END) + [SC] QueryServiceConfig SUCCESS + + SERVICE_NAME: sshd + TYPE : 10 WIN32_OWN_PROCESS + START_TYPE : 2 AUTO_START + ERROR_CONTROL : 1 NORMAL + BINARY_PATH_NAME : C:\\Windows\\System32\\OpenSSH\\sshd.exe + LOAD_ORDER_GROUP : + TAG : 0 + DISPLAY_NAME : OpenSSH SSH Server + DEPENDENCIES : + SERVICE_START_NAME : LocalSystem + END + + expect(host.determine_ssh_server).to eq :win32_openssh end it 'returns old value if it has already determined before' do ssh_server_before = host.instance_variable_get( :@ssh_server ) test_value = :test916