diff options
author | Stig Sandbeck Mathisen <ssm@debian.org> | 2014-09-07 10:14:36 +0200 |
---|---|---|
committer | Stig Sandbeck Mathisen <ssm@debian.org> | 2014-09-07 10:14:36 +0200 |
commit | d4b83be375ac1dead058e091191ee7c7b7c24c8a (patch) | |
tree | dc825687392ae3068de5b764be60c53122d9e02a /spec/unit/module_tool/applications/unpacker_spec.rb | |
parent | 229cbb976fe0f70f5f30548b83517b415840f9bb (diff) | |
parent | 1681684857c6e39d60d87b0b3520d8783977ceff (diff) | |
download | puppet-upstream/3.7.0.tar.gz |
Imported Upstream version 3.7.0upstream/3.7.0
Diffstat (limited to 'spec/unit/module_tool/applications/unpacker_spec.rb')
-rw-r--r-- | spec/unit/module_tool/applications/unpacker_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/unit/module_tool/applications/unpacker_spec.rb b/spec/unit/module_tool/applications/unpacker_spec.rb index 39b0c261f..81557df99 100644 --- a/spec/unit/module_tool/applications/unpacker_spec.rb +++ b/spec/unit/module_tool/applications/unpacker_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' require 'json' require 'puppet/module_tool/applications' +require 'puppet/file_system' require 'puppet_spec/modules' describe Puppet::ModuleTool::Applications::Unpacker do @@ -31,4 +32,43 @@ describe Puppet::ModuleTool::Applications::Unpacker do Puppet::ModuleTool::Applications::Unpacker.run(filename, :target_dir => target) File.should be_directory(File.join(target, 'mytarball')) end + + it "should warn about symlinks", :if => Puppet.features.manages_symlinks? do + untar = mock('Tar') + untar.expects(:unpack).with(filename, anything()) do |src, dest, _| + FileUtils.mkdir(File.join(dest, 'extractedmodule')) + File.open(File.join(dest, 'extractedmodule', 'metadata.json'), 'w+') do |file| + file.puts JSON.generate('name' => module_name, 'version' => '1.0.0') + end + FileUtils.touch(File.join(dest, 'extractedmodule/tempfile')) + Puppet::FileSystem.symlink(File.join(dest, 'extractedmodule/tempfile'), File.join(dest, 'extractedmodule/tempfile2')) + true + end + + Puppet::ModuleTool::Tar.expects(:instance).returns(untar) + Puppet.expects(:warning).with(regexp_matches(/symlinks/i)) + + Puppet::ModuleTool::Applications::Unpacker.run(filename, :target_dir => target) + File.should be_directory(File.join(target, 'mytarball')) + end + + it "should warn about symlinks in subdirectories", :if => Puppet.features.manages_symlinks? do + untar = mock('Tar') + untar.expects(:unpack).with(filename, anything()) do |src, dest, _| + FileUtils.mkdir(File.join(dest, 'extractedmodule')) + File.open(File.join(dest, 'extractedmodule', 'metadata.json'), 'w+') do |file| + file.puts JSON.generate('name' => module_name, 'version' => '1.0.0') + end + FileUtils.mkdir(File.join(dest, 'extractedmodule/manifests')) + FileUtils.touch(File.join(dest, 'extractedmodule/manifests/tempfile')) + Puppet::FileSystem.symlink(File.join(dest, 'extractedmodule/manifests/tempfile'), File.join(dest, 'extractedmodule/manifests/tempfile2')) + true + end + + Puppet::ModuleTool::Tar.expects(:instance).returns(untar) + Puppet.expects(:warning).with(regexp_matches(/symlinks/i)) + + Puppet::ModuleTool::Applications::Unpacker.run(filename, :target_dir => target) + File.should be_directory(File.join(target, 'mytarball')) + end end |