2019-06-11 22:24:35 +00:00
|
|
|
require "functional/helper"
|
2018-02-14 20:06:39 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "inspec detect" do
|
2018-02-14 20:06:39 +00:00
|
|
|
include FunctionalHelper
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "outputs the correct data" do
|
|
|
|
res = inspec("detect")
|
2019-07-23 01:44:43 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
res.stderr.must_equal ""
|
2018-02-14 20:06:39 +00:00
|
|
|
|
|
|
|
stdout = res.stdout
|
2018-12-12 16:44:16 +00:00
|
|
|
stdout.must_include "Platform Details"
|
2018-02-20 12:37:23 +00:00
|
|
|
stdout.must_include "\nName: \e[1m\e[36m"
|
|
|
|
stdout.must_include "\nFamilies: \e[1m\e[36m"
|
|
|
|
stdout.must_include "\nArch: \e[1m\e[36m"
|
|
|
|
stdout.must_include "\nRelease: \e[1m\e[36m"
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
assert_exit_code 0, res
|
2018-02-14 20:06:39 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "outputs the correct data when target the target an API" do
|
|
|
|
res = inspec("detect -t aws://")
|
|
|
|
res.stderr.must_equal ""
|
2018-02-14 20:06:39 +00:00
|
|
|
|
|
|
|
stdout = res.stdout
|
2018-12-12 16:44:16 +00:00
|
|
|
stdout.must_include "Platform Details"
|
2018-02-20 12:37:23 +00:00
|
|
|
stdout.must_include "\nName: \e[1m\e[36m"
|
|
|
|
stdout.must_include "\nFamilies: \e[1m\e[36m"
|
|
|
|
stdout.must_include "\nRelease: \e[1m\e[36m"
|
2018-02-14 20:06:39 +00:00
|
|
|
|
|
|
|
stdout.wont_include "\nArch:"
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
assert_exit_code 0, res
|
2018-02-14 20:06:39 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "when `--format json` is used`" do
|
|
|
|
it "outputs the correct JSON data" do
|
|
|
|
res = inspec("detect --format json")
|
|
|
|
res.stderr.must_equal ""
|
2018-02-14 20:06:39 +00:00
|
|
|
|
|
|
|
json = JSON.parse(res.stdout)
|
2019-06-11 22:24:35 +00:00
|
|
|
json.keys.must_include "name"
|
|
|
|
json.keys.must_include "families"
|
|
|
|
json.keys.must_include "arch"
|
|
|
|
json.keys.must_include "release"
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
assert_exit_code 0, res
|
2018-02-14 20:06:39 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "outputs the correct JSON data when the target an API" do
|
|
|
|
res = inspec("detect -t aws:// --format json")
|
|
|
|
res.stderr.must_equal ""
|
2018-02-14 20:06:39 +00:00
|
|
|
|
|
|
|
json = JSON.parse(res.stdout)
|
2019-06-11 22:24:35 +00:00
|
|
|
json.keys.must_include "name"
|
|
|
|
json.keys.must_include "families"
|
|
|
|
json.keys.must_include "release"
|
2018-02-14 20:06:39 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
json.keys.wont_include "arch"
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
assert_exit_code 0, res
|
2018-02-14 20:06:39 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|