diff --git a/plugins/communicators/winrm/helper.rb b/plugins/communicators/winrm/helper.rb index 9a0674621..928c29979 100644 --- a/plugins/communicators/winrm/helper.rb +++ b/plugins/communicators/winrm/helper.rb @@ -33,7 +33,7 @@ module VagrantPlugins return addr if addr ssh_info = machine.ssh_info - raise Errors::WinRMNotReady if !ssh_info + raise Errors::WinRMNotReady if !ssh_info || ssh_info[:host].empty? return ssh_info[:host] end diff --git a/test/unit/plugins/communicators/winrm/helper_test.rb b/test/unit/plugins/communicators/winrm/helper_test.rb index a14318019..818a4c75e 100644 --- a/test/unit/plugins/communicators/winrm/helper_test.rb +++ b/test/unit/plugins/communicators/winrm/helper_test.rb @@ -36,6 +36,12 @@ describe VagrantPlugins::CommunicatorWinRM::Helper do expect { subject.winrm_address(machine) }. to raise_error(VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady) end + + it "raise an exception if it detects an empty host ip" do + machine.stub(ssh_info: { host: "" }) + expect { subject.winrm_address(machine) }. + to raise_error(VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady) + end end describe ".winrm_info" do