summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-10-11 21:07:29 -0700
committerMarkus Roberts <Markus@reality.com>2010-10-13 16:49:46 -0700
commite232770baefc35abb71de6e2f28d053158e6dd45 (patch)
tree730004d0698a9afe1cd5587a6dfd23b646815c97 /spec
parenta090e868d55ea9b10f8193dcb2d1f23838a6def1 (diff)
downloadpuppet-e232770baefc35abb71de6e2f28d053158e6dd45.tar.gz
puppet-e232770baefc35abb71de6e2f28d053158e6dd45.tar.xz
puppet-e232770baefc35abb71de6e2f28d053158e6dd45.zip
Minimal fix for #4975 -- only call chage when managing password age rules
This is intended to be a minimal fix, with tests, to prevent chage from running unless needed.
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/provider/user/useradd_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/unit/provider/user/useradd_spec.rb b/spec/unit/provider/user/useradd_spec.rb
index 26367c584..9ebba596c 100755
--- a/spec/unit/provider/user/useradd_spec.rb
+++ b/spec/unit/provider/user/useradd_spec.rb
@@ -131,4 +131,46 @@ describe provider_class do
@provider.addcmd.must == ["useradd", "-G", "somegroup", "-o", "-m", "someuser"]
end
end
+
+ describe "when calling passcmd" do
+ before do
+ @resource.stubs(:allowdupe?).returns true
+ @resource.stubs(:managehome?).returns true
+ end
+
+ it "should call command with :pass" do
+ @provider.expects(:command).with(:password)
+ @provider.passcmd
+ end
+
+ it "should return nil if neither min nor max is set" do
+ @resource.stubs(:should).with(:password_min_age).returns nil
+ @resource.stubs(:should).with(:password_max_age).returns nil
+ @provider.passcmd.must == nil
+ end
+
+ it "should return a chage command array with -m <value> and the user name if password_min_age is set" do
+ @provider.stubs(:command).with(:password).returns("chage")
+ @resource.stubs(:[]).with(:name).returns("someuser")
+ @resource.stubs(:should).with(:password_min_age).returns 123
+ @resource.stubs(:should).with(:password_max_age).returns nil
+ @provider.passcmd.must == ['chage','-m',123,'someuser']
+ end
+
+ it "should return a chage command array with -M <value> if password_max_age is set" do
+ @provider.stubs(:command).with(:password).returns("chage")
+ @resource.stubs(:[]).with(:name).returns("someuser")
+ @resource.stubs(:should).with(:password_min_age).returns nil
+ @resource.stubs(:should).with(:password_max_age).returns 999
+ @provider.passcmd.must == ['chage','-M',999,'someuser']
+ end
+
+ it "should return a chage command array with -M <value> -m <value> if both password_min_age and password_max_age are set" do
+ @provider.stubs(:command).with(:password).returns("chage")
+ @resource.stubs(:[]).with(:name).returns("someuser")
+ @resource.stubs(:should).with(:password_min_age).returns 123
+ @resource.stubs(:should).with(:password_max_age).returns 999
+ @provider.passcmd.must == ['chage','-m',123,'-M',999,'someuser']
+ end
+ end
end