diff options
author | Luke Kanies <luke@madstop.com> | 2008-07-04 22:14:37 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-07-04 22:14:37 -0500 |
commit | b0febd263c0cb8e61d512898f7c79868ea77e619 (patch) | |
tree | 3f35c4b2d7186d3c69c070c9edc684ccdc51f658 /spec/unit/indirector | |
parent | df528a66cafc8538c3208bf0b52fdbe1065f6e48 (diff) | |
parent | 81be1c5c3f85f514505e99fab5b8a2b2ae6fbec8 (diff) | |
download | puppet-b0febd263c0cb8e61d512898f7c79868ea77e619.tar.gz puppet-b0febd263c0cb8e61d512898f7c79868ea77e619.tar.xz puppet-b0febd263c0cb8e61d512898f7c79868ea77e619.zip |
Merge branch '0.24.x'
Conflicts:
lib/puppet/util/settings.rb
spec/integration/defaults.rb
spec/unit/node/catalog.rb
spec/unit/type/interface.rb
spec/unit/type/ssh_authorized_key.rb
Diffstat (limited to 'spec/unit/indirector')
-rwxr-xr-x | spec/unit/indirector/node/ldap.rb | 36 | ||||
-rwxr-xr-x | spec/unit/indirector/yaml.rb | 15 |
2 files changed, 47 insertions, 4 deletions
diff --git a/spec/unit/indirector/node/ldap.rb b/spec/unit/indirector/node/ldap.rb index 01d148631..ed8809e73 100755 --- a/spec/unit/indirector/node/ldap.rb +++ b/spec/unit/indirector/node/ldap.rb @@ -136,6 +136,14 @@ describe Puppet::Node::Ldap do @searcher.stubs(:name2hash).returns @result 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 + + Puppet::Node.expects(:new).with("mynode.domain.com").returns @node + @searcher.find(@request) + end + it "should add any classes from ldap" do @result[:classes] = %w[a b c d] @node.expects(:classes=).with(%w{a b c d}) @@ -161,6 +169,19 @@ describe Puppet::Node::Ldap do @searcher.find(@request) end + it "should merge the node's facts after the parameters from ldap are assigned" do + # Make sure we've got data to start with, so the parameters are actually set. + @result[:parameters] = {} + @result[:parameters]["one"] = "yay" + + # A hackish way to enforce order. + set = false + @node.expects(:parameters=).with { |*args| set = true } + @node.expects(:fact_merge).with { |*args| raise "Facts were merged before parameters were set" unless set; true } + + @searcher.find(@request) + end + describe "and a parent node is specified" do before do @entry = {:classes => [], :parameters => {}} @@ -304,13 +325,22 @@ describe Puppet::Node::Ldap do @searcher.search @request end - it "should return a node for each processed entry" do - @searcher.expects(:ldapsearch).yields("one") - @searcher.expects(:entry2hash).with("one").returns(:name => "foo") + it "should return a node for each processed entry with the name from the entry" do + @searcher.expects(:ldapsearch).yields("whatever") + @searcher.expects(:entry2hash).with("whatever").returns(:name => "foo") result = @searcher.search(@request) result[0].should be_instance_of(Puppet::Node) result[0].name.should == "foo" end + + it "should merge each node's facts" do + node = mock 'node' + Puppet::Node.expects(:new).with("foo").returns node + node.expects(:fact_merge) + @searcher.stubs(:ldapsearch).yields("one") + @searcher.stubs(:entry2hash).with("one").returns(:name => "foo") + @searcher.search(@request) + end end end diff --git a/spec/unit/indirector/yaml.rb b/spec/unit/indirector/yaml.rb index 53d12f426..3875d70aa 100755 --- a/spec/unit/indirector/yaml.rb +++ b/spec/unit/indirector/yaml.rb @@ -20,12 +20,25 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do @subject.name = :me @dir = "/what/ever" - Puppet.settings.stubs(:value).with(:yamldir).returns(@dir) + Puppet.settings.stubs(:value).returns("fakesettingdata") + Puppet.settings.stubs(:value).with(:clientyamldir).returns(@dir) @request = stub 'request', :key => :me, :instance => @subject end describe Puppet::Indirector::Yaml, " when choosing file location" do + it "should use the yamldir if the process name is 'puppetmasterd'" do + Puppet.settings.expects(:value).with(:name).returns "puppetmasterd" + Puppet.settings.expects(:value).with(:yamldir).returns "/main/yaml/dir" + @store.path(:me).should =~ %r{^/main/yaml/dir} + end + + it "should use the client yamldir if the process name is not 'puppetmasterd'" do + Puppet.settings.expects(:value).with(:name).returns "cient" + Puppet.settings.expects(:value).with(:clientyamldir).returns "/client/yaml/dir" + @store.path(:me).should =~ %r{^/client/yaml/dir} + end + it "should store all files in a single file root set in the Puppet defaults" do @store.path(:me).should =~ %r{^#{@dir}} end |