summaryrefslogtreecommitdiff
path: root/knife/spec
diff options
context:
space:
mode:
authorsnehaldwivedi <sdwivedi@msystechnologies.com>2021-03-31 06:48:10 -0700
committersnehaldwivedi <sdwivedi@msystechnologies.com>2021-07-15 22:00:55 -0700
commitab4f5bfadbc3fb489fa0d757c4d551867181e5cd (patch)
tree35e326bae8cf742657b7c9e8b24fcc8f764b37ec /knife/spec
parentf2336b49fb9327f09c0343d59c239404b8221fa0 (diff)
downloadchef-ab4f5bfadbc3fb489fa0d757c4d551867181e5cd.tar.gz
Updated writable condition for check file permissions
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
Diffstat (limited to 'knife/spec')
-rw-r--r--knife/spec/unit/knife/client_create_spec.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/knife/spec/unit/knife/client_create_spec.rb b/knife/spec/unit/knife/client_create_spec.rb
index d7d108658e..043dad71e7 100644
--- a/knife/spec/unit/knife/client_create_spec.rb
+++ b/knife/spec/unit/knife/client_create_spec.rb
@@ -166,6 +166,20 @@ describe Chef::Knife::ClientCreate do
expect(client.validator).to be_truthy
end
end
+
+ describe "with -f or --file when dir or file is not writable" do
+ it "when the directory is not writable" do
+ knife.config[:file] = "example/client1.pem"
+ expect(knife.ui).to receive(:fatal).with("Dir example is not writable. Check permissions.")
+ expect { knife.run }.to raise_error(SystemExit)
+ end
+
+ it "when the file is not writable" do
+ knife.config[:file] = "test/client1.pem"
+ expect(knife.ui).to receive(:fatal).with("File test/client1.pem is not writable. Check permissions.")
+ expect { knife.run }.to raise_error(SystemExit)
+ end
+ end
end
end
end