diff options
| author | Jesse Wolfe <jes5199@gmail.com> | 2010-10-18 12:01:29 -0700 |
|---|---|---|
| committer | Jesse Wolfe <jes5199@gmail.com> | 2010-10-18 12:01:29 -0700 |
| commit | 19ae3dffa4e52e752149ce90ebf83f9055c2313b (patch) | |
| tree | f5cf31b9d5c45a199dbb9795482efb08e3c8afb7 /spec | |
| parent | 2d13fdaac56bd5cd57444cc4447081649e18f487 (diff) | |
| parent | e3fc5b95d133aee1ae3dc188e6c47e88786dfc6e (diff) | |
| download | puppet-19ae3dffa4e52e752149ce90ebf83f9055c2313b.tar.gz puppet-19ae3dffa4e52e752149ce90ebf83f9055c2313b.tar.xz puppet-19ae3dffa4e52e752149ce90ebf83f9055c2313b.zip | |
Merge commit '2.6.3rc1' into next
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/unit/provider/user/user_role_add_spec.rb | 2 | ||||
| -rwxr-xr-x | spec/unit/provider/user/useradd_spec.rb | 42 | ||||
| -rwxr-xr-x | spec/unit/util/pson_spec.rb (renamed from spec/unit/util/json_spec.rb) | 17 |
3 files changed, 60 insertions, 1 deletions
diff --git a/spec/unit/provider/user/user_role_add_spec.rb b/spec/unit/provider/user/user_role_add_spec.rb index b3244f19d..9cf649267 100644 --- a/spec/unit/provider/user/user_role_add_spec.rb +++ b/spec/unit/provider/user/user_role_add_spec.rb @@ -72,7 +72,7 @@ describe provider_class do @provider = provider_class.new(@resource) @provider.stubs(:user_attributes) @provider.stubs(:execute) - @provider.expects(:execute).with { |cmd, *args| args == ["-m", 5, "-M", 10, "myuser"] } + @provider.expects(:execute).with { |cmd, *args| args == ["-n", 5, "-x", 10, "myuser"] } @provider.create end end 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 diff --git a/spec/unit/util/json_spec.rb b/spec/unit/util/pson_spec.rb index 4f6cea997..d02d28517 100755 --- a/spec/unit/util/json_spec.rb +++ b/spec/unit/util/pson_spec.rb @@ -18,4 +18,21 @@ describe Puppet::Util::Pson do pson.expects(:from_pson).with("mydata") pson.pson_create("type" => "foo", "data" => "mydata") end + + + { + 'foo' => '"foo"', + 1 => '1', + "\x80" => "\"\x80\"", + [] => '[]' + }.each { |str,pson| + it "should be able to encode #{str.inspect}" do + str.to_pson.should == pson + end + } + + it "should be able to handle arbitrary binary data" do + bin_string = (1..20000).collect { |i| ((17*i+13*i*i) % 255).chr }.join + PSON.parse(%Q{{ "type": "foo", "data": #{bin_string.to_pson} }})["data"].should == bin_string + end end |
