Adding check for APIPA in winrm helper to fix #8996
This commit is contained in:
parent
2355936291
commit
0eaf691ea0
|
@ -33,10 +33,15 @@ module VagrantPlugins
|
|||
return addr if addr
|
||||
|
||||
ssh_info = machine.ssh_info
|
||||
raise Errors::WinRMNotReady if !ssh_info || ssh_info[:host].to_s.empty?
|
||||
raise Errors::WinRMNotReady if winrm_info_invalid?(ssh_info)
|
||||
return ssh_info[:host]
|
||||
end
|
||||
|
||||
def self.winrm_info_invalid?(ssh_info)
|
||||
invalid = (!ssh_info || ssh_info[:host].to_s.empty? || ssh_info[:host].to_s.match(/^169.254/))
|
||||
return invalid
|
||||
end
|
||||
|
||||
# Returns the port to access WinRM.
|
||||
#
|
||||
# @param [Vagrant::Machine] machine
|
||||
|
|
|
@ -48,6 +48,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 APIPA" do
|
||||
machine.stub(ssh_info: { host: "169.254.123.123" })
|
||||
expect { subject.winrm_address(machine) }.
|
||||
to raise_error(VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".winrm_info" do
|
||||
|
|
Loading…
Reference in New Issue