Skip to content

Commit

Permalink
Replaced exception with the warnings and removed related failing specs
Browse files Browse the repository at this point in the history
Signed-off-by: sanga17 <[email protected]>
  • Loading branch information
sanga1794 committed Feb 18, 2021
1 parent a8890fd commit f6eb7c4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
2 changes: 1 addition & 1 deletion lib/chef/knife/mixin/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def validate_json(json)
next unless printable?(value.to_s)

msg = "Value '#{value}' of key '#{key}' contains non-printable characters. Check that backslashes are escaped with another backslash (e.g. C:\\\\Windows) in double-quoted strings."
raise ChefVault::Exceptions::InvalidValue, msg
ChefVault::Log.warn(msg)
end
end
end
Expand Down
5 changes: 0 additions & 5 deletions spec/chef/helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@
include ChefVault::Mixin::Helper

let(:json_data) { '{"username": "root", "password": "abcabc"}' }
let(:json_data_control_char) { '{"username": "root", "password": "abc\abc"}' }
let(:buggy_json_data) { '{"username": "root", "password": "abc\abc"' }

describe "#validate_json" do
it "Raises InvalidValue Exception when invalid data provided" do
expect { validate_json(buggy_json_data) }.to raise_error(ChefVault::Exceptions::InvalidValue)
end

it "Raises InvalidValue Exception when value consist of control characters" do
expect { validate_json(json_data_control_char) }.to raise_error(ChefVault::Exceptions::InvalidValue)
end

it "Not to raise error if valid data provided" do
expect { validate_json(json_data) }.to_not raise_error
end
Expand Down

0 comments on commit f6eb7c4

Please sign in to comment.