diff options
| author | Luke Kanies <luke@madstop.com> | 2008-03-31 23:56:09 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-03-31 23:56:09 -0500 |
| commit | 88dc49cb7b0efe757c92ce28c807b91335acb07a (patch) | |
| tree | 13fe4561f1f524f97a8bb2c1ff84c1ef981d0241 /test/network | |
| parent | 4165edaeb71ee2883b1bb85ff39a52d5628b259f (diff) | |
| parent | a8592f1009040ebf30a98268610915cc33bb3f63 (diff) | |
| download | puppet-88dc49cb7b0efe757c92ce28c807b91335acb07a.tar.gz puppet-88dc49cb7b0efe757c92ce28c807b91335acb07a.tar.xz puppet-88dc49cb7b0efe757c92ce28c807b91335acb07a.zip | |
Merge branch 'master' into master_no_global_resources
Conflicts:
lib/puppet/node/catalog.rb
lib/puppet/type/pfile.rb
lib/puppet/type/pfilebucket.rb
lib/puppet/util/filetype.rb
spec/unit/node/catalog.rb
spec/unit/other/transbucket.rb
spec/unit/ral/provider/mount/parsed.rb
spec/unit/ral/types/file.rb
spec/unit/ral/types/interface.rb
spec/unit/ral/types/mount.rb
spec/unit/ral/types/package.rb
spec/unit/ral/types/schedule.rb
spec/unit/ral/types/service.rb
test/language/compile.rb
test/language/lexer.rb
test/language/snippets.rb
test/lib/puppettest.rb
test/ral/types/basic.rb
test/ral/types/cron.rb
test/ral/types/exec.rb
test/ral/types/file.rb
test/ral/types/file/target.rb
test/ral/types/filebucket.rb
test/ral/types/fileignoresource.rb
test/ral/types/filesources.rb
test/ral/types/group.rb
test/ral/types/host.rb
test/ral/types/parameter.rb
test/ral/types/sshkey.rb
test/ral/types/tidy.rb
test/ral/types/user.rb
test/ral/types/yumrepo.rb
Diffstat (limited to 'test/network')
| -rwxr-xr-x | test/network/client/client.rb | 29 | ||||
| -rwxr-xr-x | test/network/client/master.rb | 41 | ||||
| -rwxr-xr-x | test/network/handler/fileserver.rb | 100 | ||||
| -rwxr-xr-x | test/network/handler/master.rb | 15 | ||||
| -rwxr-xr-x | test/network/server/webrick.rb | 2 |
5 files changed, 106 insertions, 81 deletions
diff --git a/test/network/client/client.rb b/test/network/client/client.rb index b6b915d31..5f96cac11 100755 --- a/test/network/client/client.rb +++ b/test/network/client/client.rb @@ -140,35 +140,6 @@ class TestClient < Test::Unit::TestCase } end - def test_classfile - Puppet[:code] = "class yaytest {}\n class bootest {}\n include yaytest, bootest" - - 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 - ) - } - - # Fake that it's local, so it creates the class file - client.local = false - - # We can't guarantee class ordering - client.expects(:setclasses).with do |array| - array.length == 2 and array.include?("yaytest") and array.include?("bootest") - end - assert_nothing_raised { - client.getconfig - } - end - def test_client_loading # Make sure we don't get a failure but that we also get nothing back assert_nothing_raised do diff --git a/test/network/client/master.rb b/test/network/client/master.rb index 48be3cafa..682d48eb5 100755 --- a/test/network/client/master.rb +++ b/test/network/client/master.rb @@ -211,6 +211,16 @@ end "Lost value to hostname") end + # Make sure that setting environment by fact takes precedence to configuration + def test_setenvironmentwithfact + name = "environment" + value = "test_environment" + + Facter.stubs(:to_hash).returns(name => value) + + assert_equal(value, Puppet::Network::Client.master.facts[name]) + end + # Make sure we load all facts on startup. def test_loadfacts dirs = [tempfile(), tempfile()] @@ -339,6 +349,8 @@ end File.open(source, "w") { |f| f.puts "something" } dest = tempfile Puppet[:noop] = true + node = stub 'node', :environment => "development" + Puppet::Node.stubs(:find).returns node assert_nothing_raised("Could not download in noop") do @master.download(:dest => dest, :source => source, :tag => "yay") end @@ -546,4 +558,33 @@ end # Doesn't throw an exception, but definitely fails. client.run end + + def test_classfile + Puppet[:code] = "class yaytest {}\n class bootest {}\n include yaytest, bootest" + + 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 + ) + } + + # Fake that it's local, so it creates the class file + client.local = false + + # We can't guarantee class ordering + client.expects(:setclasses).with do |array| + array.length == 2 and array.include?("yaytest") and array.include?("bootest") + end + assert_nothing_raised { + client.getconfig + } + end end diff --git a/test/network/handler/fileserver.rb b/test/network/handler/fileserver.rb index e4b1ac3df..b3a9aef2b 100755 --- a/test/network/handler/fileserver.rb +++ b/test/network/handler/fileserver.rb @@ -109,13 +109,13 @@ class TestFileServer < Test::Unit::TestCase # and verify different iterations of 'root' return the same value list = nil assert_nothing_raised { - list = server.list("/test/", :ignore, true, false) + list = server.list("/test/", :manage, true, false) } assert(list =~ pattern) assert_nothing_raised { - list = server.list("/test", :ignore, true, false) + list = server.list("/test", :manage, true, false) } assert(list =~ pattern) @@ -143,7 +143,7 @@ class TestFileServer < Test::Unit::TestCase list = nil sfile = "/test/tmpfile" assert_nothing_raised { - list = server.list(sfile, :ignore, true, false) + list = server.list(sfile, :manage, true, false) } output = "/\tfile" @@ -196,7 +196,7 @@ class TestFileServer < Test::Unit::TestCase list = nil sfile = "/test/" assert_nothing_raised { - list = server.list(sfile, :ignore, true, false) + list = server.list(sfile, :manage, true, false) } # create the new file @@ -206,7 +206,7 @@ class TestFileServer < Test::Unit::TestCase newlist = nil assert_nothing_raised { - newlist = server.list(sfile, :ignore, true, false) + newlist = server.list(sfile, :manage, true, false) } # verify the list has changed @@ -235,12 +235,12 @@ class TestFileServer < Test::Unit::TestCase list = nil assert_nothing_raised { - list = server.list("/root/" + testdir, :ignore, true, false) + list = server.list("/root/" + testdir, :manage, true, false) } assert(list =~ pattern) assert_nothing_raised { - list = server.list("/root" + testdir, :ignore, true, false) + list = server.list("/root" + testdir, :manage, true, false) } assert(list =~ pattern) @@ -275,7 +275,7 @@ class TestFileServer < Test::Unit::TestCase # get our list list = nil assert_nothing_raised { - list = server.list("/test/with", :ignore, false, false) + list = server.list("/test/with", :manage, false, false) } # make sure we only got one line, since we're not recursing @@ -284,7 +284,7 @@ class TestFileServer < Test::Unit::TestCase # for each level of recursion, make sure we get the right list [0, 1, 2].each { |num| assert_nothing_raised { - list = server.list("/test/with", :ignore, num, false) + list = server.list("/test/with", :manage, num, false) } count = 0 @@ -328,13 +328,13 @@ class TestFileServer < Test::Unit::TestCase list = nil # and then check a few dirs assert_nothing_raised { - list = server.list("/localhost/with", :ignore, false, false) + list = server.list("/localhost/with", :manage, false, false) } assert(list !~ /with/) assert_nothing_raised { - list = server.list("/localhost/with/some/sub", :ignore, true, false) + list = server.list("/localhost/with/some/sub", :manage, true, false) } assert(list !~ /sub/) @@ -366,7 +366,7 @@ class TestFileServer < Test::Unit::TestCase list = nil assert_nothing_raised { - list = server.list("/localhost/", :ignore, 1, false) + list = server.list("/localhost/", :manage, 1, false) } assert_instance_of(String, list, "Server returned %s instead of string") list = list.split("\n") @@ -398,7 +398,7 @@ class TestFileServer < Test::Unit::TestCase list = nil sfile = "/test/" assert_nothing_raised { - list = server.list(sfile, :ignore, true, false) + list = server.list(sfile, :manage, true, false) } # and describe each file in the list @@ -488,7 +488,7 @@ class TestFileServer < Test::Unit::TestCase mounts.each { |mount, files| mount = "/#{mount}/" assert_nothing_raised { - list = server.list(mount, :ignore, true, false) + list = server.list(mount, :manage, true, false) } assert_nothing_raised { @@ -540,12 +540,12 @@ class TestFileServer < Test::Unit::TestCase assert_raise(Puppet::AuthorizationError, "Host %s, ip %s, allowed %s" % [host, ip, mount]) { - list = server.list(mount, :ignore, true, false, host, ip) + list = server.list(mount, :manage, true, false, host, ip) } when :allow: assert_nothing_raised("Host %s, ip %s, denied %s" % [host, ip, mount]) { - list = server.list(mount, :ignore, true, false, host, ip) + list = server.list(mount, :manage, true, false, host, ip) } end } @@ -598,7 +598,7 @@ class TestFileServer < Test::Unit::TestCase assert_raise(Puppet::Network::Handler::FileServerError, "Invalid mount was mounted") { - server.list(mount, :ignore) + server.list(mount, :manage) } } @@ -650,13 +650,13 @@ class TestFileServer < Test::Unit::TestCase list = nil assert_nothing_raised { - list = server.list("/thing/", :ignore, false, false, + list = server.list("/thing/", :manage, false, false, "test1.domain.com", "127.0.0.1") } assert(list != "", "List returned nothing in rereard test") assert_raise(Puppet::AuthorizationError, "List allowed invalid host") { - list = server.list("/thing/", :ignore, false, false, + list = server.list("/thing/", :manage, false, false, "test2.domain.com", "127.0.0.1") } @@ -671,12 +671,12 @@ class TestFileServer < Test::Unit::TestCase } assert_raise(Puppet::AuthorizationError, "List allowed invalid host") { - list = server.list("/thing/", :ignore, false, false, + list = server.list("/thing/", :manage, false, false, "test1.domain.com", "127.0.0.1") } assert_nothing_raised { - list = server.list("/thing/", :ignore, false, false, + list = server.list("/thing/", :manage, false, false, "test2.domain.com", "127.0.0.1") } @@ -731,7 +731,7 @@ class TestFileServer < Test::Unit::TestCase # Then not results = {} assert_nothing_raised { - server.describe("/mount/link", :ignore).split("\t").zip( + server.describe("/mount/link", :manage).split("\t").zip( Puppet::Network::Handler.fileserver::CHECKPARAMS ).each { |v,p| results[p] = v } } @@ -797,28 +797,28 @@ allow * list = nil sfile = "/host/file.txt" assert_nothing_raised { - list = server.list(sfile, :ignore, true, false, client1, ip) + list = server.list(sfile, :manage, true, false, client1, ip) } assert_equal("/\tfile", list) assert_nothing_raised { - list = server.list(sfile, :ignore, true, false, client2, ip) + list = server.list(sfile, :manage, true, false, client2, ip) } assert_equal("", list) sfile = "/fqdn/file.txt" assert_nothing_raised { - list = server.list(sfile, :ignore, true, false, client1, ip) + list = server.list(sfile, :manage, true, false, client1, ip) } assert_equal("", list) assert_nothing_raised { - list = server.list(sfile, :ignore, true, false, client2, ip) + list = server.list(sfile, :manage, true, false, client2, ip) } assert_equal("/\tfile", list) # check describe sfile = "/host/file.txt" assert_nothing_raised { - list = server.describe(sfile, :ignore, client1, ip).split("\t") + list = server.describe(sfile, :manage, client1, ip).split("\t") } assert_equal(5, list.size) assert_equal("file", list[1]) @@ -826,18 +826,18 @@ allow * assert_equal("{md5}#{md5}", list[4]) assert_nothing_raised { - list = server.describe(sfile, :ignore, client2, ip).split("\t") + list = server.describe(sfile, :manage, client2, ip).split("\t") } assert_equal([], list) sfile = "/fqdn/file.txt" assert_nothing_raised { - list = server.describe(sfile, :ignore, client1, ip).split("\t") + list = server.describe(sfile, :manage, client1, ip).split("\t") } assert_equal([], list) assert_nothing_raised { - list = server.describe(sfile, :ignore, client2, ip).split("\t") + list = server.describe(sfile, :manage, client2, ip).split("\t") } assert_equal(5, list.size) assert_equal("file", list[1]) @@ -847,23 +847,23 @@ allow * # Check retrieve sfile = "/host/file.txt" assert_nothing_raised { - list = server.retrieve(sfile, :ignore, client1, ip).chomp + list = server.retrieve(sfile, :manage, client1, ip).chomp } assert_equal(contents[client1_hostdir].chomp, list) assert_nothing_raised { - list = server.retrieve(sfile, :ignore, client2, ip).chomp + list = server.retrieve(sfile, :manage, client2, ip).chomp } assert_equal("", list) sfile = "/fqdn/file.txt" assert_nothing_raised { - list = server.retrieve(sfile, :ignore, client1, ip).chomp + list = server.retrieve(sfile, :manage, client1, ip).chomp } assert_equal("", list) assert_nothing_raised { - list = server.retrieve(sfile, :ignore, client2, ip).chomp + list = server.retrieve(sfile, :manage, client2, ip).chomp } assert_equal(contents[client2_fqdndir].chomp, list) end @@ -941,12 +941,14 @@ allow * # Now, check that they use Facter info Puppet.notice "The following messages are normal" client = nil - local = Facter["hostname"].value - domain = Facter["domain"].value - fqdn = [local, domain].join(".") - {"%h" => local, # Short name - "%H" => fqdn, # Full name - "%d" => domain, # domain + Facter.stubs(:value).with(:ipaddress).returns("127.0.0.1") + Facter.stubs(:value).with { |v| v.to_s == "hostname" }.returns("myhost") + Facter.stubs(:value).with { |v| v.to_s == "domain" }.returns("mydomain.com") + Facter.stubs(:value).with(:domain).returns("mydomain.com") + + {"%h" => "myhost", # Short name + "%H" => "myhost.mydomain.com", # Full name + "%d" => "mydomain.com", # domain "%%" => "%", # escape "%o" => "%o" # other }.each do |pat, repl| @@ -989,18 +991,18 @@ allow * ret = nil assert_nothing_raised do - ret = server.list("/name", :ignore, false, false, host, ip) + ret = server.list("/name", :manage, false, false, host, ip) end assert_equal("/\tfile", ret) assert_nothing_raised do - ret = server.describe("/name", :ignore, host, ip) + ret = server.describe("/name", :manage, host, ip) end - assert(ret =~ /\tfile\t/, "Did not get valid a description") + assert(ret =~ /\tfile\t/, "Did not get valid a description (#{ret.inspect})") assert_nothing_raised do - ret = server.retrieve("/name", :ignore, host, ip) + ret = server.retrieve("/name", :manage, host, ip) end assert_equal(ret, File.read(file)) @@ -1046,7 +1048,7 @@ allow * mount = "/#{mod.name}/" list = nil assert_nothing_raised { - list = server.list(mount, :ignore, true, false) + list = server.list(mount, :manage, true, false) } list = list.split("\n") if mod.name == "green" @@ -1059,7 +1061,7 @@ allow * end assert_nothing_raised("Host 'allow' denied #{mount}") { - server.list(mount, :ignore, true, false, + server.list(mount, :manage, true, false, 'allow.example.com', "192.168.0.1") } end @@ -1102,7 +1104,7 @@ allow * list = nil mount = "/#{mod.name}/" assert_nothing_raised { - list = server.list(mount, :ignore, true, false) + list = server.list(mount, :manage, true, false) } assert_nothing_raised { @@ -1117,11 +1119,11 @@ allow * # now let's check that things are being correctly forbidden assert_raise(Puppet::AuthorizationError, "Host 'deny' allowed #{mount}") { - server.list(mount, :ignore, true, false, + server.list(mount, :manage, true, false, 'deny.example.com', "192.168.1.1") } assert_nothing_raised("Host 'allow' denied #{mount}") { - server.list(mount, :ignore, true, false, + server.list(mount, :manage, true, false, 'allow.example.com', "192.168.0.1") } end diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb index 25117030e..55522237b 100755 --- a/test/network/handler/master.rb +++ b/test/network/handler/master.rb @@ -76,18 +76,29 @@ class TestMaster < Test::Unit::TestCase Puppet[:node_name] = "cert" # Make sure we get the fact data back when nothing is set - facts = {"hostname" => "fact_hostname", "ipaddress" => "fact_ip"} - certname = "cert_hostname" + 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 diff --git a/test/network/server/webrick.rb b/test/network/server/webrick.rb index e44d84dda..f4e5398b8 100755 --- a/test/network/server/webrick.rb +++ b/test/network/server/webrick.rb @@ -95,7 +95,7 @@ class TestWebrickServer < Test::Unit::TestCase # the client starts its connection immediately, thus throwing # the error. assert_raise(OpenSSL::SSL::SSLError) { - client = Puppet::Network::Client.status.new(:Server => "localhost", :Port => @@port) + Puppet::Network::HttpPool.http_instance("localhost", @@port).start } end |
