|
1 | 1 | require 'spec_helper'
|
2 | 2 | require 'puppet/module_tool'
|
3 | 3 |
|
4 |
| -describe Puppet::ModuleTool::Tar::Gnu do |
| 4 | +describe Puppet::ModuleTool::Tar::Gnu, unless: Puppet::Util::Platform.windows? do |
| 5 | + let(:sourcedir) { '/space path/the/src/dir' } |
5 | 6 | let(:sourcefile) { '/space path/the/module.tar.gz' }
|
6 | 7 | let(:destdir) { '/space path/the/dest/dir' }
|
7 |
| - let(:sourcedir) { '/space path/the/src/dir' } |
8 |
| - let(:destfile) { '/space path/the/dest/file.tar.gz' } |
| 8 | + let(:destfile) { '/space path/the/dest/fi le.tar.gz' } |
| 9 | + |
| 10 | + let(:safe_sourcedir) { '/space\ path/the/src/dir' } |
| 11 | + let(:safe_sourcefile) { '/space\ path/the/module.tar.gz' } |
| 12 | + let(:safe_destdir) { '/space\ path/the/dest/dir' } |
| 13 | + let(:safe_destfile) { 'fi\ le.tar.gz' } |
9 | 14 |
|
10 | 15 | it "unpacks a tar file" do
|
11 |
| - expect(Dir).to receive(:chdir).with(File.expand_path(destdir)).and_yield |
12 |
| - expect(Puppet::Util::Execution).to receive(:execute).with("gzip -dc #{Shellwords.shellescape(File.expand_path(sourcefile))} | tar xof -") |
13 |
| - expect(Puppet::Util::Execution).to receive(:execute).with("find . -type d -exec chmod 755 {} +") |
14 |
| - expect(Puppet::Util::Execution).to receive(:execute).with("find . -type f -exec chmod u+rw,g+r,a-st {} +") |
15 |
| - expect(Puppet::Util::Execution).to receive(:execute).with("chown -R <owner:group> .") |
| 16 | + expect(Puppet::Util::Execution).to receive(:execute).with("gzip -dc #{safe_sourcefile} | tar --extract --no-same-owner --directory #{safe_destdir} --file -") |
| 17 | + expect(Puppet::Util::Execution).to receive(:execute).with(['find', destdir, '-type', 'd', '-exec', 'chmod', '755', '{}', '+']) |
| 18 | + expect(Puppet::Util::Execution).to receive(:execute).with(['find', destdir, '-type', 'f', '-exec', 'chmod', 'u+rw,g+r,a-st', '{}', '+']) |
| 19 | + expect(Puppet::Util::Execution).to receive(:execute).with(['chown', '-R', '<owner:group>', destdir]) |
16 | 20 | subject.unpack(sourcefile, destdir, '<owner:group>')
|
17 | 21 | end
|
18 | 22 |
|
19 | 23 | it "packs a tar file" do
|
20 |
| - expect(Puppet::Util::Execution).to receive(:execute).with("tar cf - #{sourcedir} | gzip -c > #{File.basename(destfile)}") |
| 24 | + expect(Puppet::Util::Execution).to receive(:execute).with("tar cf - #{safe_sourcedir} | gzip -c > #{safe_destfile}") |
21 | 25 | subject.pack(sourcedir, destfile)
|
22 | 26 | end
|
23 | 27 | end
|
0 commit comments