From e4626d088db84a903b7c9fcaf8f17e88a73719d2 Mon Sep 17 00:00:00 2001 From: Bryce Shurts Date: Thu, 1 Dec 2016 13:03:38 -0600 Subject: [PATCH] issue-7983 - Helper now throws WinRMNotReady exception is host ip is reported as an empty string --- plugins/communicators/winrm/helper.rb | 2 +- test/unit/plugins/communicators/winrm/helper_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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