summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/language/compile.rb86
-rwxr-xr-xtest/language/parser.rb1
-rwxr-xr-xtest/lib/puppettest.rb11
-rw-r--r--test/lib/puppettest/support/assertions.rb2
-rwxr-xr-xtest/network/client/master.rb144
-rwxr-xr-xtest/network/client/resource.rb8
-rwxr-xr-xtest/network/handler/master.rb68
-rwxr-xr-xtest/network/handler/runner.rb72
-rwxr-xr-xtest/other/relationships.rb10
-rwxr-xr-xtest/ral/manager/instances.rb3
-rwxr-xr-xtest/ral/manager/type.rb63
-rwxr-xr-xtest/ral/types/file.rb6
-rwxr-xr-xtest/ral/types/host.rb6
-rwxr-xr-xtest/ral/types/parameter.rb5
-rwxr-xr-xtest/ral/types/sshkey.rb5
15 files changed, 151 insertions, 339 deletions
diff --git a/test/language/compile.rb b/test/language/compile.rb
index 380da3da5..50b16a24d 100755
--- a/test/language/compile.rb
+++ b/test/language/compile.rb
@@ -174,88 +174,18 @@ class TestCompile < Test::Unit::TestCase
# "".
def test_evaluate_main
compile = mkcompile
- main = mock 'main_class'
- compile.topscope.expects(:source=).with(main)
- @parser.expects(:findclass).with("", "").returns(main)
+ main_class = mock 'main_class'
+ compile.topscope.expects(:source=).with(main_class)
+ @parser.expects(:findclass).with("", "").returns(main_class)
- assert_nothing_raised("Could not call evaluate_main") do
- compile.send(:evaluate_main)
- end
-
- assert(compile.resources.find { |r| r.to_s == "Class[main]" }, "Did not create a 'main' resource")
- end
-
- # Make sure we either don't look for nodes, or that we find and evaluate the right object.
- def test_evaluate_ast_node
- # First try it with ast_nodes disabled
- compile = mkcompile
- name = compile.node.name
- compile.expects(:ast_nodes?).returns(false)
- compile.parser.expects(:nodes).never
-
- assert_nothing_raised("Could not call evaluate_ast_node when ast nodes are disabled") do
- compile.send(:evaluate_ast_node)
- end
-
- assert_nil(compile.resources.find { |r| r.to_s == "Node[#{name}]" }, "Created node object when ast_nodes was false")
-
- # Now try it with them enabled, but no node found.
- nodes = mock 'node_hash'
- compile = mkcompile
- name = compile.node.name
- compile.expects(:ast_nodes?).returns(true)
- compile.parser.stubs(:nodes).returns(nodes)
-
- # Set some names for our test
- @node.names = %w{a b c}
- nodes.expects(:[]).with("a").returns(nil)
- nodes.expects(:[]).with("b").returns(nil)
- nodes.expects(:[]).with("c").returns(nil)
-
- # It should check this last, of course.
- nodes.expects(:[]).with("default").returns(nil)
+ main_resource = mock 'main resource'
+ Puppet::Parser::Resource.expects(:new).with { |args| args[:title] == :main }.returns(main_resource)
- # And make sure the lack of a node throws an exception
- assert_raise(Puppet::ParseError, "Did not fail when we couldn't find an ast node") do
- compile.send(:evaluate_ast_node)
- end
-
- # Finally, make sure it works dandily when we have a node
- compile = mkcompile
- compile.expects(:ast_nodes?).returns(true)
-
- node = stub 'node', :classname => "c"
- nodes = {"c" => node}
- compile.parser.stubs(:nodes).returns(nodes)
-
- # Set some names for our test
- @node.names = %w{a b c}
-
- # And make sure we throw no exceptions.
- assert_nothing_raised("Failed when a node was found") do
- compile.send(:evaluate_ast_node)
- end
+ main_resource.expects(:evaluate)
- assert_instance_of(Puppet::Parser::Resource, compile.resources.find { |r| r.to_s == "Node[c]" },
- "Did not create node resource")
-
- # Lastly, check when we actually find the default.
- compile = mkcompile
- compile.expects(:ast_nodes?).returns(true)
-
- node = stub 'node', :classname => "default"
- nodes = {"default" => node}
- compile.parser.stubs(:nodes).returns(nodes)
-
- # Set some names for our test
- @node.names = %w{a b c}
-
- # And make sure the lack of a node throws an exception
- assert_nothing_raised("Failed when a node was found") do
- compile.send(:evaluate_ast_node)
+ assert_nothing_raised("Could not call evaluate_main") do
+ compile.send(:evaluate_main)
end
- assert_instance_of(Puppet::Parser::Resource, compile.resources.find { |r| r.to_s == "Node[default]" },
- "Did not create default node resource")
end
def test_evaluate_node_classes
diff --git a/test/language/parser.rb b/test/language/parser.rb
index 04cd3a095..bc89eff20 100755
--- a/test/language/parser.rb
+++ b/test/language/parser.rb
@@ -694,6 +694,7 @@ file { "/tmp/yayness":
manifest = File.join(modpath, "manifest.pp")
manifest_texts.each do |txt|
+ Puppet::Type.allclear
File.open(manifest, "w") { |f| f.puts txt }
assert_nothing_raised {
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index 440ba3ba2..6447b80fb 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -20,6 +20,17 @@ if ARGV.include?("-d")
$console = true
end
+# Some monkey-patching to allow us to test private methods.
+class Class
+ def publicize_methods(*methods)
+ saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods
+
+ self.class_eval { public *saved_private_instance_methods }
+ yield
+ self.class_eval { private *saved_private_instance_methods }
+ end
+end
+
module PuppetTest
# Munge cli arguments, so we can enable debugging if we want
# and so we can run just specific methods.
diff --git a/test/lib/puppettest/support/assertions.rb b/test/lib/puppettest/support/assertions.rb
index 7e3e5ca2b..906bb3c76 100644
--- a/test/lib/puppettest/support/assertions.rb
+++ b/test/lib/puppettest/support/assertions.rb
@@ -1,7 +1,9 @@
require 'puppettest'
+require 'puppettest/support/utils'
require 'fileutils'
module PuppetTest
+ include PuppetTest::Support::Utils
def assert_logged(level, regex, msg = nil)
# Skip verifying logs that we're not supposed to send.
return unless Puppet::Util::Log.sendlevel?(level)
diff --git a/test/network/client/master.rb b/test/network/client/master.rb
index 4f6956470..7216af936 100755
--- a/test/network/client/master.rb
+++ b/test/network/client/master.rb
@@ -7,38 +7,6 @@ require 'mocha'
class TestMasterClient < Test::Unit::TestCase
include PuppetTest::ServerTest
-
- class FakeTrans
- def initialize
- @counters = Hash.new { |h,k| h[k] = 0 }
- end
- [:evaluate, :report, :cleanup, :addtimes, :tags, :ignoreschedules].each do |m|
- define_method(m.to_s + "=") do |*args|
- @counters[m] += 1
- end
- define_method(m) do |*args|
- @counters[m] += 1
- end
- define_method(m.to_s + "?") do
- @counters[m]
- end
- end
- end
- class FakeComponent
- attr_accessor :trans
- def evaluate
- @trans = FakeTrans.new
- @trans
- end
-
- def finalize
- @finalized = true
- end
-
- def finalized?
- @finalized
- end
- end
def setup
super
@@ -67,66 +35,6 @@ class TestMasterClient < Test::Unit::TestCase
return client
end
-
- def mk_fake_client
- server = Puppet::Network::Handler.master.new :Code => ""
- master = Puppet::Network::Client.master.new :Master => server, :Local => true
-
- # Now create some objects
- objects = FakeComponent.new
-
- master.send(:instance_variable_set, "@objects", objects)
-
- class << master
- def report(r)
- @reported ||= 0
- @reported += 1
- end
- def reported
- @reported ||= 0
- @reported
- end
- end
- return master, objects
- end
-
- def test_getconfig
- client = mkclient
-
- $methodsrun = []
- cleanup { $methodsrun = nil }
- client.meta_def(:getplugins) do
- $methodsrun << :getplugins
- end
- client.meta_def(:get_actual_config) do
- $methodsrun << :get_actual_config
- result = Puppet::TransBucket.new()
- result.type = "testing"
- result.name = "yayness"
- result
- end
-
- assert_nothing_raised do
- client.getconfig
- end
- [:get_actual_config].each do |method|
- assert($methodsrun.include?(method), "method %s was not run" % method)
- end
- assert(! $methodsrun.include?(:getplugins), "plugins were synced even tho disabled")
-
- # Now set pluginsync
- Puppet[:pluginsync] = true
- $methodsrun.clear
-
- assert_nothing_raised do
- client.getconfig
- end
- [:getplugins, :get_actual_config].each do |method|
- assert($methodsrun.include?(method), "method %s was not run" % method)
- end
-
- assert_instance_of(Puppet::Node::Configuration, client.configuration, "Configuration was not created")
- end
def test_disable
FileUtils.mkdir_p(Puppet[:statedir])
@@ -136,27 +44,22 @@ class TestMasterClient < Test::Unit::TestCase
client = mkclient(master)
- assert(! FileTest.exists?(@createdfile))
-
- assert_nothing_raised {
+ assert_nothing_raised("Could not disable client") {
client.disable
}
- assert_nothing_raised {
- client.run
- }
+ client.expects(:getconfig).never
- assert(! FileTest.exists?(@createdfile), "Disabled client ran")
+ client.run
- assert_nothing_raised {
- client.enable
- }
+ client = mkclient(master)
- assert_nothing_raised {
- client.run
- }
+ client.expects(:getconfig)
- assert(FileTest.exists?(@createdfile), "Enabled client did not run")
+ assert_nothing_raised("Could not enable client") {
+ client.enable
+ }
+ client.run
end
# Make sure we're getting the client version in our list of facts
@@ -652,15 +555,16 @@ end
client = mkclient
ftype = Puppet::Type.type(:file)
+ file = ftype.create :title => "/what/ever", :ensure => :present
+ config = Puppet::Node::Configuration.new
+ config.add_resource(file)
- assert_nil(ftype[@createdfile], "file object already exists")
- assert(! FileTest.exists?(@createdfile), "File already exists on disk")
+ config.expects :apply
- assert_nothing_raised("Could not apply config") do
- client.run
- end
+ client.configuration = config
+ client.expects(:getconfig)
+ client.run
- assert(FileTest.exists?(@createdfile), "File does not exist on disk")
assert_nil(ftype[@createdfile], "file object was not removed from memory")
end
@@ -675,20 +579,20 @@ end
end
end
- # #800 -- we cannot fix this using the current design.
- def disabled_test_invalid_relationships_do_not_get_cached
- # Make a master with an invalid relationship
+ def test_invalid_configurations_do_not_get_cached
master = mkmaster :Code => "notify { one: require => File[yaytest] }"
master.local = false # so it gets cached
client = mkclient(master)
+ client.stubs(:facts).returns({})
client.local = false
- client.getconfig
- # Doesn't throw an exception, but definitely fails.
- client.apply
+ Puppet::Node::Facts.indirection.stubs(:terminus_class).returns(:memory)
# Make sure the config is not cached.
- config = Puppet.settings[:localconfig] + ".yaml"
- assert(! File.exists?(config), "Cached an invalid configuration")
+ client.expects(:cache).never
+
+ client.getconfig
+ # Doesn't throw an exception, but definitely fails.
+ client.run
end
end
diff --git a/test/network/client/resource.rb b/test/network/client/resource.rb
index 83c195035..eb8e829eb 100755
--- a/test/network/client/resource.rb
+++ b/test/network/client/resource.rb
@@ -3,10 +3,13 @@
require File.dirname(__FILE__) + '/../../lib/puppettest'
require 'puppettest'
+require 'puppettest/support/utils'
+require 'puppettest/support/assertions'
require 'puppet/network/client/resource'
class TestResourceClient < Test::Unit::TestCase
include PuppetTest::ServerTest
+ include PuppetTest::Support::Utils
def mkresourceserver
Puppet::Network::Handler.resource.new
@@ -35,6 +38,7 @@ class TestResourceClient < Test::Unit::TestCase
assert_instance_of(Puppet::TransObject, tobj)
+ Puppet::Type.allclear
obj = nil
assert_nothing_raised {
obj = tobj.to_type
@@ -45,6 +49,7 @@ class TestResourceClient < Test::Unit::TestCase
File.unlink(file)
# Now test applying
+ Puppet::Type.allclear
result = nil
assert_nothing_raised {
result = client.apply(tobj)
@@ -52,6 +57,7 @@ class TestResourceClient < Test::Unit::TestCase
assert(FileTest.exists?(file), "File was not created on apply")
# Lastly, test "list"
+ Puppet::Type.allclear
list = nil
assert_nothing_raised {
list = client.list("user")
@@ -64,12 +70,14 @@ class TestResourceClient < Test::Unit::TestCase
break if count > 3
assert_instance_of(Puppet::TransObject, tobj)
+ Puppet::Type.allclear
tobj2 = nil
assert_nothing_raised {
tobj2 = client.describe(tobj.type, tobj.name)
}
obj = nil
+ Puppet::Type.allclear
assert_nothing_raised {
obj = tobj2.to_type
}
diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb
index 694888f4d..25117030e 100755
--- a/test/network/handler/master.rb
+++ b/test/network/handler/master.rb
@@ -13,39 +13,11 @@ class TestMaster < Test::Unit::TestCase
Puppet::Indirector::Indirection.clear_cache
end
- def test_defaultmanifest
- textfiles { |file|
- Puppet[:manifest] = file
- client = nil
- master = nil
- assert_nothing_raised() {
- # this is the default server setup
- master = Puppet::Network::Handler.master.new(
- :Manifest => file,
- :UseNodes => false,
- :Local => true
- )
- }
- assert_nothing_raised() {
- client = Puppet::Network::Client.master.new(
- :Master => master
- )
- }
-
- # pull our configuration
- assert_nothing_raised() {
- client.getconfig
- stopservices
- Puppet::Type.allclear
- }
-
- break
- }
- end
-
+ # Make sure that files are reread when they change.
def test_filereread
# Start with a normal setting
Puppet[:filetimeout] = 15
+
manifest = mktestmanifest()
facts = Puppet::Network::Client.master.facts
@@ -63,35 +35,12 @@ class TestMaster < Test::Unit::TestCase
:Local => true
)
}
- assert_nothing_raised() {
- client = Puppet::Network::Client.master.new(
- :Master => master
- )
- }
- assert(client, "did not create master client")
- # The client doesn't have a config, so it can't be up to date
- assert(! client.fresh?(facts),
- "Client is incorrectly up to date")
-
- Puppet.settings.use(:main)
- config = nil
- assert_nothing_raised {
- config = client.getconfig
- config.apply
- }
-
- # Now it should be up to date
- assert(client.fresh?(facts), "Client is not up to date")
+ config = master.getconfig({"hostname" => "blah"})
# Cache this value for later
parse1 = master.freshness("mynode")
- # Verify the config got applied
- assert(FileTest.exists?(@createdfile),
- "Created file %s does not exist" % @createdfile)
- Puppet::Type.allclear
-
sleep 1.5
# Create a new manifest
File.open(manifest, "w") { |f|
@@ -101,7 +50,6 @@ class TestMaster < Test::Unit::TestCase
# Verify that the master doesn't immediately reparse the file; we
# want to wait through the timeout
assert_equal(parse1, master.freshness("mynode"), "Master did not wait through timeout")
- assert(client.fresh?(facts), "Client is not up to date")
# Then eliminate it
Puppet[:filetimeout] = 0
@@ -109,16 +57,8 @@ class TestMaster < Test::Unit::TestCase
# Now make sure the master does reparse
#Puppet.notice "%s vs %s" % [parse1, master.freshness]
assert(parse1 != master.freshness("mynode"), "Master did not reparse file")
- assert(! client.fresh?(facts), "Client is incorrectly up to date")
-
- # Retrieve and apply the new config
- assert_nothing_raised {
- config = client.getconfig
- config.apply
- }
- assert(client.fresh?(facts), "Client is not up to date")
- assert(FileTest.exists?(file2), "Second file %s does not exist" % file2)
+ assert(master.getconfig({"hostname" => "blah"}) != config, "Did not use reloaded config")
end
# Make sure we're correctly doing clientname manipulations.
diff --git a/test/network/handler/runner.rb b/test/network/handler/runner.rb
index 402b27ffc..171458ffa 100755
--- a/test/network/handler/runner.rb
+++ b/test/network/handler/runner.rb
@@ -29,7 +29,8 @@ class TestHandlerRunner < Test::Unit::TestCase
client
end
- def test_runner
+ def setup
+ super
FileUtils.mkdir_p(Puppet[:statedir])
Puppet[:ignoreschedules] = false
# Okay, make our manifest
@@ -37,7 +38,7 @@ class TestHandlerRunner < Test::Unit::TestCase
created = tempfile()
# We specify the schedule here, because I was having problems with
# using default schedules.
- code = %{
+ @code = %{
class yayness {
schedule { "yayness": period => weekly }
file { "#{created}": ensure => file, schedule => yayness }
@@ -46,59 +47,24 @@ class TestHandlerRunner < Test::Unit::TestCase
include yayness
}
- client = mkclient(code)
+ @client = mkclient(@code)
- runner = nil
- assert_nothing_raised {
- runner = Puppet::Network::Handler.runner.new
- }
- # First: tags
- # Second: ignore schedules true/false
- # Third: background true/false
- # Fourth: whether file should exist true/false
- [
- ["with no backgrounding",
- nil, true, true, true],
- ["in the background",
- nil, true, false, true],
- ["with a bad tag",
- ["coolness"], true, false, false],
- ["with another bad tag",
- "coolness", true, false, false],
- ["with a good tag",
- ["coolness", "yayness"], true, false, true],
- ["with another good tag",
- ["yayness"], true, false, true],
- ["with a third good tag",
- "yayness", true, false, true],
- ["with no tags",
- "", true, false, true],
- ["not ignoring schedules",
- nil, false, false, false],
- ["ignoring schedules",
- nil, true, false, true],
- ].each do |msg, tags, ignore, fg, shouldexist|
- if FileTest.exists?(created)
- File.unlink(created)
- end
- assert_nothing_raised {
- # Try it without backgrounding
- runner.run(tags, ignore, fg)
- }
+ @runner = Puppet::Network::Handler.runner.new
+ end
+
+ def test_runner_when_in_foreground
+ @client.expects(:run).with(:tags => "mytags", :ignoreschedules => true)
+
+ Process.expects(:newthread).never
- unless fg
- Puppet.join
- end
-
- if shouldexist
- assert(FileTest.exists?(created), "File did not get created " +
- msg)
- else
- assert(!FileTest.exists?(created), "File got created incorrectly " +
- msg)
- end
- end
+ @runner.run("mytags", true, true)
end
-end
+ def test_runner_when_in_background
+ @client.expects(:run).with(:tags => "mytags", :ignoreschedules => true)
+
+ Puppet.expects(:newthread).yields
+ @runner.run("mytags", true, false)
+ end
+end
diff --git a/test/other/relationships.rb b/test/other/relationships.rb
index bfe7e88d7..0f2a103fe 100755
--- a/test/other/relationships.rb
+++ b/test/other/relationships.rb
@@ -111,7 +111,7 @@ class TestRelationships < Test::Unit::TestCase
end
end
- def test_store_relationship
+ def test_munge_relationship
file = Puppet::Type.newfile :path => tempfile(), :mode => 0755
execs = []
3.times do |i|
@@ -122,7 +122,7 @@ class TestRelationships < Test::Unit::TestCase
result = nil
[execs[0], [:exec, "yay0"], ["exec", "yay0"]].each do |target|
assert_nothing_raised do
- result = file.send(:store_relationship, :require, target)
+ result = file.send(:munge_relationship, :require, target)
end
assert_equal([[:exec, "yay0"]], result)
@@ -133,7 +133,7 @@ class TestRelationships < Test::Unit::TestCase
strings = execs.collect { |e| [e.class.name.to_s, e.title] }
[execs, symbols, strings].each do |target|
assert_nothing_raised do
- result = file.send(:store_relationship, :require, target)
+ result = file.send(:munge_relationship, :require, target)
end
assert_equal(symbols, result)
@@ -141,7 +141,7 @@ class TestRelationships < Test::Unit::TestCase
# Make sure we can mix it up, even though this shouldn't happen
assert_nothing_raised do
- result = file.send(:store_relationship, :require, [execs[0], [execs[1].class.name, execs[1].title]])
+ result = file.send(:munge_relationship, :require, [execs[0], [execs[1].class.name, execs[1].title]])
end
assert_equal([[:exec, "yay0"], [:exec, "yay1"]], result)
@@ -151,7 +151,7 @@ class TestRelationships < Test::Unit::TestCase
file[:require] = execs[0]
assert_nothing_raised do
- result = file.send(:store_relationship, :require, [execs[1], execs[2]])
+ result = file.send(:munge_relationship, :require, [execs[1], execs[2]])
end
assert_equal(symbols, result)
diff --git a/test/ral/manager/instances.rb b/test/ral/manager/instances.rb
index 6ac4322f5..88f766038 100755
--- a/test/ral/manager/instances.rb
+++ b/test/ral/manager/instances.rb
@@ -93,7 +93,8 @@ class TestTypeInstances < Test::Unit::TestCase
# Make sure resources are entirely deleted.
def test_delete
aliases = %w{one}
- obj = @type.create(:name => "testing", :alias => "two")
+ config = mk_configuration
+ obj = @type.create(:name => "testing", :alias => "two", :configuration => config)
aliases << "two"
@type.alias("two", obj)
diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb
index 57248159b..350d3dd15 100755
--- a/test/ral/manager/type.rb
+++ b/test/ral/manager/type.rb
@@ -131,27 +131,60 @@ class TestType < Test::Unit::TestCase
}
end
- # Verify that aliasing works
- def test_aliasing
- file = tempfile()
+ def test_aliases_to_self_are_not_failures
+ resource = Puppet.type(:file).create(
+ :name => "/path/to/some/missing/file",
+ :ensure => "file"
+ )
+ resource.stubs(:path).returns("")
- baseobj = nil
- assert_nothing_raised {
- baseobj = Puppet.type(:file).create(
- :name => file,
- :ensure => "file",
- :alias => ["funtest"]
- )
- }
+ configuration = stub 'configuration'
+ configuration.expects(:resource).with(:file, "/path/to/some/missing/file").returns(resource)
+ resource.configuration = configuration
# Verify our adding ourselves as an alias isn't an error.
- assert_nothing_raised {
- baseobj[:alias] = file
+ assert_nothing_raised("Could not add alias") {
+ resource[:alias] = "/path/to/some/missing/file"
+ }
+
+ assert_equal(resource.object_id, Puppet.type(:file)["/path/to/some/missing/file"].object_id, "Could not retrieve alias to self")
+ end
+
+ def test_aliases_are_added_to_class_and_configuration
+ resource = Puppet.type(:file).create(
+ :name => "/path/to/some/missing/file",
+ :ensure => "file"
+ )
+ resource.stubs(:path).returns("")
+
+ configuration = stub 'configuration'
+ configuration.stubs(:resource).returns(nil)
+ configuration.expects(:alias).with(resource, "funtest")
+ resource.configuration = configuration
+
+ assert_nothing_raised("Could not add alias") {
+ resource[:alias] = "funtest"
}
- assert_instance_of(Puppet.type(:file), Puppet.type(:file)["funtest"],
- "Could not retrieve alias")
+ assert_equal(resource.object_id, Puppet.type(:file)["funtest"].object_id, "Could not retrieve alias")
+ end
+
+ def test_aliasing_fails_without_a_configuration
+ resource = Puppet.type(:file).create(
+ :name => "/no/such/file",
+ :ensure => "file"
+ )
+
+ assert_raise(Puppet::Error, "Did not fail to alias when no configuration was available") {
+ resource[:alias] = "funtest"
+ }
+ end
+ def test_configurations_are_set_during_initialization_if_present_on_the_transobject
+ trans = Puppet::TransObject.new("/path/to/some/file", :file)
+ trans.configuration = :my_config
+ resource = trans.to_type
+ assert_equal(resource.configuration, trans.configuration, "Did not set configuration on initialization")
end
# Verify that requirements don't depend on file order
diff --git a/test/ral/types/file.rb b/test/ral/types/file.rb
index aca9d3b9c..73095a783 100755
--- a/test/ral/types/file.rb
+++ b/test/ral/types/file.rb
@@ -104,6 +104,12 @@ class TestFile < Test::Unit::TestCase
}
end
+ def test_groups_fails_when_invalid
+ assert_raise(Puppet::Error, "did not fail when the group was empty") do
+ Puppet::Type.type(:file).create :path => "/some/file", :group => ""
+ end
+ end
+
if Puppet::Util::SUIDManager.uid == 0
def test_createasuser
dir = tmpdir()
diff --git a/test/ral/types/host.rb b/test/ral/types/host.rb
index 69e37da0f..1013651c5 100755
--- a/test/ral/types/host.rb
+++ b/test/ral/types/host.rb
@@ -38,12 +38,16 @@ class TestHost < Test::Unit::TestCase
else
@hcount = 1
end
+
+ @configuration ||= mk_configuration
+
host = nil
assert_nothing_raised {
host = Puppet.type(:host).create(
:name => "fakehost%s" % @hcount,
:ip => "192.168.27.%s" % @hcount,
- :alias => "alias%s" % @hcount
+ :alias => "alias%s" % @hcount,
+ :configuration => @configuration
)
}
diff --git a/test/ral/types/parameter.rb b/test/ral/types/parameter.rb
index 89c8b944d..1d402cb85 100755
--- a/test/ral/types/parameter.rb
+++ b/test/ral/types/parameter.rb
@@ -113,6 +113,9 @@ class TestParameter < Test::Unit::TestCase
inst = type.create(:name => "test")
+ config = mk_configuration
+ inst.configuration = config
+
assert_nothing_raised("Could not create shadowed param") {
inst[:alias] = "foo"
}
@@ -133,7 +136,7 @@ class TestParameter < Test::Unit::TestCase
# Now try it during initialization
other = nil
assert_nothing_raised("Could not create instance with shadow") do
- other = type.create(:name => "rah", :alias => "one")
+ other = type.create(:name => "rah", :alias => "one", :configuration => config)
end
params = other.instance_variable_get("@parameters")
obj = params[:alias]
diff --git a/test/ral/types/sshkey.rb b/test/ral/types/sshkey.rb
index c610eb9e9..c99f7562a 100755
--- a/test/ral/types/sshkey.rb
+++ b/test/ral/types/sshkey.rb
@@ -47,12 +47,15 @@ class TestSSHKey < Test::Unit::TestCase
@kcount = 1
end
+ @config ||= mk_configuration
+
assert_nothing_raised {
key = @sshkeytype.create(
:name => "host%s.madstop.com" % @kcount,
:key => "%sAAAAB3NzaC1kc3MAAACBAMnhSiku76y3EGkNCDsUlvpO8tRgS9wL4Eh54WZfQ2lkxqfd2uT/RTT9igJYDtm/+UHuBRdNGpJYW1Nw2i2JUQgQEEuitx4QKALJrBotejGOAWxxVk6xsh9xA0OW8Q3ZfuX2DDitfeC8ZTCl4xodUMD8feLtP+zEf8hxaNamLlt/AAAAFQDYJyf3vMCWRLjTWnlxLtOyj/bFpwAAAIEAmRxxXb4jjbbui9GYlZAHK00689DZuX0EabHNTl2yGO5KKxGC6Esm7AtjBd+onfu4Rduxut3jdI8GyQCIW8WypwpJofCIyDbTUY4ql0AQUr3JpyVytpnMijlEyr41FfIb4tnDqnRWEsh2H7N7peW+8DWZHDFnYopYZJ9Yu4/jHRYAAACAERG50e6aRRb43biDr7Ab9NUCgM9bC0SQscI/xdlFjac0B/kSWJYTGVARWBDWug705hTnlitY9cLC5Ey/t/OYOjylTavTEfd/bh/8FkAYO+pWdW3hx6p97TBffK0b6nrc6OORT2uKySbbKOn0681nNQh4a6ueR3JRppNkRPnTk5c=" % @kcount,
:type => "ssh-dss",
- :alias => ["192.168.0.%s" % @kcount]
+ :alias => ["192.168.0.%s" % @kcount],
+ :configuration => @config
)
}