diff options
author | Luke Kanies <luke@madstop.com> | 2008-05-26 17:41:38 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-05-26 17:41:38 -0500 |
commit | 02411f5d74e9f437acdba9c75eb811b9976174c7 (patch) | |
tree | a019b22b9cb13466716d4fd5f7a8bfde1bcfa89e /test | |
parent | 7b02f2ba443ba35d7305c24b87028456eaf6bd29 (diff) | |
download | puppet-02411f5d74e9f437acdba9c75eb811b9976174c7.tar.gz puppet-02411f5d74e9f437acdba9c75eb811b9976174c7.tar.xz puppet-02411f5d74e9f437acdba9c75eb811b9976174c7.zip |
Always using the cert name to store yaml files, which fixes #1178.
The Master handler previously provided the support for the :node_name
setting, and that functionality has now been moved into the Node
class. At the same time, the names to search through have been
changed somewhat: Previously, the certificate name and the
hostname were both used for searching, but now, the cert name
is always searched first (unless node_name == facter), but only
the Facter hostname, domain, and fqdn are used otherwise. We no
longer split the cert name, only the hostname/domain/fqdn.
In the general case, this provides no behaviour change, because
people's hostname is the same as their certname. This only
results in a change in behaviour if you specify a certificate
name that is a normal node name, and you want to look that node
up by something other than the full name in the certificate.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'test')
-rwxr-xr-x | test/network/client/master.rb | 14 | ||||
-rwxr-xr-x | test/network/handler/master.rb | 86 |
2 files changed, 37 insertions, 63 deletions
diff --git a/test/network/client/master.rb b/test/network/client/master.rb index dc2140e62..9f71247fa 100755 --- a/test/network/client/master.rb +++ b/test/network/client/master.rb @@ -472,17 +472,8 @@ end Puppet::Node::Facts.indirection.stubs(:save) - master = client = nil - assert_nothing_raised() { - master = Puppet::Network::Handler.master.new( - :Local => false - ) - } - assert_nothing_raised() { - client = Puppet::Network::Client.master.new( - :Master => master - ) - } + master = Puppet::Network::Handler.master.new( :Local => false) + client = Puppet::Network::Client.master.new( :Master => master) # Fake that it's local, so it creates the class file client.local = false @@ -491,6 +482,7 @@ end client.expects(:setclasses).with do |array| array.length == 2 and array.include?("yaytest") and array.include?("bootest") end + assert_nothing_raised { client.getconfig } diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb index e91ec2f47..448667b73 100755 --- a/test/network/handler/master.rb +++ b/test/network/handler/master.rb @@ -8,69 +8,51 @@ require 'puppet/network/handler/master' class TestMaster < Test::Unit::TestCase include PuppetTest::ServerTest + def setup + super + @master = Puppet::Network::Handler.master.new(:Manifest => tempfile) + + @catalog = stub 'catalog', :extract => "" + Puppet::Node::Catalog.stubs(:find).returns(@catalog) + end + def teardown super Puppet::Indirector::Indirection.clear_cache end def test_freshness_is_always_now - master = Puppet::Network::Handler.master.new( - :Manifest => tempfile, - :UseNodes => true, - :Local => true - ) - now1 = mock 'now1' Time.expects(:now).returns(now1) - assert_equal(master.freshness, now1, "Did not return current time as freshness") + assert_equal(@master.freshness, now1, "Did not return current time as freshness") end - # Make sure we're correctly doing clientname manipulations. - # Testing to make sure we always get a hostname and IP address. - def test_clientname - # create our master - master = Puppet::Network::Handler.master.new( - :Manifest => tempfile, - :UseNodes => true, - :Local => true - ) - - - # First check that 'cert' works - Puppet[:node_name] = "cert" - - # Make sure we get the fact data back when nothing is set - facts = { - "hostname" => "fact_hostname", - "domain" => "fact_domain", - "fqdn" => "fact_hostname.fact_domain", - "ipaddress" => "fact_ip" - } - certhostname = "cert_hostname" - certdomain = "cert_domain" - certname = certhostname + "." + certdomain - certip = "cert_ip" - - resname, resip = master.send(:clientname, nil, nil, facts) - assert_equal(facts["hostname"], resname, "Did not use fact hostname when no certname was present") - assert_equal(facts["ipaddress"], resip, "Did not use fact ip when no certname was present") - assert_equal(facts["domain"], "fact_domain", "Did not use fact domain when no certname was present") - assert_equal(facts["fqdn"], "fact_hostname.fact_domain", "Did not use fact fqdn when no certname was present") - - # Now try it with the cert stuff present - resname, resip = master.send(:clientname, certname, certip, facts) - assert_equal(certname, resname, "Did not use cert hostname when certname was present") - assert_equal(certip, resip, "Did not use cert ip when certname was present") - assert_equal(facts["domain"], certdomain, "Did not use cert domain when certname was present") - assert_equal(facts["fqdn"], certname, "Did not use cert fqdn when certname was present") - - # And reset the node_name stuff and make sure we use it. - Puppet[:node_name] = :facter - resname, resip = master.send(:clientname, certname, certip, facts) - assert_equal(facts["hostname"], resname, "Did not use fact hostname when nodename was set to facter") - assert_equal(facts["ipaddress"], resip, "Did not use fact ip when nodename was set to facter") + def test_hostname_is_used_if_client_is_missing + @master.expects(:decode_facts).returns("hostname" => "yay") + Puppet::Node::Facts.expects(:new).with { |name, facts| name == "yay" }.returns(stub('facts', :save => nil)) + + @master.getconfig("facts") end -end + def test_facts_are_saved + facts = mock('facts') + Puppet::Node::Facts.expects(:new).returns(facts) + facts.expects(:save) + + @master.stubs(:decode_facts) + @master.getconfig("facts", "yaml", "foo.com") + end + + def test_catalog_is_used_for_compiling + facts = stub('facts', :save => nil) + Puppet::Node::Facts.stubs(:new).returns(facts) + + @master.stubs(:decode_facts) + + Puppet::Node::Catalog.expects(:find).with("foo.com").returns(@catalog) + + @master.getconfig("facts", "yaml", "foo.com") + end +end |