diff options
author | SteveLowe <slowe@slnet.eu> | 2015-03-12 07:51:43 +0000 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-06-02 14:17:12 -0700 |
commit | 1b3e3c8e3a743187abe7dfe593a04df1df29174c (patch) | |
tree | c120e59ee2f65094cd0c22c5d7bf7d2301ea81d8 /spec | |
parent | d8172e646d9fbf43e57bca5e20d0ac352ba9a66a (diff) | |
download | chef-1b3e3c8e3a743187abe7dfe593a04df1df29174c.tar.gz |
Fix copying ntfs dacl and sacl when nulljdm/3066
Fixes #1992
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/file_content_management/deploy/mv_windows_spec.rb | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/unit/file_content_management/deploy/mv_windows_spec.rb b/spec/unit/file_content_management/deploy/mv_windows_spec.rb index c52001cd26..2d1981befc 100644 --- a/spec/unit/file_content_management/deploy/mv_windows_spec.rb +++ b/spec/unit/file_content_management/deploy/mv_windows_spec.rb @@ -115,6 +115,66 @@ describe Chef::FileContentManagement::Deploy::MvWindows do end + context "and the target file has null dacl and sacl" do + + before do + allow(target_file_security_descriptor).to receive(:dacl_present?).and_return(true) + allow(target_file_security_descriptor).to receive(:dacl).and_return(nil) + allow(target_file_security_descriptor).to receive(:dacl_inherits?).and_return(false) + + allow(target_file_security_descriptor).to receive(:sacl_present?).and_return(true) + allow(target_file_security_descriptor).to receive(:sacl).and_return(nil) + allow(target_file_security_descriptor).to receive(:sacl_inherits?).and_return(false) + + expect(updated_target_security_object).to receive(:set_dacl).with(nil, false) + expect(updated_target_security_object).to receive(:set_sacl).with(nil, false) + end + + + it "fixes up permissions and moves the file into place" do + content_deployer.deploy(staging_file_path, target_file_path) + end + + end + + context "and the target has an empty dacl and sacl" do + let(:original_target_file_dacl) { [] } + let(:original_target_file_sacl) { [] } + + let(:empty_dacl) { double("Windows ACL with no dacl ACEs") } + let(:empty_sacl) { double("Windows ACL with no sacl ACEs") } + + before do + allow(target_file_security_descriptor).to receive(:dacl_present?).and_return(true) + allow(target_file_security_descriptor).to receive(:dacl_inherits?).and_return(false) + + allow(target_file_security_descriptor).to receive(:dacl).and_return(original_target_file_dacl) + expect(Chef::ReservedNames::Win32::Security::ACL). + to receive(:create). + with([]). + and_return(empty_dacl) + + + allow(target_file_security_descriptor).to receive(:sacl_present?).and_return(true) + allow(target_file_security_descriptor).to receive(:sacl_inherits?).and_return(false) + + allow(target_file_security_descriptor).to receive(:sacl).and_return(original_target_file_sacl) + expect(Chef::ReservedNames::Win32::Security::ACL). + to receive(:create). + with([]). + and_return(empty_sacl) + + + expect(updated_target_security_object).to receive(:set_dacl).with(empty_dacl, false) + expect(updated_target_security_object).to receive(:set_sacl).with(empty_sacl, false) + end + + + it "fixes up permissions and moves the file into place" do + content_deployer.deploy(staging_file_path, target_file_path) + end + end + context "and the target has a dacl and sacl" do let(:inherited_dacl_ace) { double("Windows dacl ace (inherited)", :inherited? => true) } let(:not_inherited_dacl_ace) { double("Windows dacl ace (not inherited)", :inherited? => false) } |