summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-10-04 16:55:15 -0500
committerLuke Kanies <luke@madstop.com>2007-10-04 16:55:15 -0500
commita93db8728ddc9a4b26dec738ff39863666ea229e (patch)
treeedcfef3751e41451b51961e1cf17b7d9a8fdcdc5
parent9984a3520dd061acec98495ddd5a21b6126376f4 (diff)
downloadpuppet-a93db8728ddc9a4b26dec738ff39863666ea229e.tar.gz
puppet-a93db8728ddc9a4b26dec738ff39863666ea229e.tar.xz
puppet-a93db8728ddc9a4b26dec738ff39863666ea229e.zip
Adding another test to the ldap node source -- we make
sure we throw an appropriate exception if a parent is specified but we cannot find it.
-rw-r--r--lib/puppet/indirector/ldap/node.rb7
-rwxr-xr-xspec/unit/indirector/ldap/node.rb11
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/puppet/indirector/ldap/node.rb b/lib/puppet/indirector/ldap/node.rb
index 6f35b575c..2e800abbe 100644
--- a/lib/puppet/indirector/ldap/node.rb
+++ b/lib/puppet/indirector/ldap/node.rb
@@ -21,8 +21,11 @@ class Puppet::Indirector::Ldap::Node < Puppet::Indirector::Ldap
raise ArgumentError, "Found loop in LDAP node parents; %s appears twice" % parent
end
parents << parent
- ldapsearch(parent) do |entry|
- parent_info = process(parent, entry)
+
+ ldapsearch(parent) { |entry| parent_info = process(parent, entry) }
+
+ unless parent_info
+ raise Puppet::Error.new("Could not find parent node '%s'" % parent)
end
information[:classes] += parent_info[:classes]
parent_info[:parameters].each do |param, value|
diff --git a/spec/unit/indirector/ldap/node.rb b/spec/unit/indirector/ldap/node.rb
index 739a2a5b0..6667efdd5 100755
--- a/spec/unit/indirector/ldap/node.rb
+++ b/spec/unit/indirector/ldap/node.rb
@@ -82,7 +82,7 @@ describe Puppet::Indirector::Ldap::Node, " when searching for nodes" do
end
end
-describe Puppet::Indirector::Ldap::Node, " when a parent node exists" do
+describe Puppet::Indirector::Ldap::Node, " when a parent node is specified" do
include LdapNodeSearching
before do
@@ -99,6 +99,15 @@ describe Puppet::Indirector::Ldap::Node, " when a parent node exists" do
@searcher.stubs(:parent_attribute).returns(:parent)
end
+ it "should fail if the parent cannot be found" do
+ @connection.stubs(:search).with { |*args| args[2] == 'parent' }.returns("whatever")
+
+ @entry.stubs(:to_hash).returns({})
+ @entry.stubs(:vals).with(:parent).returns(%w{parent})
+
+ proc { @searcher.find("mynode") }.should raise_error(Puppet::Error)
+ end
+
it "should add any parent classes to the node's classes" do
@entry.stubs(:to_hash).returns({})
@entry.stubs(:vals).with(:parent).returns(%w{parent})