diff options
| -rw-r--r-- | lib/puppet/indirector/ldap/node.rb | 7 | ||||
| -rwxr-xr-x | spec/unit/indirector/ldap/node.rb | 11 |
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}) |
