Change authorization error tests to match WinRM 1.3

This commit is contained in:
Max Lincoln 2015-01-28 10:47:03 -05:00
parent c37c12526a
commit 5d5e13bc0f
2 changed files with 2 additions and 10 deletions

View File

@ -22,6 +22,7 @@ module VagrantPlugins
@@exceptions_to_retry_on = [
HTTPClient::KeepAliveDisconnected,
WinRM::WinRMHTTPTransportError,
WinRM::WinRMAuthorizationError,
Errno::EACCES,
Errno::EADDRINUSE,
Errno::ECONNREFUSED,
@ -124,15 +125,6 @@ module VagrantPlugins
message: exception.message
when WinRM::WinRMHTTPTransportError
case exception.status_code
# If the error is a 401, we can return a more specific error message
when 401
raise Errors::AuthenticationFailed,
user: @config.username,
password: @config.password,
endpoint: endpoint,
message: exception.message
end
raise Errors::ExecutionError,
shell: shell,
command: command,

View File

@ -31,7 +31,7 @@ describe VagrantPlugins::CommunicatorWinRM::WinRMShell do
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))
WinRM::WinRMAuthorizationError.new("Oh no!!", 401))
expect { subject.powershell("dir") }.to raise_error(
VagrantPlugins::CommunicatorWinRM::Errors::AuthenticationFailed)
end