diff options
author | Stuart Preston <stuart@chef.io> | 2018-07-25 10:04:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-25 10:04:17 +0100 |
commit | c85f28481a7ee6308e4dc3e29ad26f05c38c9432 (patch) | |
tree | 75fdf2f0d2cb7b255a08c30196318425b2403cb6 /spec/unit/win32 | |
parent | 98762283604d272c39c9993dd407648f52db5c96 (diff) | |
download | chef-c85f28481a7ee6308e4dc3e29ad26f05c38c9432.tar.gz |
Assume credentials supplied are still valid if they cannot be validated due to a Windows account restriction (#7416)
Signed-off-by: Stuart Preston <stuart@chef.io>
Diffstat (limited to 'spec/unit/win32')
-rw-r--r-- | spec/unit/win32/error_spec.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/spec/unit/win32/error_spec.rb b/spec/unit/win32/error_spec.rb index e8b6d5af6a..316303ab4f 100644 --- a/spec/unit/win32/error_spec.rb +++ b/spec/unit/win32/error_spec.rb @@ -36,12 +36,12 @@ describe "Chef::Win32::Error", :windows_only do end context "last error received is not user_not_found" do - it "raises Win32APIError exception" do + it "raises Win32APIError exception with code 2202" do expect(Chef::ReservedNames::Win32::Error).to receive(:get_last_error).and_return( Chef::ReservedNames::Win32::API::Error::ERROR_BAD_USERNAME ) expect(Chef::ReservedNames::Win32::Error).to receive_message_chain(:format_message, :strip).and_return("Bad Username") - expect { Chef::ReservedNames::Win32::Error.raise! }.to raise_error Chef::Exceptions::Win32APIError + expect { Chef::ReservedNames::Win32::Error.raise! }.to raise_error(Chef::Exceptions::Win32APIError) end end end @@ -62,6 +62,16 @@ describe "Chef::Win32::Error", :windows_only do expect { Chef::ReservedNames::Win32::Error.raise! nil, Chef::ReservedNames::Win32::API::Error::ERROR_BAD_USERNAME }.to raise_error Chef::Exceptions::Win32APIError end end + + context "last error received is logon failure" do + it "raises a Win32ApiError exception with code 1326" do + expect { Chef::ReservedNames::Win32::Error.raise! nil, Chef::ReservedNames::Win32::API::Error::ERROR_LOGON_FAILURE }.to raise_error { |error| + expect(error).to be_a(Chef::Exceptions::Win32APIError) + # This is not localized but neither is the exception. + expect(error.to_s).to match(/System Error Code: 1326/) + } + end + end end end end |