spec/unit/provider/selmodule_spec.rb in puppet-2.7.13 vs spec/unit/provider/selmodule_spec.rb in puppet-2.7.14
- old
+ new
@@ -4,10 +4,11 @@
# in the same directory as this test called selmodule-example.pp
# with version 1.5.0. The provided selmodule-example.pp is the first
# 256 bytes taken from /usr/share/selinux/targeted/nagios.pp on Fedora 9
require 'spec_helper'
+require 'stringio'
provider_class = Puppet::Type.type(:selmodule).provider(:semodule)
describe provider_class do
before :each do
@@ -17,23 +18,23 @@
end
describe "exists? method" do
it "should find a module if it is already loaded" do
@provider.expects(:command).with(:semodule).returns "/usr/sbin/semodule"
- @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields "bar\t1.2.3\nfoo\t4.4.4\nbang\t1.0.0\n"
+ @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields StringIO.new("bar\t1.2.3\nfoo\t4.4.4\nbang\t1.0.0\n")
@provider.exists?.should == :true
end
it "should return nil if not loaded" do
@provider.expects(:command).with(:semodule).returns "/usr/sbin/semodule"
- @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields "bar\t1.2.3\nbang\t1.0.0\n"
+ @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields StringIO.new("bar\t1.2.3\nbang\t1.0.0\n")
@provider.exists?.should be_nil
end
it "should return nil if no modules are loaded" do
@provider.expects(:command).with(:semodule).returns "/usr/sbin/semodule"
- @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields ""
+ @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields StringIO.new("")
@provider.exists?.should be_nil
end
end
describe "selmodversion_file" do
@@ -58,9 +59,15 @@
it "should return before checking file version if no loaded policy" do
@provider.expects(:selmodversion_loaded).returns nil
@provider.syncversion.should == :false
end
-
end
+ describe "selmodversion_loaded" do
+ it "should return the version of a loaded module" do
+ @provider.expects(:command).with(:semodule).returns "/usr/sbin/semodule"
+ @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields StringIO.new("bar\t1.2.3\nfoo\t4.4.4\nbang\t1.0.0\n")
+ @provider.selmodversion_loaded.should == "4.4.4"
+ end
+ end
end