0
@@ -17,6 +17,7 @@ describe Puppet::Node::Ldap do
0
@searcher.stubs(:connection).returns(@connection)
0
@searcher.stubs(:class_attributes).returns([])
0
@searcher.stubs(:parent_attribute).returns(nil)
0
+ @searcher.stubs(:stacked_attributes).returns([])
0
@searcher.stubs(:search_base).returns(:yay)
0
@searcher.stubs(:search_filter).returns(:filter)
0
@@ -195,6 +196,96 @@ describe Puppet::Node::Ldap do
0
proc { @searcher.find(@request) }.should raise_error(ArgumentError)
0
+ describe "and a puppet variable is specified" do
0
+ @searcher.stubs(:stacked_attributes).returns(['puppetvar'])
0
+ it "should add the variable to the node parameters" do
0
+ @entry.stubs(:vals).with("puppetvar").returns(%w{one=two})
0
+ @entry.stubs(:to_hash).returns({})
0
+ @node.expects(:parameters=).with("one" => "two")
0
+ @searcher.find(@request)
0
+ it "should not overwrite node parameters specified as ldap object attribute" do
0
+ @entry.stubs(:vals).with("puppetvar").returns(%w{one=two})
0
+ @entry.stubs(:to_hash).returns("one" => "three")
0
+ @node.expects(:parameters=).with("one" => "three")
0
+ @searcher.find(@request)
0
+ it "should set entries without an equal sign to nil" do
0
+ @entry.stubs(:vals).with("puppetvar").returns(%w{one})
0
+ @entry.stubs(:to_hash).returns({})
0
+ @node.expects(:parameters=).with("one" => nil)
0
+ @searcher.find(@request)
0
+ it "should ignore empty entries" do
0
+ @entry.stubs(:vals).with("puppetvar").returns(%w{})
0
+ @entry.stubs(:to_hash).returns({})
0
+ @searcher.find(@request)
0
+ describe "and a puppet variable as well as a parent node are specified" do
0
+ @parent = mock 'parent'
0
+ @searcher.meta_def(:search_filter) do |name|
0
+ @connection.stubs(:search).with { |*args| args[2] == @name }.yields(@entry)
0
+ @connection.stubs(:search).with { |*args| args[2] == 'parent' }.yields(@parent)
0
+ @searcher.stubs(:stacked_attributes).returns(['puppetvar'])
0
+ @searcher.stubs(:parent_attribute).returns(:parent)
0
+ it "should add parent node variables to the child node parameters" do
0
+ @parent.stubs(:to_hash).returns({})
0
+ @parent.stubs(:vals).with("puppetvar").returns(%w{one=two})
0
+ @parent.stubs(:vals).with(:parent).returns(nil)
0
+ @entry.stubs(:to_hash).returns({})
0
+ @entry.stubs(:vals).with("puppetvar").returns(%w{})
0
+ @entry.stubs(:vals).with(:parent).returns(%w{parent})
0
+ @node.expects(:parameters=).with("one" => "two")
0
+ @searcher.find(@request)
0
+ it "should overwrite parent node variables with child node parameters" do
0
+ @parent.stubs(:to_hash).returns({})
0
+ @parent.stubs(:vals).with("puppetvar").returns(%w{one=two})
0
+ @parent.stubs(:vals).with(:parent).returns(nil)
0
+ @entry.stubs(:to_hash).returns({})
0
+ @entry.stubs(:vals).with("puppetvar").returns(%w{one=three})
0
+ @entry.stubs(:vals).with(:parent).returns(%w{parent})
0
+ @node.expects(:parameters=).with("one" => "three")
0
+ @searcher.find(@request)
0
+ it "should not overwrite parent node parameters specified as ldap object attribute" do
0
+ @parent.stubs(:to_hash).returns("one" => "three")
0
+ @parent.stubs(:vals).with("puppetvar").returns(%w{})
0
+ @parent.stubs(:vals).with(:parent).returns(nil)
0
+ @entry.stubs(:vals).with("puppetvar").returns(%w{one=two})
0
+ @entry.stubs(:to_hash).returns({})
0
+ @entry.stubs(:vals).with(:parent).returns(%w{parent})
0
+ @node.expects(:parameters=).with("one" => "three")
0
+ @searcher.find(@request)