mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
Merge pull request #5918 from inspec/vasundhara/deprecates-target-id-option
CFINSPEC-137: Deprecate --target-id option
This commit is contained in:
commit
0fb344c1d5
20 changed files with 76 additions and 74 deletions
|
@ -380,7 +380,7 @@ This subcommand has the following additional options:
|
|||
* ``-t``, ``--target=TARGET``
|
||||
Simple targeting option using URIs, e.g. ssh://user:pass@host:port.
|
||||
* ``--target-id=TARGET_ID``
|
||||
Provide a ID which will be included on reports.
|
||||
Provide a ID which will be included on reports - deprecated.
|
||||
* ``--tags=one two three``
|
||||
A list of tags or a list of regular expressions that match tags. `exec` will run controls referenced by the listed or matching tags.
|
||||
* ``--user=USER``
|
||||
|
|
|
@ -122,6 +122,10 @@
|
|||
"action": "warn",
|
||||
"prefix": "The --hook option is being replaced by the --activator option.",
|
||||
"suffix": "This options will be removed in InSpec 4.0."
|
||||
},
|
||||
"cli_option_target_id":{
|
||||
"action": "warn",
|
||||
"prefix": "The --target-id option is deprecated in InSpec 5. Its value will be ignored."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ module Inspec
|
|||
option :insecure, type: :boolean, default: false,
|
||||
desc: "Disable SSL verification on select targets"
|
||||
option :target_id, type: :string,
|
||||
desc: "Provide a ID which will be included on reports"
|
||||
desc: "Provide a ID which will be included on reports - deprecated"
|
||||
option :winrm_shell_type, type: :string, default: "powershell",
|
||||
desc: "Specify a shell type for winrm (eg. 'elevated' or 'powershell')"
|
||||
option :docker_url, type: :string,
|
||||
|
|
|
@ -302,6 +302,7 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|||
def exec(*targets)
|
||||
o = config
|
||||
diagnose(o)
|
||||
deprecate_target_id(config)
|
||||
configure_logger(o)
|
||||
|
||||
runner = Inspec::Runner.new(o)
|
||||
|
@ -320,6 +321,7 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|||
option :format, type: :string
|
||||
def detect
|
||||
o = config
|
||||
deprecate_target_id(config)
|
||||
o[:command] = "platform.params"
|
||||
|
||||
configure_logger(o)
|
||||
|
@ -360,6 +362,7 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|||
desc: "Specify one or more inputs directly on the command line to the shell, as --input NAME=VALUE. Accepts single-quoted YAML and JSON structures."
|
||||
def shell_func
|
||||
o = config
|
||||
deprecate_target_id(config)
|
||||
diagnose(o)
|
||||
o[:debug_shell] = true
|
||||
|
||||
|
@ -447,6 +450,12 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|||
|
||||
private
|
||||
|
||||
def deprecate_target_id(config)
|
||||
unless config[:target_id].nil?
|
||||
Inspec.deprecate "cli_option_target_id"
|
||||
end
|
||||
end
|
||||
|
||||
def run_command(opts)
|
||||
runner = Inspec::Runner.new(Inspec::Config.new(opts))
|
||||
res = runner.eval_with_virtual_profile(opts[:command])
|
||||
|
|
|
@ -21,7 +21,7 @@ module Inspec::Reporters
|
|||
final_report[:type] = "inspec_report"
|
||||
|
||||
final_report[:end_time] = Time.now.utc.strftime("%FT%TZ")
|
||||
final_report[:node_uuid] = report[:platform][:target_id] || @config["node_uuid"] || @config["target_id"]
|
||||
final_report[:node_uuid] = @config["node_uuid"] || report[:platform][:target_id]
|
||||
raise Inspec::ReporterError, "Cannot find a UUID for your node. Please specify one via json-config." if final_report[:node_uuid].nil?
|
||||
|
||||
final_report[:report_uuid] = @config["report_uuid"] || uuid_from_string(final_report[:end_time] + final_report[:node_uuid])
|
||||
|
|
|
@ -76,7 +76,7 @@ module Inspec::Reporters
|
|||
}
|
||||
header["Failure Message"] = profile[:status_message] if profile[:status] == "failed"
|
||||
header["Target"] = run_data[:platform][:target] unless run_data[:platform][:target].nil?
|
||||
header["Target ID"] = @config["target_id"] unless @config["target_id"].nil?
|
||||
header["Target ID"] = run_data[:platform][:target_id] || ""
|
||||
|
||||
pad = header.keys.max_by(&:length).length + 1
|
||||
header.each do |title, value|
|
||||
|
|
|
@ -29,7 +29,7 @@ module Inspec::Reporters
|
|||
{
|
||||
name: run_data[:platform][:name],
|
||||
release: run_data[:platform][:release],
|
||||
target_id: run_data[:platform][:target_id] || @config["target_id"],
|
||||
target_id: run_data[:platform][:target_id] || "",
|
||||
}.reject { |_k, v| v.nil? }
|
||||
end
|
||||
|
||||
|
|
7
test/fixtures/reporters/cli_output
vendored
7
test/fixtures/reporters/cli_output
vendored
|
@ -1,7 +1,8 @@
|
|||
|
||||
Profile: InSpec Profile (long_commands)
|
||||
Version: 0.1.0
|
||||
Target: local://
|
||||
Profile: InSpec Profile (long_commands)
|
||||
Version: 0.1.0
|
||||
Target: local://
|
||||
Target ID:
|
||||
|
||||
[38;5;41m ✔ tmp-1.0: Create /tmp directory[0m
|
||||
[38;5;41m ✔ File /tmp should be directory[0m
|
||||
|
|
7
test/fixtures/reporters/cli_output_windows
vendored
7
test/fixtures/reporters/cli_output_windows
vendored
|
@ -1,7 +1,8 @@
|
|||
|
||||
Profile: InSpec Profile (long_commands)
|
||||
Version: 0.1.0
|
||||
Target: local://
|
||||
Profile: InSpec Profile (long_commands)
|
||||
Version: 0.1.0
|
||||
Target: local://
|
||||
Target ID:
|
||||
|
||||
[0;1;32m [PASS] tmp-1.0: Create /tmp directory[0m
|
||||
[0;1;32m [PASS] File /tmp should be directory[0m
|
||||
|
|
3
test/fixtures/reporters/json_merged_output
vendored
3
test/fixtures/reporters/json_merged_output
vendored
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"platform": {
|
||||
"name": "mac_os_x",
|
||||
"release": "17.5.0"
|
||||
"release": "17.5.0",
|
||||
"target_id": ""
|
||||
},
|
||||
"profiles": [
|
||||
{
|
||||
|
|
2
test/fixtures/reporters/json_output
vendored
2
test/fixtures/reporters/json_output
vendored
|
@ -1 +1 @@
|
|||
{"platform":{"name":"mac_os_x","release":"17.2.0"},"profiles":[{"name":"long_commands","version":"0.1.0","sha256":"4f816f8cf18f165f05f1cf20936aaad06a15287de3f578891197647ca05c7df4","title":"InSpec Profile","maintainer":"The Authors","summary":"An InSpec Compliance Profile","license":"Apache-2.0","copyright":"The Authors","copyright_email":"you@example.com","supports":[{"os-family":"bds"},{"os-name":"mac_os_x","release":"17.*"}],"attributes":[],"groups":[{"id":"controls/example.rb","controls":["(generated from example.rb:7 871cd54043069c5c4f6e382fd5627830)","tmp-1.0","(generated from example.rb:21 2ff474c5357e7070f4c3efa932032dcb)"],"title":"sample section"},{"id":"controls/run_command.rb","controls":["(generated from run_command.rb:5 a411d4ded1530b2f48170840e1127584)"]}],"controls":[{"id":"(generated from example.rb:7 871cd54043069c5c4f6e382fd5627830)","title":null,"desc":null,"descriptions":[],"impact":0.5,"refs":[],"tags":{},"code":"","source_location":{"line":89,"ref":"/Users/jquick/Chef/inspec/lib/inspec/control_eval_context.rb"},"waiver_data":{},"results":[{"status":"passed","code_desc":"File /tmp should be directory","run_time":0.002058,"start_time":"2018-01-05 11:43:04 -0500","resource_params":"","resource_id":"File /tmp"}]},{"id":"tmp-1.0","title":"Create /tmp directory","desc":"An optional description...","descriptions":[{"label":"default","data":"An optional description..."}],"impact":0.7,"refs":[],"tags":{},"code":"control 'tmp-1.0' do # A unique ID for this control\n impact 0.7 # The criticality, if this control fails.\n title 'Create /tmp directory' # A human-readable title\n desc 'An optional description...'\n describe file('/tmp') do # The actual test\n it { should be_directory }\n end\nend\n","waiver_data":{},"source_location":{"line":12,"ref":"../inspec-demo/_test/long_commands/controls/example.rb"},"results":[{"status":"passed","code_desc":"File /tmp should be directory","run_time":0.000102,"start_time":"2018-01-05 11:43:04 -0500","resource_params":"","resource_id":"File /tmp"}]},{"id":"(generated from example.rb:21 2ff474c5357e7070f4c3efa932032dcb)","title":null,"desc":null,"descriptions":[],"impact":0.5,"refs":[],"tags":{},"code":"","waiver_data":{},"source_location":{"line":89,"ref":"/Users/jquick/Chef/inspec/lib/inspec/control_eval_context.rb"},"results":[{"status":"failed","code_desc":"gem package rubocop should be installed","run_time":0.000168,"start_time":"2018-01-05 11:43:04 -0500","message":"rubocop is not installed","resource_params":"","resource_id":"gem package rubocop"}]},{"id":"(generated from run_command.rb:5 a411d4ded1530b2f48170840e1127584)","title":null,"desc":null,"descriptions":[],"impact":0.5,"refs":[],"tags":{},"code":"","waiver_data":{},"source_location":{"line":89,"ref":"/Users/jquick/Chef/inspec/lib/inspec/control_eval_context.rb"},"results":[{"status":"passed","code_desc":"Command whoami stdout should eq \"jquick\\n\"","run_time":0.034938,"start_time":"2018-01-05 11:43:04 -0500","resource_params":"","resource_id":"stdout"}]}]}],"statistics":{"duration":0.039182},"version":"1.49.2"}
|
||||
{"platform":{"name":"mac_os_x","release":"17.2.0", "target_id":""},"profiles":[{"name":"long_commands","version":"0.1.0","sha256":"4f816f8cf18f165f05f1cf20936aaad06a15287de3f578891197647ca05c7df4","title":"InSpec Profile","maintainer":"The Authors","summary":"An InSpec Compliance Profile","license":"Apache-2.0","copyright":"The Authors","copyright_email":"you@example.com","supports":[{"os-family":"bds"},{"os-name":"mac_os_x","release":"17.*"}],"attributes":[],"groups":[{"id":"controls/example.rb","controls":["(generated from example.rb:7 871cd54043069c5c4f6e382fd5627830)","tmp-1.0","(generated from example.rb:21 2ff474c5357e7070f4c3efa932032dcb)"],"title":"sample section"},{"id":"controls/run_command.rb","controls":["(generated from run_command.rb:5 a411d4ded1530b2f48170840e1127584)"]}],"controls":[{"id":"(generated from example.rb:7 871cd54043069c5c4f6e382fd5627830)","title":null,"desc":null,"descriptions":[],"impact":0.5,"refs":[],"tags":{},"code":"","source_location":{"line":89,"ref":"/Users/jquick/Chef/inspec/lib/inspec/control_eval_context.rb"},"waiver_data":{},"results":[{"status":"passed","code_desc":"File /tmp should be directory","run_time":0.002058,"start_time":"2018-01-05 11:43:04 -0500","resource_params":"","resource_id":"File /tmp"}]},{"id":"tmp-1.0","title":"Create /tmp directory","desc":"An optional description...","descriptions":[{"label":"default","data":"An optional description..."}],"impact":0.7,"refs":[],"tags":{},"code":"control 'tmp-1.0' do # A unique ID for this control\n impact 0.7 # The criticality, if this control fails.\n title 'Create /tmp directory' # A human-readable title\n desc 'An optional description...'\n describe file('/tmp') do # The actual test\n it { should be_directory }\n end\nend\n","waiver_data":{},"source_location":{"line":12,"ref":"../inspec-demo/_test/long_commands/controls/example.rb"},"results":[{"status":"passed","code_desc":"File /tmp should be directory","run_time":0.000102,"start_time":"2018-01-05 11:43:04 -0500","resource_params":"","resource_id":"File /tmp"}]},{"id":"(generated from example.rb:21 2ff474c5357e7070f4c3efa932032dcb)","title":null,"desc":null,"descriptions":[],"impact":0.5,"refs":[],"tags":{},"code":"","waiver_data":{},"source_location":{"line":89,"ref":"/Users/jquick/Chef/inspec/lib/inspec/control_eval_context.rb"},"results":[{"status":"failed","code_desc":"gem package rubocop should be installed","run_time":0.000168,"start_time":"2018-01-05 11:43:04 -0500","message":"rubocop is not installed","resource_params":"","resource_id":"gem package rubocop"}]},{"id":"(generated from run_command.rb:5 a411d4ded1530b2f48170840e1127584)","title":null,"desc":null,"descriptions":[],"impact":0.5,"refs":[],"tags":{},"code":"","waiver_data":{},"source_location":{"line":89,"ref":"/Users/jquick/Chef/inspec/lib/inspec/control_eval_context.rb"},"results":[{"status":"passed","code_desc":"Command whoami stdout should eq \"jquick\\n\"","run_time":0.034938,"start_time":"2018-01-05 11:43:04 -0500","resource_params":"","resource_id":"stdout"}]}]}],"statistics":{"duration":0.039182},"version":"1.49.2"}
|
||||
|
|
1
test/fixtures/reporters/run_data.yml
vendored
1
test/fixtures/reporters/run_data.yml
vendored
|
@ -2,6 +2,7 @@
|
|||
:platform:
|
||||
:name: fedora
|
||||
:release: '28'
|
||||
:target_id: ''
|
||||
:profiles:
|
||||
- :name: tests from t.rb
|
||||
:sha256: 9260af15d2b7568443df4d9d2556f773f425f92491c97eb1d201c535c7a9f5e0
|
||||
|
|
1
test/fixtures/reporters/yaml_output
vendored
1
test/fixtures/reporters/yaml_output
vendored
|
@ -2,6 +2,7 @@
|
|||
:platform:
|
||||
:name: fedora
|
||||
:release: '28'
|
||||
:target_id: ''
|
||||
:profiles:
|
||||
- :name: tests from t.rb
|
||||
:sha256: 9260af15d2b7568443df4d9d2556f773f425f92491c97eb1d201c535c7a9f5e0
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
:platform:
|
||||
:name: fedora
|
||||
:release: '28'
|
||||
:target_id: ''
|
||||
:profiles:
|
||||
- :name: tests from t.rb
|
||||
:sha256: 9260af15d2b7568443df4d9d2556f773f425f92491c97eb1d201c535c7a9f5e0
|
||||
|
|
|
@ -168,7 +168,7 @@ describe "running profiles with git-based dependencies" do
|
|||
it "should use default HEAD branch" do
|
||||
inspec("exec #{git_default_main_profile_url}")
|
||||
assert_empty stderr
|
||||
assert_includes stdout, "Profile: InSpec Profile (default-main)"
|
||||
assert_includes stdout, "Profile: InSpec Profile (default-main)"
|
||||
assert_includes stdout, "Profile Summary: 1 successful control, 0 control failures, 0 controls skipped\n"
|
||||
assert_includes stdout, "Test Summary: 2 successful, 0 failures, 0 skipped\n"
|
||||
assert_exit_code 0, out
|
||||
|
|
|
@ -210,7 +210,14 @@ module FunctionalHelper
|
|||
|
||||
if opts[:json] && !run_result.stdout.empty?
|
||||
begin
|
||||
@json = JSON.parse(run_result.stdout)
|
||||
out = run_result.stdout.split("\n")
|
||||
if out.count > 1
|
||||
@deprication_msg = out[1].include?("The --target-id option is deprecated in InSpec 5") ? out[0] : nil
|
||||
out = out[1]
|
||||
else
|
||||
out = out[0]
|
||||
end
|
||||
@json = JSON.parse(out)
|
||||
rescue JSON::ParserError => e
|
||||
warn "JSON PARSE ERROR: %s" % [e.message]
|
||||
warn "OUT: <<%s>>" % [run_result.stdout]
|
||||
|
|
|
@ -49,7 +49,8 @@ describe "inspec exec with json formatter" do
|
|||
it "can execute a profile and validate the json schema and override the tagret id with platform uuid" do
|
||||
skip_windows!
|
||||
out = inspec("exec " + complete_profile + " --reporter json --no-create-lockfile --target-id 1d3e399f-4d71-4863-ac54-84d437fbc444")
|
||||
data = JSON.parse(out.stdout)
|
||||
_(out.stdout).must_include "The --target-id option is deprecated in InSpec 5. Its value will be ignored"
|
||||
data = JSON.parse(out.stdout.split("\n")[1])
|
||||
_(data["platform"]["target_id"]).wont_equal "1d3e399f-4d71-4863-ac54-84d437fbc444"
|
||||
_(data["platform"]["target_id"]).must_equal platform_uuid
|
||||
sout = inspec("schema exec-json")
|
||||
|
|
|
@ -59,15 +59,11 @@ describe "inspec exec" do
|
|||
it "executes a minimum metadata-only profile" do
|
||||
inspec("exec " + File.join(profile_path, "simple-metadata") + " --no-create-lockfile")
|
||||
|
||||
_(stdout).must_equal "
|
||||
Profile: yumyum profile
|
||||
Version: (not specified)
|
||||
Target: local://
|
||||
|
||||
No tests executed.
|
||||
|
||||
Test Summary: 0 successful, 0 failures, 0 skipped
|
||||
"
|
||||
_(stdout).must_include "Profile: yumyum profile"
|
||||
_(stdout).must_include "Version: (not specified)"
|
||||
_(stdout).must_include "Target: local://"
|
||||
_(stdout).must_include "No tests executed."
|
||||
_(stdout).must_include "Test Summary: 0 successful, 0 failures, 0 skipped"
|
||||
_(stderr).must_equal ""
|
||||
|
||||
assert_exit_code 0, out
|
||||
|
@ -115,10 +111,12 @@ Test Summary: 0 successful, 0 failures, 0 skipped
|
|||
assert_exit_code 0, out
|
||||
end
|
||||
|
||||
it "can execute the profile with a target_id passthrough" do
|
||||
it "shows deprecation warning for --target-id opition ignore the its value." do
|
||||
skip_windows!
|
||||
inspec("exec #{complete_profile} --no-create-lockfile --target-id 1d3e399f-4d71-4863-ac54-84d437fbc444")
|
||||
|
||||
_(stdout).must_include "Target ID: 1d3e399f-4d71-4863-ac54-84d437fbc444"
|
||||
_(stdout).must_include "The --target-id option is deprecated in InSpec 5. Its value will be ignored."
|
||||
_(stdout).must_include "Target ID: #{inspec_os_uuid}"
|
||||
|
||||
_(stderr).must_equal ""
|
||||
|
||||
|
@ -127,17 +125,11 @@ Test Summary: 0 successful, 0 failures, 0 skipped
|
|||
|
||||
it "executes a metadata-only profile" do
|
||||
inspec("exec " + File.join(profile_path, "complete-metadata") + " --no-create-lockfile")
|
||||
|
||||
_(stdout).must_equal "
|
||||
Profile: title (name)
|
||||
Version: 1.2.3
|
||||
Target: local://
|
||||
|
||||
No tests executed.
|
||||
|
||||
Test Summary: 0 successful, 0 failures, 0 skipped
|
||||
"
|
||||
|
||||
_(stdout).must_include "Profile: title (name)"
|
||||
_(stdout).must_include "Target: local://"
|
||||
_(stdout).must_include "Version: 1.2.3"
|
||||
_(stdout).must_include "No tests executed."
|
||||
_(stdout).must_include "Test Summary: 0 successful, 0 failures, 0 skipped\n"
|
||||
_(stderr).must_equal ""
|
||||
|
||||
assert_exit_code 0, out
|
||||
|
@ -155,7 +147,7 @@ Test Summary: 0 successful, 0 failures, 0 skipped
|
|||
|
||||
it "executes a specs-only profile" do
|
||||
inspec("exec " + File.join(profile_path, "spec_only") + " --no-create-lockfile")
|
||||
_(stdout).must_include "Target: local://"
|
||||
_(stdout).must_include "Target: local://"
|
||||
_(stdout).must_include "working"
|
||||
_(stdout).must_include "✔ is expected to eq \"working\""
|
||||
_(stdout).must_include "skippy\n"
|
||||
|
@ -528,17 +520,12 @@ Test Summary: 0 successful, 0 failures, 0 skipped
|
|||
describe "with a profile that inherits core resource into custom reosuce" do
|
||||
let(:out) { inspec("exec " + File.join(profile_path, "custom-resource-inheritance") + " --no-create-lockfile") }
|
||||
it "executes the custom resoruc without error" do
|
||||
_(stdout).must_equal "
|
||||
Profile: InSpec Profile (custom-resource-inheritance)
|
||||
Version: 0.1.0
|
||||
Target: local://
|
||||
|
||||
Node Json
|
||||
✔ name is expected to eq \"hello\"
|
||||
✔ [\"meta\", \"creator\"] is expected to eq \"John Doe\"
|
||||
|
||||
Test Summary: 2 successful, 0 failures, 0 skipped
|
||||
"
|
||||
_(stdout).must_include "Profile: InSpec Profile (custom-resource-inheritance)"
|
||||
_(stdout).must_include "Version: 0.1.0"
|
||||
_(stdout).must_include "local://"
|
||||
_(stdout).must_include "✔ name is expected to eq \"hello\""
|
||||
_(stdout).must_include "✔ [\"meta\", \"creator\"] is expected to eq \"John Doe\""
|
||||
_(stdout).must_include "Test Summary: 2 successful, 0 failures, 0 skipped"
|
||||
_(stderr).must_equal ""
|
||||
assert_exit_code 0, out
|
||||
end
|
||||
|
@ -548,19 +535,13 @@ Test Summary: 2 successful, 0 failures, 0 skipped
|
|||
let(:out) { inspec("exec " + example_control + " --no-create-lockfile") }
|
||||
|
||||
it "prints the control results, then the anonymous describe block results" do
|
||||
_(stdout).must_match(/Profile: tests from .*test.fixtures.profiles.old-examples.profile.controls.example-tmp.rb/)
|
||||
_(stdout).must_include "
|
||||
Version: (not specified)
|
||||
Target: local://
|
||||
|
||||
\xE2\x9C\x94 tmp-1.0: Create / directory
|
||||
\xE2\x9C\x94 File / is expected to be directory
|
||||
|
||||
File /
|
||||
\xE2\x9C\x94 is expected to be directory
|
||||
|
||||
Profile Summary: 1 successful control, 0 control failures, 0 controls skipped
|
||||
Test Summary: 2 successful, 0 failures, 0 skipped\n"
|
||||
_(stdout).must_include("test.fixtures.profiles.old-examples.profile.controls.example-tmp.rb")
|
||||
_(stdout).must_include "Version: (not specified)"
|
||||
_(stdout).must_include "Target: local://"
|
||||
_(stdout).must_include "✔ tmp-1.0: Create / directory"
|
||||
_(stdout).must_include "✔ File / is expected to be directory"
|
||||
_(stdout).must_include "Profile Summary: 1 successful control, 0 control failures, 0 controls skipped"
|
||||
_(stdout).must_include "Test Summary: 2 successful, 0 failures, 0 skipped\n"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1003,7 +984,7 @@ Test Summary: 2 successful, 0 failures, 0 skipped\n"
|
|||
|
||||
describe "when using the legacy --json-config" do
|
||||
let(:cli_args) { "--json-config " + File.join(config_dir_path, "json-config", "good.json") }
|
||||
it "should override the custom target ID value with platform uuid" do
|
||||
it "should ignore the custom target ID value and override it with platform uuid" do
|
||||
skip_windows!
|
||||
_(stderr).must_be_empty # TODO: one day deprecate the --json-config option
|
||||
_(seen_target_id).wont_equal "from-config-file"
|
||||
|
@ -1172,8 +1153,8 @@ Test Summary: 2 successful, 0 failures, 0 skipped\n"
|
|||
|
||||
describe "when a target URI with a known credset is used" do
|
||||
let(:cli_args) { "--target mock://mycredset" + " --config " + File.join(config_dir_path, "json-config", "mock-credset.json") }
|
||||
it "should connect to the mock platform" do
|
||||
_(seen_platform).must_equal({ "name" => "mock", "release" => "unknown", "target_id" => "from-mock-credset-config-file" })
|
||||
it "should connect to the mock platform and ignore the target_id set in the config file." do
|
||||
_(seen_platform).must_equal({ "name" => "mock", "release" => "unknown", "target_id" => "" })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -41,13 +41,7 @@ describe Inspec::Reporters::CLI do
|
|||
|
||||
describe "#print_profile_header" do
|
||||
it "confirm header output" do
|
||||
expected = <<~EOF
|
||||
Profile: InSpec Profile (long_commands)
|
||||
Version: 0.1.0
|
||||
Target: local://
|
||||
|
||||
EOF
|
||||
_(report.send(:print_profile_header, profile)).must_equal expected
|
||||
_(report.send(:print_profile_header, profile)).must_equal "Profile: InSpec Profile (long_commands)\nVersion: 0.1.0\nTarget: local://\nTarget ID: \n\n"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ describe Inspec::Reporters::Json do
|
|||
|
||||
describe "#platform" do
|
||||
it "confirm platform output" do
|
||||
hash = { name: "mac_os_x", release: "17.2.0" }
|
||||
hash = { name: "mac_os_x", release: "17.2.0", target_id: "" }
|
||||
_(report.send(:platform)).must_equal hash
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue