summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorNigel Kersten <nigelk@google.com>2009-07-06 14:55:52 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-07-11 00:47:17 +1000
commit858d3334004bbcd642443a5de061b9733a8e765c (patch)
treea1bf222e653c333304d5e908a741651b6446af34 /spec
parent44f127f738f6427bdf2adbe1d06d57b7b62e715e (diff)
Fixes #2258,#2257,#2256. Maintain correct type for integers/booleans, allow correct values, and fix rule array handling
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/type/macauthorization.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/unit/type/macauthorization.rb b/spec/unit/type/macauthorization.rb
index 191a16bd0..8785984fe 100755
--- a/spec/unit/type/macauthorization.rb
+++ b/spec/unit/type/macauthorization.rb
@@ -13,6 +13,7 @@ describe Puppet::Type.type(:macauthorization), "when checking macauthorization o
provider_class = macauth_type.provider(macauth_type.providers[0])
Plist.stubs(:parse_xml).with("/etc/authorization").returns(authplist)
macauth_type.stubs(:defaultprovider).returns provider_class
+ @resource = macauth_type.new(:name => 'foo')
end
describe "when validating attributes" do
@@ -70,4 +71,41 @@ describe Puppet::Type.type(:macauthorization), "when checking macauthorization o
end
+ [:k_of_n, :timeout, :tries].each do |property|
+ describe "when managing the #{property} property" do
+ it "should convert number-looking strings into actual numbers" do
+ prop = macauth_type.attrclass(property).new(:resource => @resource)
+ prop.should = "300"
+ prop.should.must == 300
+ end
+ it "should support integers as a value" do
+ prop = macauth_type.attrclass(property).new(:resource => @resource)
+ prop.should = 300
+ prop.should.must == 300
+ end
+ it "should raise an error for non-integer values" do
+ prop = macauth_type.attrclass(property).new(:resource => @resource)
+ lambda { prop.should = "foo" }.should raise_error(Puppet::Error)
+ end
+ end
+ end
+
+ [:allow_root, :authenticate_user, :session_owner, :shared].each do |property|
+ describe "when managing the #{property} property" do
+ it "should convert boolean-looking false strings into actual booleans" do
+ prop = macauth_type.attrclass(property).new(:resource => @resource)
+ prop.should = "false"
+ prop.should.must == :false
+ end
+ it "should convert boolean-looking true strings into actual booleans" do
+ prop = macauth_type.attrclass(property).new(:resource => @resource)
+ prop.should = "true"
+ prop.should.must == :true
+ end
+ it "should raise an error for non-boolean values" do
+ prop = macauth_type.attrclass(property).new(:resource => @resource)
+ lambda { prop.should = "foo" }.should raise_error(Puppet::Error)
+ end
+ end
+ end
end