diff --git a/.kitchen.yml b/.kitchen.yml index 042724d1..087f07bb 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -121,7 +121,7 @@ suites: attributes: audit: collector: json-file - inspec_version: 1.20.0 + inspec_version: 1.29.0 fail_if_not_present: true - name: skip-inspec-gem-install run_list: @@ -130,5 +130,5 @@ suites: attributes: audit: collector: json-file - inspec_version: 1.19.1 + inspec_version: 1.25.1 fail_if_not_present: true diff --git a/files/default/handler/audit_report.rb b/files/default/handler/audit_report.rb index 7a67f653..a1179f2e 100644 --- a/files/default/handler/audit_report.rb +++ b/files/default/handler/audit_report.rb @@ -5,6 +5,8 @@ class Chef class Handler # Creates a compliance audit report class AuditReport < ::Chef::Handler + MIN_INSPEC_VERSION = '1.25.1'.freeze + def report # get reporter(s) from attributes as an array reporters = get_reporters(node['audit']) @@ -125,10 +127,8 @@ def get_opts(format, quiet) # run profiles and return report def call(opts, profiles) Chef::Log.info "Using InSpec #{::Inspec::VERSION}" - - if Gem::Version.new(Inspec::VERSION) < Gem::Version.new('1.24.0') - Chef::Log.error "This audit cookbook version requires InSpec 1.24.0 or newer, aborting compliance scan..." - return {} + if Gem::Version.new(::Inspec::VERSION) < Gem::Version.new(MIN_INSPEC_VERSION) + raise "This audit cookbook version requires InSpec #{MIN_INSPEC_VERSION} or newer, aborting compliance scan..." end Chef::Log.debug "Options are set to: #{opts}" diff --git a/test/integration/gem-install-version/default.rb b/test/integration/gem-install-version/default.rb index 8f56ed43..25e46745 100644 --- a/test/integration/gem-install-version/default.rb +++ b/test/integration/gem-install-version/default.rb @@ -1,5 +1,5 @@ # verify that a specific inspec version is installed describe gem('inspec', :chef) do it { should be_installed } - its('version') { should cmp '1.20.0'} + its('version') { should cmp '1.29.0'} end diff --git a/test/integration/skip-inspec-gem-install/default.rb b/test/integration/skip-inspec-gem-install/default.rb index 02d74eb3..567aeff6 100644 --- a/test/integration/skip-inspec-gem-install/default.rb +++ b/test/integration/skip-inspec-gem-install/default.rb @@ -1,5 +1,5 @@ # verify that a specific inspec version is installed describe gem('inspec', :chef) do it { should be_installed } - its('version') { should cmp '1.19.1'} + its('version') { should cmp '1.25.1'} end