Fixing tests broken during the #1405 fix.
Most of these were small changes, like moved methods. Signed-off-by: Luke Kanies <luke@madstop.com>
This commit is contained in:
Родитель
08a5d492dd
Коммит
5335788411
|
@ -152,7 +152,10 @@ Puppet::Log.newdestination(:console)
|
|||
client = nil
|
||||
server = nil
|
||||
|
||||
Puppet.settraps
|
||||
trap(:INT) do
|
||||
$stderr.puts "Cancelling"
|
||||
exit(1)
|
||||
end
|
||||
|
||||
if options[:debug]
|
||||
Puppet::Log.level = :debug
|
||||
|
|
|
@ -166,7 +166,10 @@ end
|
|||
client = nil
|
||||
server = nil
|
||||
|
||||
Puppet.settraps
|
||||
trap(:INT) do
|
||||
$stderr.puts "Exiting"
|
||||
exit(1)
|
||||
end
|
||||
|
||||
if options[:debug]
|
||||
Puppet::Util::Log.level = :debug
|
||||
|
|
|
@ -29,6 +29,16 @@ class Puppet::Resource
|
|||
@parameters[parameter_name(param)]
|
||||
end
|
||||
|
||||
# Compatibility method.
|
||||
def builtin?
|
||||
builtin_type?
|
||||
end
|
||||
|
||||
# Is this a builtin resource type?
|
||||
def builtin_type?
|
||||
@reference.builtin_type?
|
||||
end
|
||||
|
||||
# Iterate over each param/value pair, as required for Enumerable.
|
||||
def each
|
||||
@parameters.each { |p,v| yield p, v }
|
||||
|
|
|
@ -469,6 +469,8 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
|
|||
def to_catalog(convert)
|
||||
result = self.class.new(self.name)
|
||||
|
||||
result.version = self.version
|
||||
|
||||
map = {}
|
||||
vertices.each do |resource|
|
||||
next if resource.respond_to?(:virtual?) and resource.virtual?
|
||||
|
|
|
@ -56,6 +56,20 @@ describe Puppet::Resource do
|
|||
resource.title.should == "mytitle"
|
||||
end
|
||||
|
||||
it "should use its resource reference to determine whether it is builtin" do
|
||||
ref = Puppet::Resource::Reference.new("file", "/f")
|
||||
Puppet::Resource::Reference.expects(:new).returns ref
|
||||
resource = Puppet::Resource.new("file", "/f")
|
||||
ref.expects(:builtin_type?).returns "yep"
|
||||
resource.builtin_type?.should == "yep"
|
||||
end
|
||||
|
||||
it "should call its builtin_type? method when 'builtin?' is called" do
|
||||
resource = Puppet::Resource.new("file", "/f")
|
||||
resource.expects(:builtin_type?).returns "foo"
|
||||
resource.builtin?.should == "foo"
|
||||
end
|
||||
|
||||
it "should use its resource reference to produce its canonical reference string" do
|
||||
ref = Puppet::Resource::Reference.new("file", "/f")
|
||||
Puppet::Resource::Reference.expects(:new).returns ref
|
||||
|
|
|
@ -191,6 +191,11 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|||
@catalog = @original.to_resource
|
||||
end
|
||||
|
||||
it "should copy over the version" do
|
||||
@original.version = "foo"
|
||||
@original.to_resource.version.should == "foo"
|
||||
end
|
||||
|
||||
it "should add all resources as Puppet::Resource instances" do
|
||||
@resources.each { |resource| @catalog.resource(resource.ref).should be_instance_of(Puppet::Resource) }
|
||||
end
|
||||
|
|
|
@ -15,131 +15,6 @@ class TestClient < Test::Unit::TestCase
|
|||
class FakeDriver
|
||||
end
|
||||
|
||||
# a single run through of connect, auth, etc.
|
||||
def disabled_test_sslInitWithAutosigningLocalServer
|
||||
# autosign everything, for simplicity
|
||||
Puppet[:autosign] = true
|
||||
|
||||
# create a server to which to connect
|
||||
mkserver()
|
||||
|
||||
# create our client
|
||||
client = nil
|
||||
assert_nothing_raised {
|
||||
client = Puppet::Network::Client.master.new(
|
||||
:Server => "localhost",
|
||||
:Port => @@port
|
||||
)
|
||||
}
|
||||
|
||||
# get our certs
|
||||
assert_nothing_raised {
|
||||
client.initcerts
|
||||
}
|
||||
|
||||
# make sure all of our cert files exist
|
||||
certfile = File.join(Puppet[:certdir], [client.fqdn, "pem"].join("."))
|
||||
keyfile = File.join(Puppet[:privatekeydir], [client.fqdn, "pem"].join("."))
|
||||
publickeyfile = File.join(Puppet[:publickeydir], [client.fqdn, "pem"].join("."))
|
||||
|
||||
assert(File.exists?(keyfile))
|
||||
assert(File.exists?(certfile))
|
||||
assert(File.exists?(publickeyfile))
|
||||
|
||||
# verify we can retrieve the catalog
|
||||
assert_nothing_raised("Client could not retrieve catalog") {
|
||||
client.getconfig
|
||||
}
|
||||
|
||||
# and apply it
|
||||
assert_nothing_raised("Client could not apply catalog") {
|
||||
client.apply
|
||||
}
|
||||
|
||||
# and verify that it did what it was supposed to
|
||||
assert(FileTest.exists?(@createdfile),
|
||||
"Applied file does not exist")
|
||||
end
|
||||
|
||||
|
||||
# here we create two servers; we
|
||||
def disabled_test_failureWithUntrustedCerts
|
||||
Puppet[:autosign] = true
|
||||
|
||||
# create a pair of clients with no certs
|
||||
nonemaster = nil
|
||||
assert_nothing_raised {
|
||||
nonemaster = Puppet::Network::Client.master.new(
|
||||
:Server => "localhost",
|
||||
:Port => @@port
|
||||
)
|
||||
}
|
||||
|
||||
nonebucket = nil
|
||||
assert_nothing_raised {
|
||||
nonebucket = Puppet::Network::Client.dipper.new(
|
||||
:Server => "localhost",
|
||||
:Port => @@port
|
||||
)
|
||||
}
|
||||
|
||||
# create a ca so we can create a set of certs
|
||||
# make a new ssldir for it
|
||||
ca = nil
|
||||
assert_nothing_raised {
|
||||
ca = Puppet::Network::Client.ca.new(
|
||||
:CA => true, :Local => true
|
||||
)
|
||||
ca.requestcert
|
||||
}
|
||||
|
||||
# initialize our clients with this set of certs
|
||||
certmaster = nil
|
||||
assert_nothing_raised {
|
||||
certmaster = Puppet::Network::Client.master.new(
|
||||
:Server => "localhost",
|
||||
:Port => @@port
|
||||
)
|
||||
}
|
||||
|
||||
certbucket = nil
|
||||
assert_nothing_raised {
|
||||
certbucket = Puppet::Network::Client.dipper.new(
|
||||
:Server => "localhost",
|
||||
:Port => @@port
|
||||
)
|
||||
}
|
||||
|
||||
# Create a new ssl root.
|
||||
confdir = tempfile()
|
||||
Puppet[:ssldir] = confdir
|
||||
Puppet.settings.mkdir(:ssldir)
|
||||
Puppet.settings.clearused
|
||||
Puppet.settings.use(:ssl, :ca)
|
||||
|
||||
mkserver
|
||||
|
||||
# now verify that our client cannot do non-cert operations
|
||||
# because its certs are signed by a different CA
|
||||
assert_raise(Puppet::Error,
|
||||
"Client was allowed to call getconfig with no certs") {
|
||||
nonemaster.getconfig
|
||||
}
|
||||
assert_raise(Puppet::Error,
|
||||
"Client was allowed to call getconfig with untrusted certs") {
|
||||
certmaster.getconfig
|
||||
}
|
||||
|
||||
assert_raise(Puppet::Network::XMLRPCClientError,
|
||||
"Client was allowed to call backup with no certs") {
|
||||
nonebucket.backup("/etc/passwd")
|
||||
}
|
||||
assert_raise(Puppet::Network::XMLRPCClientError,
|
||||
"Client was allowed to call backup with untrusted certs") {
|
||||
certbucket.backup("/etc/passwd")
|
||||
}
|
||||
end
|
||||
|
||||
def test_client_loading
|
||||
# Make sure we don't get a failure but that we also get nothing back
|
||||
assert_nothing_raised do
|
||||
|
@ -181,7 +56,7 @@ class TestClient < Test::Unit::TestCase
|
|||
|
||||
# Make sure we get a client class for each handler type.
|
||||
def test_loading_all_clients
|
||||
%w{ca dipper file master report resource runner status}.each do |name|
|
||||
%w{ca dipper file report resource runner status}.each do |name|
|
||||
client = nil
|
||||
assert_nothing_raised do
|
||||
client = Puppet::Network::Client.client(name)
|
||||
|
|
|
@ -65,39 +65,6 @@ class TestWebrickServer < Test::Unit::TestCase
|
|||
}
|
||||
assert_equal(1, retval)
|
||||
end
|
||||
|
||||
# Test that a client whose cert has been revoked really can't connect
|
||||
def test_xcertificate_revocation
|
||||
Puppet[:autosign] = true
|
||||
|
||||
serverpid, server = mk_status_server
|
||||
|
||||
client = mk_status_client
|
||||
|
||||
status = nil
|
||||
assert_nothing_raised() {
|
||||
status = client.status
|
||||
}
|
||||
assert_equal(1, status)
|
||||
client.shutdown
|
||||
|
||||
# Revoke the client's cert
|
||||
ca = Puppet::SSLCertificates::CA.new()
|
||||
ca.revoke(ca.getclientcert(Puppet[:certname])[0].serial)
|
||||
|
||||
# Restart the server
|
||||
@@port += 1
|
||||
Puppet[:autosign] = false
|
||||
kill_and_wait(serverpid, server.pidfile)
|
||||
serverpid, server = mk_status_server
|
||||
|
||||
# This time the client should be denied. With keep-alive,
|
||||
# the client starts its connection immediately, thus throwing
|
||||
# the error.
|
||||
assert_raise(OpenSSL::SSL::SSLError) {
|
||||
Puppet::Network::HttpPool.http_instance("localhost", @@port).start
|
||||
}
|
||||
end
|
||||
|
||||
def mk_status_client
|
||||
client = nil
|
||||
|
|
|
@ -41,36 +41,6 @@ class TestPuppetModule < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
# Make sure that services get correctly started and stopped
|
||||
def test_servicehandling
|
||||
file = tempfile()
|
||||
testclass = mktestclass()
|
||||
|
||||
obj = testclass.new(file)
|
||||
|
||||
assert_nothing_raised {
|
||||
Puppet.newservice(obj)
|
||||
}
|
||||
|
||||
assert_nothing_raised {
|
||||
Puppet.start(false)
|
||||
}
|
||||
|
||||
# Give it a sec or so
|
||||
sleep 0.3
|
||||
|
||||
assert(obj.started?, "Object was not started")
|
||||
|
||||
assert_nothing_raised {
|
||||
Puppet.shutdown(false)
|
||||
}
|
||||
# Give it a sec or so
|
||||
sleep 0.3
|
||||
|
||||
assert(!obj.started?, "Object is still running")
|
||||
|
||||
end
|
||||
|
||||
def test_path
|
||||
oldpath = ENV["PATH"]
|
||||
cleanup do
|
||||
|
|
|
@ -83,7 +83,7 @@ class TestReports < Test::Unit::TestCase
|
|||
|
||||
# We have to reuse reporting here because of something going on in the
|
||||
# server/report.rb file
|
||||
Puppet.settings.use(:main, :reporting)
|
||||
Puppet.settings.use(:main, :puppetmasterd)
|
||||
|
||||
3.times { |i|
|
||||
log = Puppet.warning("Report test message %s" % i)
|
||||
|
@ -97,10 +97,7 @@ class TestReports < Test::Unit::TestCase
|
|||
|
||||
yaml = YAML.dump(report)
|
||||
|
||||
file = nil
|
||||
assert_nothing_raised {
|
||||
file = report.process
|
||||
}
|
||||
file = report.process
|
||||
|
||||
assert(FileTest.exists?(file), "report file did not get created")
|
||||
assert_equal(yaml, File.read(file), "File did not get written")
|
||||
|
|
|
@ -203,8 +203,6 @@ yay = /a/path
|
|||
|
||||
file = tempfile()
|
||||
File.open(file, "w") { |f| f.puts text }
|
||||
|
||||
@config.expects(:settimer)
|
||||
|
||||
result = nil
|
||||
assert_nothing_raised {
|
||||
|
@ -607,8 +605,6 @@ yay = /a/path
|
|||
end
|
||||
|
||||
def test_correct_type_assumptions
|
||||
config = mkconfig
|
||||
|
||||
file = Puppet::Util::Settings::CFile
|
||||
element = Puppet::Util::Settings::CElement
|
||||
bool = Puppet::Util::Settings::CBoolean
|
||||
|
@ -624,11 +620,13 @@ yay = /a/path
|
|||
["$server/yayness", file],
|
||||
["$server/yayness.conf", file]
|
||||
].each do |ary|
|
||||
config = mkconfig
|
||||
value, type = ary
|
||||
name = value.to_s + "_setting"
|
||||
assert_nothing_raised {
|
||||
config.setdefaults(:yayness, value => { :default => value, :desc => name.to_s})
|
||||
config.setdefaults(:yayness, name => { :default => value, :desc => name.to_s})
|
||||
}
|
||||
elem = config.element(value)
|
||||
elem = config.element(name)
|
||||
|
||||
assert_instance_of(type, elem,
|
||||
"%s got created as wrong type" % value.inspect)
|
||||
|
|
Загрузка…
Ссылка в новой задаче