File tree Expand file tree Collapse file tree 7 files changed +13
-33
lines changed Expand file tree Collapse file tree 7 files changed +13
-33
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,6 @@ def extractexe(command)
102102 def validatecmd ( command )
103103 exe = extractexe ( command )
104104 # if we're not fully qualified, require a path
105- self . fail _ ( "'%{exe}' is not qualified and no path was specified. Please qualify the command or specify a path." ) % { exe : exe } if !absolute_path? ( exe ) and resource [ :path ] . nil?
105+ self . fail _ ( "'%{exe}' is not qualified and no path was specified. Please qualify the command or specify a path." ) % { exe : exe } if !absolute_path? ( exe ) && ( resource [ :path ] . nil? || resource [ :path ] . empty? )
106106 end
107107end
Original file line number Diff line number Diff line change @@ -223,7 +223,9 @@ def sync
223223 newparam ( :path ) do
224224 desc "The search path used for command execution.
225225 Commands must be fully qualified if no path is specified. Paths
226- can be specified as an array or as a '#{ File ::PATH_SEPARATOR } ' separated list."
226+ can be specified as an array or as a '#{ File ::PATH_SEPARATOR } ' separated list. Defaults to the `path` fact."
227+
228+ defaultto Puppet . runtime [ :facter ] . value ( 'path' )
227229
228230 # Support both arrays and colon-separated fields.
229231 def value = ( *values )
Original file line number Diff line number Diff line change @@ -650,10 +650,10 @@ def with_another_agent_running(&block)
650650 . and output ( /No more routes to fileserver/ ) . to_stderr
651651 end
652652
653- it 'preserves the old cached catalog if validation fails with the old one ' do
653+ it 'Updates the old cached catalog if a resource failed to apply ' do
654654 catalog_handler = -> ( req , res ) {
655655 catalog = compile_to_catalog ( <<-MANIFEST , node )
656- exec { 'unqualified_command': }
656+ exec { 'unqualified_command': path => '' }
657657 MANIFEST
658658
659659 res . body = formatter . render ( catalog )
@@ -665,14 +665,14 @@ def with_another_agent_running(&block)
665665 expect {
666666 agent . command_line . args << '--test'
667667 agent . run
668- } . to exit_with ( 1 )
668+ } . to exit_with ( 4 )
669669 . and output ( %r{Retrieving plugin} ) . to_stdout
670- . and output ( %r{Validation of Exec \[ unqualified_command \] failed: 'unqualified_command' is not qualified and no path was specified } ) . to_stderr
670+ . and output ( %r{Error: Could not find command 'unqualified_command' } ) . to_stderr
671671 end
672672
673- # cached catalog should not be updated
673+ # cached catalog should be updated
674674 cached_catalog = "#{ File . join ( Puppet [ :client_datadir ] , 'catalog' , Puppet [ :certname ] ) } .json"
675- expect ( File ) . to_not be_exist ( cached_catalog )
675+ expect ( File ) . to be_exist ( cached_catalog )
676676 end
677677 end
678678
Original file line number Diff line number Diff line change @@ -16,10 +16,7 @@ def make_exe
1616
1717 describe "#validatecmd" do
1818 it "should fail if no path is specified and the command is not fully qualified" do
19- expect { provider . validatecmd ( "foo" ) } . to raise_error (
20- Puppet ::Error ,
21- "'foo' is not qualified and no path was specified. Please qualify the command or specify a path."
22- )
19+ expect ( provider . validatecmd ( 'foo' ) ) . to eq ( nil )
2320 end
2421
2522 it "should pass if a path is given" do
Original file line number Diff line number Diff line change 8888 end
8989
9090 describe "#validatecmd" do
91- it "should fail if the command isn't absolute and there is no path" do
92- expect { provider . validatecmd ( 'foo' ) } . to raise_error ( Puppet :: Error , /'foo' is not qualified and no path was specified/ )
91+ it "should not fail if the command isn't absolute and there is no path" do
92+ expect ( provider . validatecmd ( 'foo' ) ) . to eq ( nil )
9393 end
9494
9595 it "should not fail if the command is absolute and there is no path" do
Original file line number Diff line number Diff line change @@ -73,20 +73,6 @@ def echo_from_ruby_exit_1(message)
7373 end
7474
7575 context "when validating the command" do
76- it "redacts the arguments if the command is relative" do
77- expect {
78- apply_compiled_manifest ( <<-MANIFEST )
79- exec { 'echo':
80- command => Sensitive.new('echo #{ supersecret } ')
81- }
82- MANIFEST
83- } . to raise_error do |err |
84- expect ( err ) . to be_a ( Puppet ::Error )
85- expect ( err . message ) . to match ( /'echo' is not qualified and no path was specified. Please qualify the command or specify a path./ )
86- expect ( err . message ) . to_not match ( /#{ supersecret } / )
87- end
88- end
89-
9076 it "redacts the arguments if the command is a directory" do
9177 dir = tmpdir ( 'exec' )
9278 apply_compiled_manifest ( <<-MANIFEST )
Original file line number Diff line number Diff line change @@ -910,11 +910,6 @@ def instance(path)
910910 let :abs do make_absolute ( '/bin/echo' ) end
911911 let :path do make_absolute ( '/bin' ) end
912912
913- it "should fail with relative command and no path" do
914- expect { type . new ( :command => rel ) } .
915- to raise_error Puppet ::Error , /no path was specified/
916- end
917-
918913 it "should accept a relative command with a path" do
919914 expect ( type . new ( :command => rel , :path => path ) ) . to be
920915 end
You can’t perform that action at this time.
0 commit comments