mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
Merge pull request #6059 from inspec/cw/backport-json-inputs-fix
CFINSPEC-250: Fix for inspec json command populating inputs
This commit is contained in:
commit
c715c16121
2 changed files with 18 additions and 1 deletions
|
@ -787,7 +787,12 @@ module Inspec
|
|||
f = load_rule_filepath(prefix, rule)
|
||||
load_rule(rule, f, controls, groups)
|
||||
end
|
||||
params[:inputs] = Inspec::InputRegistry.list_inputs_for_profile(@profile_id)
|
||||
if @profile_id.nil?
|
||||
# identifying inputs using profile name
|
||||
params[:inputs] = Inspec::InputRegistry.list_inputs_for_profile(params[:name])
|
||||
else
|
||||
params[:inputs] = Inspec::InputRegistry.list_inputs_for_profile(@profile_id)
|
||||
end
|
||||
params
|
||||
end
|
||||
|
||||
|
|
|
@ -26,6 +26,10 @@ describe "inspec json" do
|
|||
_(json["generator"]["version"]).must_equal Inspec::VERSION
|
||||
end
|
||||
|
||||
it "has empty array of inputs" do
|
||||
_(json["inputs"]).must_be_empty
|
||||
end
|
||||
|
||||
it "has a name" do
|
||||
_(json["name"]).must_equal "profile"
|
||||
end
|
||||
|
@ -85,6 +89,14 @@ describe "inspec json" do
|
|||
end
|
||||
end
|
||||
|
||||
describe "json profile data with inputs" do
|
||||
let(:json) { JSON.load(inspec("json " + examples_path + "/profile-attribute").stdout) }
|
||||
|
||||
it "has a inputs" do
|
||||
_(json["inputs"]).must_equal [{ "name" => "user", "options" => { "value" => "alice" } }, { "name" => "password", "options" => { "value" => "Input 'password' does not have a value. Skipping test." } }]
|
||||
end
|
||||
end
|
||||
|
||||
describe "filter with --controls" do
|
||||
let(:out) { inspec("json " + example_profile + " --controls tmp-1.0") }
|
||||
|
||||
|
|
Loading…
Reference in a new issue