From b10d35d0da8f630e004966a52ac3ecd01287d36c Mon Sep 17 00:00:00 2001 From: Sean Millichamp Date: Fri, 7 May 2010 08:58:50 -0400 Subject: Fixes #3745 Catch unhandled exception in ssh_authorized_key provider If the target is not specified it is automatically set to the user's home directory. If the user does not exist when the generation of the target path occurs then an ArgumentError exception is raised but not caught. This patch catches the ArgumentError and raises a Puppet::Error instead to more gracefully notify the user and allow any remaining resources to be applied. Signed-off-by: Sean Millichamp --- spec/unit/provider/ssh_authorized_key/parsed.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'spec/unit/provider') diff --git a/spec/unit/provider/ssh_authorized_key/parsed.rb b/spec/unit/provider/ssh_authorized_key/parsed.rb index 0edf2b0ae..f8613e35e 100755 --- a/spec/unit/provider/ssh_authorized_key/parsed.rb +++ b/spec/unit/provider/ssh_authorized_key/parsed.rb @@ -204,5 +204,17 @@ describe provider_class do proc { @provider.flush }.should raise_error end end + + describe "and a invalid user has been specified with no target" do + before :each do + @resource.stubs(:should).with(:user).returns "thisusershouldnotexist" + @resource.stubs(:should).with(:target).returns nil + end + + it "should catch an exception and raise a Puppet error" do + lambda { @provider.flush }.should raise_error(Puppet::Error) + end + end + end end -- cgit