Skip to content

Commit

Permalink
Added additional specs for validating vault data with tab or new line
Browse files Browse the repository at this point in the history
Signed-off-by: sanga17 <[email protected]>
  • Loading branch information
sanga1794 committed Aug 20, 2021
1 parent 35c56ce commit f051821
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions spec/chef/helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
RSpec.describe ChefVault::Mixin::Helper do
include ChefVault::Mixin::Helper

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

Expand All @@ -15,5 +16,12 @@
it "Not to raise error if valid data provided" do
expect { validate_json(json_data) }.to_not raise_error
end

it "not to raise error if data consist of tab/new line OR space" do
%w{abc\tabc abc\nabc}.each do |pass|
json_data_with_slash = json.merge("password": pass)
expect { validate_json(json_data_with_slash.to_s) }.to_not raise_error
end
end
end
end

0 comments on commit f051821

Please sign in to comment.