mirror of
https://github.com/inspec/inspec
synced 2024-11-10 23:24:18 +00:00
Fix bundle exec calls (#2670)
* Fix bundle exec calls and add test. Signed-off-by: Jared Quick <jquick@chef.io> * Add exit check for supermarket exec. Signed-off-by: Jared Quick <jquick@chef.io>
This commit is contained in:
parent
4641978716
commit
457a33a2b3
3 changed files with 51 additions and 6 deletions
|
@ -78,11 +78,20 @@ module Compliance
|
|||
def exec(*tests)
|
||||
config = Compliance::Configuration.new
|
||||
return if !loggedin(config)
|
||||
o = opts(:exec).dup
|
||||
diagnose(o)
|
||||
configure_logger(o)
|
||||
|
||||
# iterate over tests and add compliance scheme
|
||||
tests = tests.map { |t| 'compliance://' + Compliance::API.sanitize_profile_name(t) }
|
||||
# execute profile from inspec exec implementation
|
||||
diagnose
|
||||
run_tests(tests, opts)
|
||||
|
||||
runner = Inspec::Runner.new(o)
|
||||
tests.each { |target| runner.add_target(target) }
|
||||
|
||||
exit runner.run
|
||||
rescue ArgumentError, RuntimeError, Train::UserError => e
|
||||
$stderr.puts e.message
|
||||
exit 1
|
||||
end
|
||||
|
||||
desc 'download PROFILE', 'downloads a profile from Chef Compliance'
|
||||
|
|
|
@ -29,12 +29,20 @@ module Supermarket
|
|||
desc 'exec PROFILE', 'execute a Supermarket profile'
|
||||
exec_options
|
||||
def exec(*tests)
|
||||
o = opts(:exec).dup
|
||||
diagnose(o)
|
||||
configure_logger(o)
|
||||
|
||||
# iterate over tests and add compliance scheme
|
||||
tests = tests.map { |t| 'supermarket://' + t }
|
||||
|
||||
# execute profile from inspec exec implementation
|
||||
diagnose
|
||||
run_tests(tests, opts)
|
||||
runner = Inspec::Runner.new(o)
|
||||
tests.each { |target| runner.add_target(target) }
|
||||
|
||||
exit runner.run
|
||||
rescue ArgumentError, RuntimeError, Train::UserError => e
|
||||
$stderr.puts e.message
|
||||
exit 1
|
||||
end
|
||||
|
||||
desc 'info PROFILE', 'display Supermarket profile details'
|
||||
|
|
28
test/functional/inspec_supermakert_test.rb
Normal file
28
test/functional/inspec_supermakert_test.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
# encoding: utf-8
|
||||
|
||||
require 'functional/helper'
|
||||
|
||||
describe 'inspec supermakert' do
|
||||
include FunctionalHelper
|
||||
|
||||
it 'help' do
|
||||
out = inspec('supermarket help')
|
||||
out.exit_status.must_equal 0
|
||||
out.stdout.must_include 'inspec supermarket exec PROFILE'
|
||||
end
|
||||
|
||||
it 'info' do
|
||||
out = inspec('supermarket info dev-sec/ssh-baseline')
|
||||
out.exit_status.must_equal 0
|
||||
out.stderr.must_equal ''
|
||||
out.stdout.must_include "name: \e[0m ssh-baseline"
|
||||
end
|
||||
|
||||
it 'supermarket exec' do
|
||||
out = inspec('supermarket exec dev-sec/ssh-baseline')
|
||||
out.exit_status.wont_equal 1
|
||||
out.stderr.must_equal ''
|
||||
out.stdout.must_include 'Profile Summary'
|
||||
out.stdout.must_include 'Test Summary'
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue