summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-01-28 14:55:17 -0800
committerDaniel Pittman <daniel@rimspace.net>2011-01-28 14:55:17 -0800
commit95ebc00c4a529c88301b26e1b0c6ecfc3a0cf67f (patch)
treee0c704bca7846496c94a457fff8d71982286d43b
parent1dc6b42d5dbaf0ca2ad1b1e9dd2a5788bcdb643d (diff)
parentc50a48edb19e80d48019b19d852665411d6222e7 (diff)
downloadpuppet-95ebc00c4a529c88301b26e1b0c6ecfc3a0cf67f.tar.gz
puppet-95ebc00c4a529c88301b26e1b0c6ecfc3a0cf67f.tar.xz
puppet-95ebc00c4a529c88301b26e1b0c6ecfc3a0cf67f.zip
Merge branch 'bug/2.6.next/6061-password-max-age' into 2.6.next
-rwxr-xr-xlib/puppet/type/user.rb4
-rwxr-xr-xspec/unit/type/user_spec.rb28
2 files changed, 30 insertions, 2 deletions
diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb
index 5de73e3dd..e7389a0d1 100755
--- a/lib/puppet/type/user.rb
+++ b/lib/puppet/type/user.rb
@@ -175,7 +175,7 @@ module Puppet
end
validate do |value|
- if value.to_s !~ /^\d+$/
+ if value.to_s !~ /^-?\d+$/
raise ArgumentError, "Password minimum age must be provided as a number"
end
end
@@ -194,7 +194,7 @@ module Puppet
end
validate do |value|
- if value.to_s !~ /^\d+$/
+ if value.to_s !~ /^-?\d+$/
raise ArgumentError, "Password maximum age must be provided as a number"
end
end
diff --git a/spec/unit/type/user_spec.rb b/spec/unit/type/user_spec.rb
index 0c3e2ab2d..297134446 100755
--- a/spec/unit/type/user_spec.rb
+++ b/spec/unit/type/user_spec.rb
@@ -245,6 +245,34 @@ describe user do
end
end
+ describe "when managing minimum password age" do
+ before do
+ @age = user.attrclass(:password_min_age).new(:resource => @resource)
+ end
+
+ it "should accept a negative minimum age" do
+ expect { @age.should = -1 }.should_not raise_error
+ end
+
+ it "should fail with an empty minimum age" do
+ expect { @age.should = '' }.should raise_error(Puppet::Error)
+ end
+ end
+
+ describe "when managing maximum password age" do
+ before do
+ @age = user.attrclass(:password_max_age).new(:resource => @resource)
+ end
+
+ it "should accept a negative maximum age" do
+ expect { @age.should = -1 }.should_not raise_error
+ end
+
+ it "should fail with an empty maximum age" do
+ expect { @age.should = '' }.should raise_error(Puppet::Error)
+ end
+ end
+
describe "when managing passwords" do
before do
@password = user.attrclass(:password).new(:resource => @resource, :should => "mypass")