Fix tests - all pass but auth retry test is extremely slow
This commit is contained in:
parent
24de8a1fb7
commit
e7e50d39d9
|
@ -105,7 +105,7 @@ module VagrantPlugins
|
|||
endpoint: endpoint,
|
||||
message: exception.message
|
||||
when WinRM::WinRMHTTPTransportError
|
||||
case exception.response_code
|
||||
case exception.status_code
|
||||
# If the error is a 401, we can return a more specific error message
|
||||
when 401
|
||||
raise Errors::AuthenticationFailed,
|
||||
|
@ -137,7 +137,10 @@ module VagrantPlugins
|
|||
# This is raised if we can't work out how to route traffic.
|
||||
raise Errors::NoRoute
|
||||
else
|
||||
raise
|
||||
raise Errors::ExecutionError,
|
||||
shell: shell,
|
||||
command: command,
|
||||
message: exception.message
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -28,11 +28,16 @@ describe VagrantPlugins::CommunicatorWinRM::Communicator do
|
|||
expect(subject.ready?).to be_true
|
||||
end
|
||||
|
||||
it "returns false if hostname command fails to execute without error" do
|
||||
expect(shell).to receive(:powershell).with("hostname").and_raise(Vagrant::Errors::VagrantError)
|
||||
it "returns false if hostname command fails with a transient error" do
|
||||
expect(shell).to receive(:powershell).with("hostname").and_raise(VagrantPlugins::CommunicatorWinRM::Errors::TransientError)
|
||||
expect(subject.ready?).to be_false
|
||||
end
|
||||
|
||||
it "raises an error if hostname command fails with an unknown error" do
|
||||
expect(shell).to receive(:powershell).with("hostname").and_raise(Vagrant::Errors::VagrantError)
|
||||
expect { subject.ready? }.to raise_error(Vagrant::Errors::VagrantError)
|
||||
end
|
||||
|
||||
it "raises timeout error when hostname command takes longer then winrm timeout" do
|
||||
expect(shell).to receive(:powershell).with("hostname") do
|
||||
sleep 2 # winrm.timeout = 1
|
||||
|
|
|
@ -28,11 +28,12 @@ describe VagrantPlugins::CommunicatorWinRM::WinRMShell do
|
|||
expect(subject.powershell("dir")[:exitcode]).to eq(0)
|
||||
end
|
||||
|
||||
it "should raise auth error when exception message contains 401" do
|
||||
expect(session).to receive(:powershell).with(/^dir.+/).and_raise(
|
||||
StandardError.new("Oh no! a 401 SOAP error!"))
|
||||
it "should raise auth error when WinRM exception has a response code of 401" do
|
||||
# The default settings might an account lockout - 20 auth failures!
|
||||
expect(session).to receive(:powershell).with(/^dir.+/).exactly(20).times.and_raise(
|
||||
WinRM::WinRMHTTPTransportError.new("Oh no!!", 401))
|
||||
expect { subject.powershell("dir") }.to raise_error(
|
||||
VagrantPlugins::CommunicatorWinRM::Errors::AuthError)
|
||||
VagrantPlugins::CommunicatorWinRM::Errors::AuthenticationFailed)
|
||||
end
|
||||
|
||||
it "should raise an execution error when an exception occurs" do
|
||||
|
|
|
@ -167,14 +167,15 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
|
|||
subject.communicator = "winrm"
|
||||
subject.finalize!
|
||||
n = subject.networks
|
||||
expect(n.length).to eq(1)
|
||||
expect(n.length).to eq(2)
|
||||
|
||||
# WinRM HTTP
|
||||
expect(n[0][0]).to eq(:forwarded_port)
|
||||
expect(n[0][1][:guest]).to eq(5985)
|
||||
expect(n[0][1][:host]).to eq(55985)
|
||||
expect(n[0][1][:host_ip]).to eq("127.0.0.1")
|
||||
expect(n[0][1][:id]).to eq("winrm")
|
||||
network = find_network("winrm")
|
||||
# expect(n[0][0]).to eq(:forwarded_port)
|
||||
expect(network[:guest]).to eq(5985)
|
||||
expect(network[:host]).to eq(55985)
|
||||
expect(network[:host_ip]).to eq("127.0.0.1")
|
||||
expect(network[:id]).to eq("winrm")
|
||||
end
|
||||
|
||||
it "allows overriding SSH" do
|
||||
|
|
Loading…
Reference in New Issue