[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585
James Turnbull
james at lovedthanlost.net
Fri Jan 23 14:21:39 UTC 2009
The following commit has been merged in the master branch:
commit b8ed6670cd0d77f63b153fb5d5afff41f2c03704
Author: James Turnbull <james at lovedthanlost.net>
Date: Sun Nov 16 10:20:22 2008 +1100
Fixed #1735 and #1747 - Fixes to confine system
diff --git a/CHANGELOG b/CHANGELOG
index ef7395d..82bcd6f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,6 @@
0.24.x
+ Fixed #1735 and #1747 - Fixes to confine system
+
Fixed #1681 - Add filesystem type check to test for per-file SELinux context support
Fixed #1746 - Sync SELinux file attributes after file contents created/modified
diff --git a/lib/puppet/provider/confine/variable.rb b/lib/puppet/provider/confine/variable.rb
index c868a4e..9bef694 100644
--- a/lib/puppet/provider/confine/variable.rb
+++ b/lib/puppet/provider/confine/variable.rb
@@ -24,6 +24,11 @@ class Puppet::Provider::Confine::Variable < Puppet::Provider::Confine
@facter_value
end
+ def initialize(values)
+ super
+ @values = @values.collect { |v| v.to_s.downcase }
+ end
+
def message(value)
"facter value '%s' for '%s' not in required list '%s'" % [test_value, self.name, values.join(",")]
end
@@ -35,10 +40,16 @@ class Puppet::Provider::Confine::Variable < Puppet::Provider::Confine
def reset
# Reset the cache. We want to cache it during a given
- # run, but across runs.
+ # run, but not across runs.
@facter_value = nil
end
+ def valid?
+ @values.include?(test_value.to_s.downcase)
+ ensure
+ reset
+ end
+
private
def setting?
diff --git a/spec/unit/provider/confine/variable.rb b/spec/unit/provider/confine/variable.rb
index 38b3dad..5f4c6c7 100755
--- a/spec/unit/provider/confine/variable.rb
+++ b/spec/unit/provider/confine/variable.rb
@@ -27,52 +27,40 @@ describe Puppet::Provider::Confine::Variable do
@confine.name = :myvar
end
- it "should use the 'pass?' method to test validity" do
- @confine.expects(:pass?).with("foo")
- @confine.valid?
- end
-
it "should use settings if the variable name is a valid setting" do
Puppet.settings.expects(:valid?).with(:myvar).returns true
Puppet.settings.expects(:value).with(:myvar).returns "foo"
- @confine.pass?("foo")
+ @confine.valid?
end
it "should use Facter if the variable name is not a valid setting" do
Puppet.settings.expects(:valid?).with(:myvar).returns false
Facter.expects(:value).with(:myvar).returns "foo"
- @confine.pass?("foo")
+ @confine.valid?
end
- it "should return true if the value matches the facter value" do
+ it "should be valid if the value matches the facter value" do
@confine.expects(:test_value).returns "foo"
- @confine.pass?("foo").should be_true
+ @confine.should be_valid
end
it "should return false if the value does not match the facter value" do
@confine.expects(:test_value).returns "fee"
- @confine.pass?("foo").should be_false
+ @confine.should_not be_valid
end
it "should be case insensitive" do
@confine.expects(:test_value).returns "FOO"
- @confine.pass?("foo").should be_true
+ @confine.should be_valid
end
it "should not care whether the value is a string or symbol" do
@confine.expects(:test_value).returns "FOO"
- @confine.pass?(:foo).should be_true
- end
-
- it "should cache the facter value during testing" do
- Facter.expects(:value).once.returns("FOO")
-
- @confine.pass?(:foo)
- @confine.pass?(:foo)
+ @confine.should be_valid
end
it "should produce a message that the fact value is not correct" do
@@ -81,6 +69,12 @@ describe Puppet::Provider::Confine::Variable do
message.should be_include("facter")
message.should be_include("bar,bee")
end
+
+ it "should be valid if the test value matches any of the provided values" do
+ @confine = Puppet::Provider::Confine::Variable.new(%w{bar bee})
+ @confine.expects(:test_value).returns "bee"
+ @confine.should be_valid
+ end
end
describe "when summarizing multiple instances" do
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list