2019-06-11 22:24:35 +00:00
|
|
|
require "functional/helper"
|
2018-09-13 19:36:17 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "inspec schema" do
|
2018-09-13 19:36:17 +00:00
|
|
|
include FunctionalHelper
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "extracting the platforms schema export" do
|
|
|
|
it "can execute a platforms schema command" do
|
|
|
|
out = inspec("schema platforms")
|
2019-07-23 01:44:43 +00:00
|
|
|
|
2018-09-13 19:36:17 +00:00
|
|
|
data = JSON.parse(out.stdout)
|
2019-09-30 22:31:55 +00:00
|
|
|
_(data.class).must_equal Array
|
|
|
|
_(data.size).must_be(:>, 1)
|
|
|
|
_(data[0]["name"]).must_equal "aix"
|
2019-06-11 22:24:35 +00:00
|
|
|
families = %w{aix unix os}
|
2019-09-30 22:31:55 +00:00
|
|
|
_(data[0]["families"]).must_equal families
|
2019-07-23 01:44:43 +00:00
|
|
|
|
2019-09-30 22:31:55 +00:00
|
|
|
_(out.stderr).must_equal ""
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
assert_exit_code 0, out
|
2018-09-13 19:36:17 +00:00
|
|
|
end
|
|
|
|
end
|
2022-03-04 14:15:52 +00:00
|
|
|
|
|
|
|
describe "validate schema of exec-json" do
|
|
|
|
it "contains resource_id key" do
|
|
|
|
out = inspec("schema exec-json")
|
|
|
|
json_output = JSON.parse(out.stdout)
|
|
|
|
_(json_output["definitions"]["Control_Result"]["properties"]["resource_id"]).wont_be_nil
|
2022-07-01 08:47:35 +00:00
|
|
|
# status value to be nil when not using enhanced outcomes flag
|
2022-07-12 11:40:55 +00:00
|
|
|
assert_nil(json_output["definitions"]["Exec_JSON_Control"]["properties"]["status"])
|
2022-03-04 14:15:52 +00:00
|
|
|
end
|
|
|
|
end
|
2022-06-29 09:54:27 +00:00
|
|
|
|
|
|
|
describe "validate schema of exec-json with enhanced_outcomes option" do
|
|
|
|
it "contains resource_id key" do
|
|
|
|
out = inspec("schema exec-json --enhanced-outcomes")
|
|
|
|
json_output = JSON.parse(out.stdout)
|
|
|
|
_(json_output["definitions"]["Exec_JSON_Control"]["properties"]["status"]).wont_be_nil
|
|
|
|
end
|
|
|
|
end
|
2018-09-13 19:36:17 +00:00
|
|
|
end
|