From 5d5e13bc0f8d93311910c5f466e5f6a306cb5460 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Wed, 28 Jan 2015 10:47:03 -0500 Subject: [PATCH] Change authorization error tests to match WinRM 1.3 --- plugins/communicators/winrm/shell.rb | 10 +--------- test/unit/plugins/communicators/winrm/shell_test.rb | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) 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