[Pkg-puppet-devel] [SCM] Packaging of Facter for debian branch, upstream, updated. 3a39dd8353b6308cf49522990104cc63e55d7cda

James Turnbull james at lovedthanlost.net
Fri Jan 29 17:22:26 UTC 2010


The following commit has been merged in the upstream branch:
commit 00b192a727c3b3c573e103b78acaad2ba6215ac1
Author: James Turnbull <james at lovedthanlost.net>
Date:   Tue May 12 21:31:30 2009 +1000

    Added SELinux tests

diff --git a/spec/unit/selinux.rb b/spec/unit/selinux.rb
new file mode 100644
index 0000000..8afa463
--- /dev/null
+++ b/spec/unit/selinux.rb
@@ -0,0 +1,48 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../spec_helper'
+
+require 'facter'
+
+describe "SELinux facts" do
+
+
+    after do
+        Facter.clear
+    end
+
+    it "should return true if SELinux enabled" do
+        Facter.fact(:kernel).stubs(:value).returns("Linux")
+
+        FileTest.stubs(:exists?).returns false
+        File.stubs(:read).with("/proc/self/attr/current").returns("notkernel")
+
+        FileTest.expects(:exists?).with("/selinux/enforce").returns true
+        FileTest.expects(:exists?).with("/proc/self/attr/current").returns true
+        File.expects(:read).with("/proc/self/attr/current").returns("kernel")
+
+        Facter.fact(:selinux).value.should == "true"
+    end
+
+    it "should return true if SELinux policy enabled" do
+       Facter.fact(:selinux).stubs(:value).returns("true")
+
+       FileTest.stubs(:exists?).returns false
+       File.stubs(:read).with("/selinux/enforce").returns("0")
+
+       FileTest.expects(:exists?).with("/selinux/enforce").returns true
+       File.expects(:read).with("/selinux/enforce").returns("1") 
+
+       Facter.fact(:selinux_enforced).value.should == "true"
+    end
+  
+    it "should return an SELinux policy version" do
+       Facter.fact(:selinux).stubs(:value).returns("true")
+
+       File.stubs(:read).with("/selinux/policyvers").returns("")
+
+       File.expects(:read).with("/selinux/policyvers").returns("1")
+
+       Facter.fact(:selinux_policyversion).value.should == "1"
+    end
+end

-- 
Packaging of Facter for debian



More information about the Pkg-puppet-devel mailing list