Skip to content

Commit bfe1645

Browse files
committed
Support compliance_engine::enforcement as a String
This fixes backwards-compatibility with a compliance_markup edge case. Also fix running `lookup()` tests directly.
1 parent c2d7db8 commit bfe1645

4 files changed

Lines changed: 9 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616

1717
/Gemfile.lock
1818
/vendor/
19+
/spec/fixtures/modules/

Rakefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ RSpec::Core::RakeTask.new('spec:standalone') do |t|
1111
t.pattern = 'spec/{classes,functions}/**/*_spec.rb'
1212
end
1313

14+
desc 'Prepare fixtures for testing'
15+
task spec_prep: :'fixtures:prep'
16+
17+
desc 'Clean up fixtures after testing'
18+
task spec_clean: :'fixtures:clean'
19+
1420
desc 'Run spec tests and clean the fixtures directory if successful'
1521
task spec: :'fixtures:prep' do |_t, args|
1622
Rake::Task['spec:standalone'].invoke(*args.extras)

lib/puppet/functions/compliance_engine/enforcement.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ def enforcement(key, options, context)
6060
end
6161

6262
def profiles
63-
profile_list = call_function('lookup', 'compliance_engine::enforcement', { 'default_value' => [] })
63+
profile_list = Array(call_function('lookup', 'compliance_engine::enforcement', { 'default_value' => [] }))
6464

6565
# For backwards compatibility with compliance_markup.
66-
profile_list += call_function('lookup', 'compliance_markup::enforcement', { 'default_value' => [] }) if @compat
66+
profile_list += Array(call_function('lookup', 'compliance_markup::enforcement', { 'default_value' => [] })) if @compat
6767

6868
profile_list.uniq
6969
end

spec/functions/lookup/10_enforce_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ def write_hieradata(hieradata_dir, hieradata_file, policy_order)
9898
let(:policy_order) { 'disa_stig' }
9999

100100
it 'returns /bin/disa' do
101-
skip('String value for compliance_engine::enforcement not supported, must be Array')
102101
result = lookup.execute('useradd::shells')
103102
expect(result).to be_instance_of(Array)
104103
expect(result).to include('/bin/disa')

0 commit comments

Comments
 (0)