diff options
author | Tim Smith <tsmith@chef.io> | 2017-12-21 09:49:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-21 09:49:42 -0800 |
commit | 71a596ec29d98030653f83dc13221593cc80d948 (patch) | |
tree | 2ab67d5dd38df679d374847c56429618ee09d750 /spec | |
parent | 8980bb3847c2bc9dd511bd8923066718b57217d2 (diff) | |
parent | 9f02a591acb6eeb99712c4c24beb653ddd528a5f (diff) | |
download | chef-71a596ec29d98030653f83dc13221593cc80d948.tar.gz |
Merge pull request #6695 from bloomberg/bootstrap-strings
Escape single-quoted strings from the context in knife bootstrap
Diffstat (limited to 'spec')
-rw-r--r-- | spec/data/client.d_00/02-strings.rb | 2 | ||||
-rw-r--r-- | spec/support/shared/unit/application_dot_d.rb | 2 | ||||
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 5 |
3 files changed, 9 insertions, 0 deletions
diff --git a/spec/data/client.d_00/02-strings.rb b/spec/data/client.d_00/02-strings.rb new file mode 100644 index 0000000000..7d9a49268c --- /dev/null +++ b/spec/data/client.d_00/02-strings.rb @@ -0,0 +1,2 @@ +# 02-strings.rb +something '/foo/bar' diff --git a/spec/support/shared/unit/application_dot_d.rb b/spec/support/shared/unit/application_dot_d.rb index da4eb88edd..b94fa7c184 100644 --- a/spec/support/shared/unit/application_dot_d.rb +++ b/spec/support/shared/unit/application_dot_d.rb @@ -38,9 +38,11 @@ shared_examples_for "an application that loads a dot d" do it "loads the configuration in order" do expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/00-foo.rb").cleanpath.to_s).and_return("foo 0") expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/01-bar.rb").cleanpath.to_s).and_return("bar 0") + expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/02-strings.rb").cleanpath.to_s).and_return("strings 0") allow(app).to receive(:apply_config).with(anything(), Chef::Config.platform_specific_path("/etc/chef/client.rb")).and_call_original.ordered expect(app).to receive(:apply_config).with("foo 0", Pathname.new("#{client_d_dir}/00-foo.rb").cleanpath.to_s).and_call_original.ordered expect(app).to receive(:apply_config).with("bar 0", Pathname.new("#{client_d_dir}/01-bar.rb").cleanpath.to_s).and_call_original.ordered + expect(app).to receive(:apply_config).with("strings 0", Pathname.new("#{client_d_dir}/02-strings.rb").cleanpath.to_s).and_call_original.ordered app.reconfigure end end diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index 736ff9b099..c725526de7 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -516,6 +516,11 @@ describe Chef::Knife::Bootstrap do end context "a flat directory structure" do + it "escapes single-quotes" do + expect(rendered_template).to match("cat > /etc/chef/client.d/02-strings.rb <<'EOP'") + expect(rendered_template).to match("something '\\\\''/foo/bar'\\\\''") + end + it "creates a file 00-foo.rb" do expect(rendered_template).to match("cat > /etc/chef/client.d/00-foo.rb <<'EOP'") expect(rendered_template).to match("d6f9b976-289c-4149-baf7-81e6ffecf228") |