blob: 43fd5bf679a7feef431b86ba5863b7debcce2204 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/usr/bin/env ruby
require File.expand_path(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
|