mirror of
https://github.com/inspec/inspec
synced 2024-11-23 21:23:29 +00:00
Merge pull request #5135 from inspec/ns/input_equal_sign_5131
Allow ‘=‘ character in CLI inputs
This commit is contained in:
commit
a461d42a85
4 changed files with 29 additions and 1 deletions
|
@ -165,7 +165,8 @@ module Inspec
|
|||
raise ArgumentError, "ERROR: An '=' is required when using --input. Usage: --input input_name1=input_value1 input2=value2"
|
||||
end
|
||||
end
|
||||
input_name, input_value = pair.split("=")
|
||||
pair = pair.match(/(.*?)=(.*)/)
|
||||
input_name, input_value = pair[1], pair[2]
|
||||
input_value = parse_cli_input_value(input_name, input_value)
|
||||
evt = Inspec::Input::Event.new(
|
||||
value: input_value,
|
||||
|
|
7
test/fixtures/profiles/inputs/with_various_values/controls/input_equals.rb
vendored
Normal file
7
test/fixtures/profiles/inputs/with_various_values/controls/input_equals.rb
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
title 'With various values'
|
||||
|
||||
control 'with equals sign' do
|
||||
describe input(:my_input) do
|
||||
it { should eq 'ab=cde' }
|
||||
end
|
||||
end
|
8
test/fixtures/profiles/inputs/with_various_values/inspec.yml
vendored
Normal file
8
test/fixtures/profiles/inputs/with_various_values/inspec.yml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
name: profile
|
||||
title: InSpec Example Profile
|
||||
maintainer: Chef Software, Inc.
|
||||
copyright: Chef Software, Inc.
|
||||
copyright_email: support@chef.io
|
||||
license: Apache-2.0
|
||||
summary: Demonstrates regressions for 5131
|
||||
version: 1.0.0
|
|
@ -32,6 +32,18 @@ describe "inspec exec" do
|
|||
FileUtils.rm_f "#{prof}/simple-metadata/inspec.lock"
|
||||
end
|
||||
|
||||
it "handles '=' character on input" do
|
||||
# This test handles a bug discovered at: https://github.com/inspec/inspec/issues/5131
|
||||
inspec(
|
||||
"exec " +
|
||||
File.join(profile_path, "inputs", "with_various_values") +
|
||||
" --no-create-lockfile" +
|
||||
" --input my_input='ab=cde'"
|
||||
)
|
||||
|
||||
_(stdout).must_include "0 failures"
|
||||
end
|
||||
|
||||
it "cleanly fails if mixing incompatible resource and transports" do
|
||||
# TODO: I do not know how to test this more directly. It should be possible.
|
||||
inspec "exec -t aws:// #{profile_path}/incompatible_resource_for_transport.rb"
|
||||
|
|
Loading…
Reference in a new issue