mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
Merge pull request #3784 from inspec/cw/attrs-consolidate-tests
Consolidate attribute-related test-fixture profiles
This commit is contained in:
commit
594ae3c423
22 changed files with 8 additions and 8 deletions
|
@ -4,16 +4,16 @@ require 'functional/helper'
|
||||||
|
|
||||||
describe 'attributes' do
|
describe 'attributes' do
|
||||||
include FunctionalHelper
|
include FunctionalHelper
|
||||||
|
let(:attribute_profiles_path) { File.join(profile_path, 'attributes') }
|
||||||
[
|
[
|
||||||
'flat',
|
'flat',
|
||||||
'nested',
|
'nested',
|
||||||
].each do |attr_file|
|
].each do |attr_file|
|
||||||
it "runs OK on #{attr_file} attributes" do
|
it "runs OK on #{attr_file} attributes" do
|
||||||
cmd = 'exec '
|
cmd = 'exec '
|
||||||
cmd += File.join(profile_path, 'attributes')
|
cmd += File.join(attribute_profiles_path, 'basic')
|
||||||
cmd += ' --no-create-lockfile'
|
cmd += ' --no-create-lockfile'
|
||||||
cmd += ' --attrs ' + File.join(profile_path, 'attributes', 'attributes', "#{attr_file}.yaml")
|
cmd += ' --attrs ' + File.join(attribute_profiles_path, 'basic', 'files', "#{attr_file}.yaml")
|
||||||
cmd += ' --controls ' + attr_file
|
cmd += ' --controls ' + attr_file
|
||||||
out = inspec(cmd)
|
out = inspec(cmd)
|
||||||
out.stderr.must_equal ''
|
out.stderr.must_equal ''
|
||||||
|
@ -24,9 +24,9 @@ describe 'attributes' do
|
||||||
describe 'run profile with yaml attributes' do
|
describe 'run profile with yaml attributes' do
|
||||||
it "runs using yml attributes" do
|
it "runs using yml attributes" do
|
||||||
cmd = 'exec '
|
cmd = 'exec '
|
||||||
cmd += File.join(profile_path, 'global_attributes')
|
cmd += File.join(attribute_profiles_path, 'global')
|
||||||
cmd += ' --no-create-lockfile'
|
cmd += ' --no-create-lockfile'
|
||||||
cmd += ' --attrs ' + File.join(profile_path, 'global_attributes', 'files', "attr.yml")
|
cmd += ' --attrs ' + File.join(attribute_profiles_path, 'global', 'files', "attr.yml")
|
||||||
out = inspec(cmd)
|
out = inspec(cmd)
|
||||||
out.stderr.must_equal ''
|
out.stderr.must_equal ''
|
||||||
out.stdout.must_include '21 successful'
|
out.stdout.must_include '21 successful'
|
||||||
|
@ -35,7 +35,7 @@ describe 'attributes' do
|
||||||
|
|
||||||
it "does not error when attributes are empty" do
|
it "does not error when attributes are empty" do
|
||||||
cmd = 'exec '
|
cmd = 'exec '
|
||||||
cmd += File.join(profile_path, 'profile-with-empty-attributes')
|
cmd += File.join(attribute_profiles_path, 'metadata-empty')
|
||||||
cmd += ' --no-create-lockfile'
|
cmd += ' --no-create-lockfile'
|
||||||
out = inspec(cmd)
|
out = inspec(cmd)
|
||||||
out.stdout.must_include 'WARN: Attributes must be defined as an Array. Skipping current definition.'
|
out.stdout.must_include 'WARN: Attributes must be defined as an Array. Skipping current definition.'
|
||||||
|
@ -44,7 +44,7 @@ describe 'attributes' do
|
||||||
|
|
||||||
it "errors with invalid attribute types" do
|
it "errors with invalid attribute types" do
|
||||||
cmd = 'exec '
|
cmd = 'exec '
|
||||||
cmd += File.join(profile_path, 'invalid_attributes')
|
cmd += File.join(attribute_profiles_path, 'metadata-invalid')
|
||||||
cmd += ' --no-create-lockfile'
|
cmd += ' --no-create-lockfile'
|
||||||
out = inspec(cmd)
|
out = inspec(cmd)
|
||||||
out.stderr.must_equal "Type 'Color' is not a valid attribute type.\n"
|
out.stderr.must_equal "Type 'Color' is not a valid attribute type.\n"
|
||||||
|
@ -54,7 +54,7 @@ describe 'attributes' do
|
||||||
|
|
||||||
it "errors with required attribute not defined" do
|
it "errors with required attribute not defined" do
|
||||||
cmd = 'exec '
|
cmd = 'exec '
|
||||||
cmd += File.join(profile_path, 'required_attributes')
|
cmd += File.join(attribute_profiles_path, 'required')
|
||||||
cmd += ' --no-create-lockfile'
|
cmd += ' --no-create-lockfile'
|
||||||
out = inspec(cmd)
|
out = inspec(cmd)
|
||||||
out.stderr.must_equal "Attribute 'username' is required and does not have a value.\n"
|
out.stderr.must_equal "Attribute 'username' is required and does not have a value.\n"
|
||||||
|
|
Loading…
Reference in a new issue