From 68d9708ca7fa627bf795d8b980e892c58cea46cb Mon Sep 17 00:00:00 2001 From: Gilles Cornu Date: Mon, 23 Nov 2015 18:51:12 +0100 Subject: [PATCH] kernel/v2: fix a bug in WinRM port forwarding Without this change a custom "winrm-ssl" port forwarding rule could be wrongly shadowed in absence of a "winrm" custom rule. --- plugins/kernel_v2/config/vm.rb | 3 ++- test/unit/plugins/kernel_v2/config/vm_test.rb | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index dfae03edd..b87e32766 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -416,7 +416,8 @@ module VagrantPlugins host_ip: "127.0.0.1", id: "winrm", auto_correct: true - + end + if !@__networks["forwarded_port-winrm-ssl"] network :forwarded_port, guest: 5986, host: 55986, diff --git a/test/unit/plugins/kernel_v2/config/vm_test.rb b/test/unit/plugins/kernel_v2/config/vm_test.rb index 146b3f344..992c27716 100644 --- a/test/unit/plugins/kernel_v2/config/vm_test.rb +++ b/test/unit/plugins/kernel_v2/config/vm_test.rb @@ -204,25 +204,25 @@ describe VagrantPlugins::Kernel_V2::VMConfig do it "allows overriding WinRM" do subject.communicator = :winrm subject.network "forwarded_port", - guest: 22, host: 14100, id: "winrm" + guest: 5985, host: 14100, id: "winrm" subject.finalize! winrm_network = find_network 'winrm' - expect(winrm_network[:guest]).to eq(22) + expect(winrm_network[:guest]).to eq(5985) expect(winrm_network[:host]).to eq(14100) expect(winrm_network[:id]).to eq("winrm") end it "allows overriding WinRM SSL" do - subject.communicator = :winrmssl + subject.communicator = :winrm subject.network "forwarded_port", - guest: 22, host: 14100, id: "winrmssl" + guest: 5986, host: 14100, id: "winrm-ssl" subject.finalize! - winrmssl_network = find_network 'winrmssl' - expect(winrmssl_network[:guest]).to eq(22) + winrmssl_network = find_network 'winrm-ssl' + expect(winrmssl_network[:guest]).to eq(5986) expect(winrmssl_network[:host]).to eq(14100) - expect(winrmssl_network[:id]).to eq("winrmssl") + expect(winrmssl_network[:id]).to eq("winrm-ssl") end it "turns all forwarded port ports to ints" do