diff --git a/lib/puppet/functions/foreman/foreman.rb b/lib/puppet/functions/foreman/foreman.rb index 7e1f1da52..ceec690ba 100644 --- a/lib/puppet/functions/foreman/foreman.rb +++ b/lib/puppet/functions/foreman/foreman.rb @@ -71,7 +71,7 @@ def foreman(item, search, per_page = "20", foreman_url = "https://localhost", fo if use_tfmproxy configfile = '/etc/foreman-proxy/settings.yml' configfile = use_tfmproxy if use_tfmproxy.is_a? String - raise Puppet::ParseError, "File #{configfile} not found while use_tfmproxy is enabled" unless File.exists?(configfile) + raise Puppet::ParseError, "File #{configfile} not found while use_tfmproxy is enabled" unless File.exist?(configfile) tfmproxy = YAML.load(File.read(configfile)) uri = URI.parse(tfmproxy[:foreman_url]) http = Net::HTTP.new(uri.host, uri.port) diff --git a/metadata.json b/metadata.json index c0a4b3918..e1d37311a 100644 --- a/metadata.json +++ b/metadata.json @@ -48,7 +48,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 7.0.0 < 8.0.0" + "version_requirement": ">= 7.0.0 < 9.0.0" } ], "operatingsystem_support": [ diff --git a/spec/functions/foreman_foreman_spec.rb b/spec/functions/foreman_foreman_spec.rb index 24dad6863..9e12d32f1 100644 --- a/spec/functions/foreman_foreman_spec.rb +++ b/spec/functions/foreman_foreman_spec.rb @@ -10,6 +10,10 @@ is_expected.to run.with_params().and_raise_error(ArgumentError) end + it 'should throw an error with filter_result=true' do + is_expected.to run.with_params('hosts', 'hostgroup=Grid', '20', 'https://foreman.example.com', 'my_api_foreman_user', 'my_api_foreman_pass', 10, true).and_raise_error(Puppet::ParseError, /Foreman: Invalid filter_result/) + end + it 'should succeed with no timeout specified' do stub_request(:get, "https://foreman.example.com/api/hosts?per_page=20&search=hostgroup=Grid"). with(basic_auth: ['my_api_foreman_user', 'my_api_foreman_pass']).