summaryrefslogtreecommitdiffstats
path: root/spec/unit/util
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2009-11-24 09:09:07 -0800
committerJames Turnbull <james@lovedthanlost.net>2009-11-25 12:02:42 +1100
commit9a41c35a5160dbba10ec00f3ed45bafad3ebd06a (patch)
treea26ccc25d7213877fb85d1c311ec46fa186cf2f7 /spec/unit/util
parent562909281f2e0bd21fed922600027f0e9a47f5ec (diff)
downloadpuppet-9a41c35a5160dbba10ec00f3ed45bafad3ebd06a.tar.gz
puppet-9a41c35a5160dbba10ec00f3ed45bafad3ebd06a.tar.xz
puppet-9a41c35a5160dbba10ec00f3ed45bafad3ebd06a.zip
Fixing #2791 fs_find should follow symlinks
Symlinks confuse the "What file system am I on?" logic. This patch just runs the paths through a beefed up version of the standard 'realpath' method. Includes some of Markus's suggested changes. Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
Diffstat (limited to 'spec/unit/util')
-rwxr-xr-xspec/unit/util/selinux.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/unit/util/selinux.rb b/spec/unit/util/selinux.rb
index 2a9a4182e..7e6cdaf30 100755
--- a/spec/unit/util/selinux.rb
+++ b/spec/unit/util/selinux.rb
@@ -61,6 +61,42 @@ describe Puppet::Util::SELinux do
selinux_label_support?('/mnt/nfs/testfile').should be_false
end
+ it "should follow symlinks when determining file systems" do
+ self.stubs(:realpath).with('/mnt/symlink/testfile').returns('/mnt/nfs/dest/testfile')
+
+ selinux_label_support?('/mnt/symlink/testfile').should be_false
+ end
+
+ end
+
+ describe "realpath" do
+ it "should handle files that don't exist" do
+
+ # Since I'm stubbing Pathname.new for this test,
+ # I need to also stub the internal calls to Pathname.new,
+ # which happen in Pathname.dirname and Parthname.basename
+ # I want those to return real Pathname objects,
+ # so I'm creating them before the stub is in place.
+ realpaths = Hash.new {|hash, path| hash[path] = Pathname.new(path) }
+ paths = ['symlink', '/mnt']
+ paths.each { |path| realpaths[path] }
+
+ realpaths['/mnt/symlink'] = stubs "Pathname"
+ realpaths['/mnt/symlink'].stubs(:realpath).returns(realpaths['/mnt/nfs/dest'])
+ realpaths['/mnt/symlink'].stubs(:exist?).returns(true)
+
+ realpaths['/mnt/symlink/nonexistant'] = stubs "Pathname"
+ realpaths['/mnt/symlink/nonexistant'].stubs(:realpath).raises(Errno::ENOENT)
+ realpaths['/mnt/symlink/nonexistant'].stubs(:exist?).returns(false)
+ realpaths['/mnt/symlink/nonexistant'].stubs(:dirname).returns(realpaths['/mnt/symlink'])
+ realpaths['/mnt/symlink/nonexistant'].stubs(:basename).returns(realpaths['nonexistant'])
+
+ realpaths.each do |path, value|
+ Pathname.stubs(:new).with(path).returns(value)
+ end
+
+ realpath('/mnt/symlink/nonexistant').should == '/mnt/nfs/dest/nonexistant'
+ end
end
describe "get_selinux_current_context" do