diff --git a/plugins/communicators/winrm/shell.rb b/plugins/communicators/winrm/shell.rb index 2e9c35d5a..ae14e0f23 100644 --- a/plugins/communicators/winrm/shell.rb +++ b/plugins/communicators/winrm/shell.rb @@ -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, diff --git a/test/unit/plugins/communicators/winrm/shell_test.rb b/test/unit/plugins/communicators/winrm/shell_test.rb index 7a402e3cb..22a50072d 100644 --- a/test/unit/plugins/communicators/winrm/shell_test.rb +++ b/test/unit/plugins/communicators/winrm/shell_test.rb @@ -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