mirror of
https://github.com/inspec/inspec
synced 2024-11-11 07:34:15 +00:00
catch empty support clause
This commit is contained in:
parent
af8e4e93ca
commit
d6f48d3534
2 changed files with 12 additions and 2 deletions
|
@ -47,7 +47,12 @@ module Inspec
|
|||
def supports_transport?(backend)
|
||||
# make sure the supports field is always an array
|
||||
supp = params[:supports]
|
||||
supp = [supp] unless supp.is_a?(Array)
|
||||
supp = supp.is_a?(Hash) ? [supp] : Array(supp)
|
||||
|
||||
# with no supports specified, always return true, as there are no
|
||||
# constraints on the supported backend; it is equivalent to putting
|
||||
# all fields into accept-all mode
|
||||
return true if supp.empty?
|
||||
|
||||
found = supp.find do |entry|
|
||||
try_support = self.class.symbolize_keys(entry)
|
||||
|
|
|
@ -21,6 +21,11 @@ describe 'metadata with supported operating systems' do
|
|||
res
|
||||
end
|
||||
|
||||
it 'load a profile with empty supports clause' do
|
||||
m = create_meta(nil)
|
||||
m.supports_transport?(backend).must_equal true
|
||||
end
|
||||
|
||||
it 'loads a profile which supports os ubuntu' do
|
||||
m = create_meta({ 'os' => 'ubuntu' })
|
||||
m.supports_transport?(backend).must_equal true
|
||||
|
|
Loading…
Reference in a new issue