summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2011-03-11 10:42:41 +1100
committerJames Turnbull <james@lovedthanlost.net>2011-03-11 10:42:41 +1100
commitdea6f78ace56df3459dd182300cc9618df712317 (patch)
tree501efa88ae46a93667519ecf740c87f3c5f36fe0 /spec
parent7c05312d844b05465b6f2a05de456dff1ddf2cd9 (diff)
downloadfacter-dea6f78ace56df3459dd182300cc9618df712317.tar.gz
facter-dea6f78ace56df3459dd182300cc9618df712317.tar.xz
facter-dea6f78ace56df3459dd182300cc9618df712317.zip
Further fix to #5485 - SELinux facts
1. Added new facts for all values returned by the sestatus command 2. Updated legacy selinux_mode fact with former value 3. Added note and ticket #6677 to remove legacy fact at Facter 2.0.0 4. Added tests for new facts and legacy fact
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/data/selinux_sestatus2
-rwxr-xr-xspec/unit/selinux_spec.rb34
2 files changed, 34 insertions, 2 deletions
diff --git a/spec/unit/data/selinux_sestatus b/spec/unit/data/selinux_sestatus
index b16777f..50cea13 100644
--- a/spec/unit/data/selinux_sestatus
+++ b/spec/unit/data/selinux_sestatus
@@ -1,4 +1,6 @@
SELinux status: enabled
SELinuxfs mount: /selinux
Current Mode: permissive
+Mode from config file: permissive
Policy version: 16
+Policy from config file: targeted
diff --git a/spec/unit/selinux_spec.rb b/spec/unit/selinux_spec.rb
index 2af9583..d820958 100755
--- a/spec/unit/selinux_spec.rb
+++ b/spec/unit/selinux_spec.rb
@@ -46,7 +46,7 @@ describe "SELinux facts" do
Facter.fact(:selinux_policyversion).value.should == "1"
end
- it "should return the SELinux policy mode" do
+ it "should return the SELinux current mode" do
Facter.fact(:selinux).stubs(:value).returns("true")
sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus'
@@ -54,6 +54,36 @@ describe "SELinux facts" do
Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus)
- Facter.fact(:selinux_mode).value.should == "permissive"
+ Facter.fact(:selinux_current_mode).value.should == "permissive"
+ end
+
+ it "should return the SELinux mode from the configuration file" do
+ Facter.fact(:selinux).stubs(:value).returns("true")
+
+ sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus'
+ selinux_sestatus = File.read(sample_output_file)
+
+ Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus)
+
+ Facter.fact(:selinux_config_mode).value.should == "permissive"
+ end
+
+ it "should return the SELinux configuration file policy" do
+ Facter.fact(:selinux).stubs(:value).returns("true")
+
+ sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus'
+ selinux_sestatus = File.read(sample_output_file)
+
+ Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus)
+
+ Facter.fact(:selinux_config_policy).value.should == "targeted"
+ end
+
+ it "should ensure legacy selinux_mode facts returns same value as selinux_config_policy fact" do
+ Facter.fact(:selinux).stubs(:value).returns("true")
+
+ Facter.fact(:selinux_config_policy).stubs(:value).returns("targeted")
+
+ Facter.fact(:selinux_mode).value.should == "targeted"
end
end