summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc A. Paradise <marc.paradise@gmail.com>2019-04-19 22:18:51 -0400
committerMarc A. Paradise <marc.paradise@gmail.com>2019-04-24 13:29:00 -0400
commit601e6fd87dcf19b8e6d03b34c114492f5604fdd2 (patch)
tree36b9128050c83c522762edab14404035999cb908
parent9befa6106a1972549449e074fbcbe828151bf54f (diff)
downloadchef-601e6fd87dcf19b8e6d03b34c114492f5604fdd2.tar.gz
Use an empty dir for certs test instead of trying to mock one
When no certs are available, test with an actual empty certs dir. This works around a problem with the mock where on the Windows platform, a buried call to Dir.glob is returning the actual certificates directory content instead of the empty list required for the test. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
-rw-r--r--spec/data/trusted_certs_empty/.gitkeep0
-rw-r--r--spec/data/trusted_certs_empty/README.md1
-rw-r--r--spec/unit/knife/bootstrap_spec.rb10
3 files changed, 7 insertions, 4 deletions
diff --git a/spec/data/trusted_certs_empty/.gitkeep b/spec/data/trusted_certs_empty/.gitkeep
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/spec/data/trusted_certs_empty/.gitkeep
diff --git a/spec/data/trusted_certs_empty/README.md b/spec/data/trusted_certs_empty/README.md
new file mode 100644
index 0000000000..e7e52627f1
--- /dev/null
+++ b/spec/data/trusted_certs_empty/README.md
@@ -0,0 +1 @@
+A directory with no certs. Used for testing directories with no certs during bootstrap.
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index b5698c5a9f..f54c8ac1d6 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -447,11 +447,13 @@ describe Chef::Knife::Bootstrap do
end
end
- it "doesn't create /etc/chef/trusted_certs if :trusted_certs_dir is empty", :focus do
- allow(Dir).to receive(:glob).and_call_original # ensure the template can be found
- expect(Dir).to receive(:glob).with(File.join(trusted_certs_dir, "*.{crt,pem}")).and_return([])
- expect(rendered_template).not_to match(%r{mkdir -p /etc/chef/trusted_certs})
+ context "when :trusted_cets_dir is empty" do
+ let(:trusted_certs_dir) { Chef::Util::PathHelper.cleanpath(File.join(File.dirname(__FILE__), "../../data/trusted_certs_empty")) }
+ it "doesn't create /etc/chef/trusted_certs if :trusted_certs_dir is empty" do
+ expect(rendered_template).not_to match(%r{mkdir -p /etc/chef/trusted_certs})
+ end
end
+
end
context "when doing fips things" do