mirror of
https://github.com/inspec/inspec
synced 2024-11-23 21:23:29 +00:00
e77b99235f
This does the following to `inspec detect`: - Modifies it to use the `platform` resource - Changes the output to mention Platform and show the family hierarchy - Changes the JSON output by changing `family` to `families` - Adds better error messaging (no more stacktraces!) - Adds support for APIs such as AWS/Azure - Hides Arch from API platforms (not applicable) Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
59 lines
1.7 KiB
Ruby
59 lines
1.7 KiB
Ruby
require 'functional/helper'
|
|
|
|
describe 'inspec detect' do
|
|
include FunctionalHelper
|
|
|
|
it 'outputs the correct data' do
|
|
res = inspec('detect')
|
|
res.stderr.must_equal ''
|
|
res.exit_status.must_equal 0
|
|
|
|
stdout = res.stdout
|
|
stdout.must_include "\n== Platform Details\n\n"
|
|
stdout.must_include "\nName: \e[0;36m"
|
|
stdout.must_include "\nFamilies: \e[0;36m"
|
|
stdout.must_include "\nArch: \e[0;36m"
|
|
stdout.must_include "\nRelease: \e[0;36m"
|
|
end
|
|
|
|
it 'outputs the correct data when target the target an API' do
|
|
res = inspec('detect -t aws://')
|
|
res.stderr.must_equal ''
|
|
res.exit_status.must_equal 0
|
|
|
|
stdout = res.stdout
|
|
stdout.must_include "\n== Platform Details\n\n"
|
|
stdout.must_include "\nName: \e[0;36m"
|
|
stdout.must_include "\nFamilies: \e[0;36m"
|
|
stdout.must_include "\nRelease: \e[0;36m"
|
|
|
|
stdout.wont_include "\nArch:"
|
|
end
|
|
|
|
describe 'when `--format json` is used`' do
|
|
it 'outputs the correct JSON data' do
|
|
res = inspec('detect --format json')
|
|
res.stderr.must_equal ''
|
|
res.exit_status.must_equal 0
|
|
|
|
json = JSON.parse(res.stdout)
|
|
json.keys.must_include 'name'
|
|
json.keys.must_include 'families'
|
|
json.keys.must_include 'arch'
|
|
json.keys.must_include 'release'
|
|
end
|
|
|
|
it 'outputs the correct JSON data when the target an API' do
|
|
res = inspec('detect -t aws:// --format json')
|
|
res.stderr.must_equal ''
|
|
res.exit_status.must_equal 0
|
|
|
|
json = JSON.parse(res.stdout)
|
|
json.keys.must_include 'name'
|
|
json.keys.must_include 'families'
|
|
json.keys.must_include 'release'
|
|
|
|
json.keys.wont_include 'arch'
|
|
end
|
|
end
|
|
end
|