inspec/test/functional/inheritance_test.rb

70 lines
2.3 KiB
Ruby
Raw Normal View History

2016-03-25 00:31:19 +00:00
# encoding: utf-8
# author: Dominik Richter
# author: Christoph Hartmann
require 'functional/helper'
describe 'example inheritance profile' do
include FunctionalHelper
let(:path) { File.join(examples_path, 'inheritance') }
let(:attrs) { File.join(examples_path, 'profile-attribute.yml') }
2016-03-25 00:31:19 +00:00
it 'check succeeds with --profiles-path' do
out = inspec('check ' + path + ' --profiles-path ' + examples_path)
out.stderr.must_equal ''
out.stdout.must_match(/Valid.*true/)
2016-03-25 00:31:19 +00:00
out.exit_status.must_equal 0
end
it 'check succeeds without --profiles-path using inspec.yml' do
out = inspec('check ' + path)
out.stderr.must_equal ''
out.stdout.must_match(/Valid.*true/)
out.exit_status.must_equal 0
end
2016-03-25 00:31:19 +00:00
it 'archive is successful with --profiles-path' do
out = inspec('archive ' + path + ' --output ' + dst.path + ' --profiles-path ' + examples_path)
out.stderr.must_equal ''
out.stdout.must_include 'Generate archive '+dst.path
out.stdout.must_include 'Finished archive generation.'
out.exit_status.must_equal 0
File.exist?(dst.path).must_equal true
end
it 'archive is successful without --profiles-path using inspec.yml' do
out = inspec('archive ' + path + ' --output ' + dst.path)
out.stderr.must_equal ''
out.stdout.must_include 'Generate archive '+dst.path
out.stdout.must_include 'Finished archive generation.'
out.exit_status.must_equal 0
File.exist?(dst.path).must_equal true
end
2016-03-25 00:31:19 +00:00
it 'read the profile json with --profiles-path' do
out = inspec('json ' + path + ' --profiles-path '+examples_path)
out.stderr.must_equal ''
out.exit_status.must_equal 0
s = out.stdout
hm = JSON.load(s)
hm['name'].must_equal 'inheritance'
hm['controls'].length.must_equal 5
2016-03-25 00:31:19 +00:00
end
it 'read the profile json without --profiles-path using inspec.yml' do
out = inspec('json ' + path)
out.stderr.must_equal ''
out.exit_status.must_equal 0
s = out.stdout
hm = JSON.load(s)
hm['name'].must_equal 'inheritance'
hm['controls'].length.must_equal 5
end
it 'can execute a profile inheritance' do
out = inspec('exec ' + path + ' --reporter json --no-create-lockfile --attrs ' + attrs)
out.stderr.must_equal ''
out.exit_status.must_equal 101
JSON.load(out.stdout).must_be_kind_of Hash
end
2016-03-25 00:31:19 +00:00
end