summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-05-21 00:30:24 -0500
committerLuke Kanies <luke@madstop.com>2008-05-21 00:30:24 -0500
commit4434072c7f51e4720b40aaea0637cb94dc6aefe5 (patch)
treedeaff95e8283e62f4909964cd09a4193e560db79 /spec/unit
parent419f2443c40116623b5c82f03eafcc85deeabcad (diff)
The ldap user/group providers now work when no users/groups are in ldap yet.
Previously, they failed if you tried to get them to autogenerate an id, because they assumed that a result would be returned.
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/provider/group/ldap.rb22
-rwxr-xr-xspec/unit/provider/user/ldap.rb31
2 files changed, 36 insertions, 17 deletions
diff --git a/spec/unit/provider/group/ldap.rb b/spec/unit/provider/group/ldap.rb
index 3f12d74e3..53d9e8bfc 100755
--- a/spec/unit/provider/group/ldap.rb
+++ b/spec/unit/provider/group/ldap.rb
@@ -45,8 +45,8 @@ describe provider_class do
describe "with no gid specified" do
it "should pick the first available GID after the largest existing GID" do
- low = {:name=>["luke"], :gid=>["100"]}
- high = {:name=>["testing"], :gid=>["140"]}
+ low = {:name=>["luke"], :gid=>["600"]}
+ high = {:name=>["testing"], :gid=>["640"]}
provider_class.manager.expects(:search).returns([low, high])
resource = stub 'resource', :should => %w{whatever}
@@ -55,12 +55,26 @@ describe provider_class do
instance = provider_class.new(:name => "luke", :ensure => :absent)
instance.stubs(:resource).returns resource
- @connection.expects(:add).with { |dn, attrs| attrs["gidNumber"] == ["141"] }
+ @connection.expects(:add).with { |dn, attrs| attrs["gidNumber"] == ["641"] }
+
+ instance.create
+ instance.flush
+ end
+
+ it "should pick '501' as its GID if no groups are found" do
+ provider_class.manager.expects(:search).returns nil
+
+ resource = stub 'resource', :should => %w{whatever}
+ resource.stubs(:should).with(:gid).returns nil
+ resource.stubs(:should).with(:ensure).returns :present
+ instance = provider_class.new(:name => "luke", :ensure => :absent)
+ instance.stubs(:resource).returns resource
+
+ @connection.expects(:add).with { |dn, attrs| attrs["gidNumber"] == ["501"] }
instance.create
instance.flush
end
end
end
-
end
diff --git a/spec/unit/provider/user/ldap.rb b/spec/unit/provider/user/ldap.rb
index eb13d8bbd..90fc7423f 100755
--- a/spec/unit/provider/user/ldap.rb
+++ b/spec/unit/provider/user/ldap.rb
@@ -24,16 +24,6 @@ describe provider_class do
provider_class.manager.rdn.should == :uid
end
- it "should be unsuitable if ldap is unavailable" do
- Puppet.features.expects(:ldap?).returns false
- provider_class.should_not be_suitable
- end
-
- it "should be suitable if ldap is available" do
- Puppet.features.expects(:ldap?).returns true
- provider_class.should be_suitable
- end
-
{:name => "uid",
:password => "userPassword",
:comment => "cn",
@@ -69,8 +59,8 @@ describe provider_class do
describe "with no uid specified" do
it "should pick the first available UID after the largest existing UID" do
- low = {:name=>["luke"], :shell=>:absent, :uid=>["100"], :home=>["/h"], :gid=>["1000"], :password=>["blah"], :comment=>["l k"]}
- high = {:name=>["testing"], :shell=>:absent, :uid=>["140"], :home=>["/h"], :gid=>["1000"], :password=>["blah"], :comment=>["t u"]}
+ low = {:name=>["luke"], :shell=>:absent, :uid=>["600"], :home=>["/h"], :gid=>["1000"], :password=>["blah"], :comment=>["l k"]}
+ high = {:name=>["testing"], :shell=>:absent, :uid=>["640"], :home=>["/h"], :gid=>["1000"], :password=>["blah"], :comment=>["t u"]}
provider_class.manager.expects(:search).returns([low, high])
resource = stub 'resource', :should => %w{whatever}
@@ -79,7 +69,22 @@ describe provider_class do
instance = provider_class.new(:name => "luke", :ensure => :absent)
instance.stubs(:resource).returns resource
- @connection.expects(:add).with { |dn, attrs| attrs["uidNumber"] == ["141"] }
+ @connection.expects(:add).with { |dn, attrs| attrs["uidNumber"] == ["641"] }
+
+ instance.create
+ instance.flush
+ end
+
+ it "should pick 501 of no users exist" do
+ provider_class.manager.expects(:search).returns nil
+
+ resource = stub 'resource', :should => %w{whatever}
+ resource.stubs(:should).with(:uid).returns nil
+ resource.stubs(:should).with(:ensure).returns :present
+ instance = provider_class.new(:name => "luke", :ensure => :absent)
+ instance.stubs(:resource).returns resource
+
+ @connection.expects(:add).with { |dn, attrs| attrs["uidNumber"] == ["501"] }
instance.create
instance.flush