diff options
| author | Jesse Wolfe <jes5199@gmail.com> | 2010-06-23 15:19:36 -0700 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | e6709da4fed6e671dab5af0db3cb87da5b27555e (patch) | |
| tree | 79beda77f8b9b89fd574f9373b58fd1372038a28 /spec/unit/indirector/node | |
| parent | a7884b4707355ed2f4e052e7d760cce773442df1 (diff) | |
| download | puppet-e6709da4fed6e671dab5af0db3cb87da5b27555e.tar.gz puppet-e6709da4fed6e671dab5af0db3cb87da5b27555e.tar.xz puppet-e6709da4fed6e671dab5af0db3cb87da5b27555e.zip | |
[#3409] fix test failures from ldap environment patch
Diffstat (limited to 'spec/unit/indirector/node')
| -rwxr-xr-x | spec/unit/indirector/node/ldap.rb | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/spec/unit/indirector/node/ldap.rb b/spec/unit/indirector/node/ldap.rb index 953a8c2b2..6f53b6ccf 100755 --- a/spec/unit/indirector/node/ldap.rb +++ b/spec/unit/indirector/node/ldap.rb @@ -23,16 +23,17 @@ describe Puppet::Node::Ldap do end it "should convert the hostname into a search filter" do - entry = stub 'entry', :dn => 'cn=mynode.domain.com,ou=hosts,dc=madstop,dc=com', :vals => %w{}, :to_hash => {} + entry = stub 'entry', :dn => 'cn=mynode.domain.com,ou=hosts,dc=madstop,dc=com', :vals => %w{}, :to_hash => {"environment" => 'production'} @searcher.expects(:ldapsearch).with("(&(objectclass=puppetClient)(cn=#{@name}))").yields entry - @searcher.name2hash(@name) + @searcher.name2hash(@name, 'production', 'parent') end it "should convert any found entry into a hash" do - entry = stub 'entry', :dn => 'cn=mynode.domain.com,ou=hosts,dc=madstop,dc=com', :vals => %w{}, :to_hash => {} + entry = stub 'entry', :dn => 'cn=mynode.domain.com,ou=hosts,dc=madstop,dc=com', :vals => %w{}, :to_hash => {"environment" => 'production'} @searcher.expects(:ldapsearch).with("(&(objectclass=puppetClient)(cn=#{@name}))").yields entry - @searcher.expects(:entry2hash).with(entry).returns "myhash" - @searcher.name2hash(@name).should == "myhash" + myhash = {"myhash" => true, :environment => 'production'} + @searcher.expects(:entry2hash).with(entry).returns myhash + @searcher.name2hash(@name, 'production', 'parent').should == myhash end # This heavily tests our entry2hash method, so we don't have to stub out the stupid entry information any more. @@ -127,20 +128,20 @@ describe Puppet::Node::Ldap do end it "should search first for the provided key" do - @searcher.expects(:name2hash).with("mynode.domain.com").returns({}) + @searcher.expects(:name2hash).with("mynode.domain.com", 'production', 'child').returns({}) @searcher.find(@request) end it "should search for the short version of the provided key if the key looks like a hostname and no results are found for the key itself" do - @searcher.expects(:name2hash).with("mynode.domain.com").returns(nil) - @searcher.expects(:name2hash).with("mynode").returns({}) + @searcher.expects(:name2hash).with("mynode.domain.com", 'production', 'child').returns(nil) + @searcher.expects(:name2hash).with("mynode", 'production', 'child').returns({}) @searcher.find(@request) end it "should search for default information if no information can be found for the key" do - @searcher.expects(:name2hash).with("mynode.domain.com").returns(nil) - @searcher.expects(:name2hash).with("mynode").returns(nil) - @searcher.expects(:name2hash).with("default").returns({}) + @searcher.expects(:name2hash).with("mynode.domain.com", 'production', 'child').returns(nil) + @searcher.expects(:name2hash).with("mynode", 'production', 'child').returns(nil) + @searcher.expects(:name2hash).with("default", 'production', 'child').returns({}) @searcher.find(@request) end @@ -161,8 +162,8 @@ describe Puppet::Node::Ldap do end it "should create the node with the correct name, even if it was found by a different name" do - @searcher.expects(:name2hash).with("mynode.domain.com").returns nil - @searcher.expects(:name2hash).with("mynode").returns @result + @searcher.expects(:name2hash).with("mynode.domain.com", 'production', 'child').returns nil + @searcher.expects(:name2hash).with("mynode", 'production', 'child').returns @result Puppet::Node.expects(:new).with("mynode.domain.com").returns @node @searcher.find(@request) @@ -212,9 +213,9 @@ describe Puppet::Node::Ldap do @parent = {:classes => [], :parameters => {}} @parent_parent = {:classes => [], :parameters => {}} - @searcher.stubs(:name2hash).with(@name).returns(@entry) - @searcher.stubs(:name2hash).with('parent').returns(@parent) - @searcher.stubs(:name2hash).with('parent_parent').returns(@parent_parent) + @searcher.stubs(:name2hash).with{|name, env, mode| name == @name}.returns(@entry) + @searcher.stubs(:name2hash).with{|name, env, mode| name == 'parent'}.returns(@parent) + @searcher.stubs(:name2hash).with{|name, env, mode| name == 'parent_parent'}.returns(@parent_parent) @searcher.stubs(:parent_attribute).returns(:parent) end @@ -222,16 +223,13 @@ describe Puppet::Node::Ldap do it "should search for the parent node" do @entry[:parent] = "parent" - @searcher.expects(:name2hash).with(@name).returns @entry - @searcher.expects(:name2hash).with('parent').returns @parent - @searcher.find(@request) end it "should fail if the parent cannot be found" do @entry[:parent] = "parent" - @searcher.expects(:name2hash).with('parent').returns nil + @searcher.expects(:name2hash).with('parent', 'production', 'parent').returns nil proc { @searcher.find(@request) }.should raise_error(Puppet::Error) end |
