summaryrefslogtreecommitdiff
path: root/chef-config/spec
diff options
context:
space:
mode:
authoryoungjl1 <luke.young@gmail.com>2015-12-16 23:05:24 -0500
committerJay Mundrawala <jdmundrawala@gmail.com>2016-02-16 19:07:55 -0800
commit8417850f5b3bba689694a4114502034600a44602 (patch)
treeb45461c929a04614dce91c3d18c7bc0c9d53a449 /chef-config/spec
parenta028bda72981a9b58427054d51d69a58b45badc2 (diff)
downloadchef-8417850f5b3bba689694a4114502034600a44602.tar.gz
Fix databag globbing issues for chef-solo on windows
Backslashes should not be passed to Dir, as it does not work when globbing in many cases. Created new function that can be used with dir on windows. `escape_glob_dir` should be used when the result is going to be passed into Dir. Fixes #4194 Replaces #4195
Diffstat (limited to 'chef-config/spec')
-rw-r--r--chef-config/spec/unit/path_helper_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/chef-config/spec/unit/path_helper_spec.rb b/chef-config/spec/unit/path_helper_spec.rb
index b67a074f9e..9cdc7a6d9c 100644
--- a/chef-config/spec/unit/path_helper_spec.rb
+++ b/chef-config/spec/unit/path_helper_spec.rb
@@ -266,6 +266,23 @@ RSpec.describe ChefConfig::PathHelper do
end
end
+ describe "escape_glob_dir" do
+ it "escapes characters reserved by glob" do
+ path = "C:\\this\\*path\\[needs]\\escaping?"
+ escaped_path = "C:\\\\this\\\\\\*path\\\\\\[needs\\]\\\\escaping\\?"
+ expect(path_helper.escape_glob_dir(path)).to eq(escaped_path)
+ end
+
+ context "when given more than one argument" do
+ it "joins, cleanpaths, and escapes characters reserved by glob" do
+ args = ["this/*path", "[needs]", "escaping?"]
+ escaped_path = "this/\\*path/\\[needs\\]/escaping\\?"
+ expect(path_helper).to receive(:join).with(*args).and_call_original
+ expect(path_helper.escape_glob_dir(*args)).to eq(escaped_path)
+ end
+ end
+ end
+
describe "all_homes" do
before do
stub_const("ENV", env)