mirror of
https://github.com/inspec/inspec
synced 2024-11-27 15:10:44 +00:00
ac106a090e
* Add yml attribute option. * Add type matching. * Add testing profile for global attributes testing all types. * Allow attributes to be called within a control block. * Fix attribut test issues and allow value to be set at runtime. * Allow setting attr value after creation. * Move attributes to global namespace. * Move attributes to a singleton object. * Add unit and updated functional testing. * Rename attributes to attributes_test so the testhelper picks it up. * Add attribute object tests and error types. * Update with feedback changes. * Remove extra line. * Move attribute registry class file. * Add documentation for attributes * Rename rspec_extensions. * Add some failing functional tests. * Update docs and fix typos. Signed-off-by: Jared Quick <jquick@chef.io>
56 lines
1.7 KiB
Ruby
56 lines
1.7 KiB
Ruby
# encoding: utf-8
|
|
|
|
require 'functional/helper'
|
|
|
|
describe 'attributes' do
|
|
include FunctionalHelper
|
|
|
|
[
|
|
'flat',
|
|
'nested',
|
|
].each do |attr_file|
|
|
it "runs OK on #{attr_file} attributes" do
|
|
cmd = 'exec '
|
|
cmd += File.join(profile_path, 'attributes')
|
|
cmd += ' --no-create-lockfile'
|
|
cmd += ' --attrs ' + File.join(profile_path, 'attributes', 'attributes', "#{attr_file}.yaml")
|
|
cmd += ' --controls ' + attr_file
|
|
out = inspec(cmd)
|
|
out.stderr.must_equal ''
|
|
out.exit_status.must_equal 0
|
|
end
|
|
end
|
|
|
|
describe 'run profile with yaml attributes' do
|
|
it "runs using yml attributes" do
|
|
cmd = 'exec '
|
|
cmd += File.join(profile_path, 'global_attributes')
|
|
cmd += ' --no-create-lockfile'
|
|
cmd += ' --attrs ' + File.join(profile_path, 'global_attributes', 'files', "attr.yml")
|
|
out = inspec(cmd)
|
|
out.stderr.must_equal ''
|
|
out.stdout.must_include '20 successful'
|
|
out.exit_status.must_equal 0
|
|
end
|
|
|
|
it "errors with invalid attribute types" do
|
|
cmd = 'exec '
|
|
cmd += File.join(profile_path, 'invalid_attributes')
|
|
cmd += ' --no-create-lockfile'
|
|
out = inspec(cmd)
|
|
out.stderr.must_equal "Type 'Color' is not a valid attribute type.\n"
|
|
out.stdout.must_equal ''
|
|
out.exit_status.must_equal 1
|
|
end
|
|
|
|
it "errors with required attribute not defined" do
|
|
cmd = 'exec '
|
|
cmd += File.join(profile_path, 'required_attributes')
|
|
cmd += ' --no-create-lockfile'
|
|
out = inspec(cmd)
|
|
out.stderr.must_equal "Attribute 'username' is required and does not have a value.\n"
|
|
out.stdout.must_equal ''
|
|
out.exit_status.must_equal 1
|
|
end
|
|
end
|
|
end
|