diff options
author | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-08-30 00:28:34 +0530 |
---|---|---|
committer | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-08-30 00:31:30 +0530 |
commit | d3b8707a698b47572481ea074b2edcf0e926ee29 (patch) | |
tree | 8106076ec1b1ebaa37755eda0537fd01b41564ae /spec/unit/knife | |
parent | 3d5abb8793042dd065743dda62a936934dc63d11 (diff) | |
download | chef-d3b8707a698b47572481ea074b2edcf0e926ee29.tar.gz |
Change ownership --sudo option is passed.
- If --sudo is passed then command run as root user instead of the logged-in user.
- It will create Dir with root user privilege.
- In order to fix this need to change the dir ownership back to the logged-in user.
Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
Diffstat (limited to 'spec/unit/knife')
-rw-r--r-- | spec/unit/knife/bootstrap/train_connector_spec.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/spec/unit/knife/bootstrap/train_connector_spec.rb b/spec/unit/knife/bootstrap/train_connector_spec.rb index bb6d21875f..dd000f7300 100644 --- a/spec/unit/knife/bootstrap/train_connector_spec.rb +++ b/spec/unit/knife/bootstrap/train_connector_spec.rb @@ -165,14 +165,17 @@ describe Chef::Knife::Bootstrap::TrainConnector do context "uses the *nix command to create the temp dir and sets ownership to logged-in" do it "with sudo privilege" do subject.config[:sudo] = true - expected_command = "mkdir -p #{dir} && sudo chown user1 '#{dir}'" - expect(subject).to receive(:run_command!).with(expected_command) + expected_command1 = "mkdir -p '#{dir}'" + expected_command2 = "chown user1 '#{dir}'" + expect(subject).to receive(:run_command!).with(expected_command1) + .and_return double("result", stdout: "\r\n") + expect(subject).to receive(:run_command!).with(expected_command2) .and_return double("result", stdout: "\r\n") expect(subject.temp_dir).to eq(dir) end it "without sudo privilege" do - expected_command = "mkdir -p #{dir}" + expected_command = "mkdir -p '#{dir}'" expect(subject).to receive(:run_command!).with(expected_command) .and_return double("result", stdout: "\r\n") expect(subject.temp_dir).to eq(dir) @@ -181,7 +184,7 @@ describe Chef::Knife::Bootstrap::TrainConnector do context "with noise in stderr" do it "uses the *nix command to create the temp dir" do - expected_command = "mkdir -p #{dir}" + expected_command = "mkdir -p '#{dir}'" expect(subject).to receive(:run_command!).with(expected_command) .and_return double("result", stdout: "sudo: unable to resolve host hostname.localhost\r\n" + "#{dir}\r\n") expect(subject.temp_dir).to eq(dir) |