diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-09-23 20:42:08 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-09-23 20:42:08 +0000 |
| commit | 8211df036e1d2d24e1084616fc3fc4891b06cfdd (patch) | |
| tree | 597f8b999cf5210a7ceff5ef1e1977f1de08c241 /test/server | |
| parent | d20ac8e0b564e5413d571f2059de559e0783b72d (diff) | |
| download | puppet-8211df036e1d2d24e1084616fc3fc4891b06cfdd.tar.gz puppet-8211df036e1d2d24e1084616fc3fc4891b06cfdd.tar.xz puppet-8211df036e1d2d24e1084616fc3fc4891b06cfdd.zip | |
Many, many changes toward a completely functional system. The only current problems with my home config are that apache's stupid init script does not do status and that packages are not working as non-root users (which makes sense).
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@703 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/server')
| -rwxr-xr-x | test/server/tc_fileserver.rb | 98 |
1 files changed, 91 insertions, 7 deletions
diff --git a/test/server/tc_fileserver.rb b/test/server/tc_fileserver.rb index 4235a725c..17003a6fe 100755 --- a/test/server/tc_fileserver.rb +++ b/test/server/tc_fileserver.rb @@ -416,6 +416,23 @@ class TestFileServer < TestPuppet files.each { |file| assert_describe(sfile, file, server) } + + # And then describe some files that we know aren't there + retval = nil + assert_nothing_raised("Describing non-existent files raised an error") { + retval = server.describe(sfile + "noexisties") + } + + assert_equal("", retval, "Description of non-existent files returned a value") + + # Now try to describe some sources that don't even exist + retval = nil + assert_raise(Puppet::Server::FileServerError, + "Describing non-existent mount did not raise an error") { + retval = server.describe("/notmounted/" + "noexisties") + } + + assert_nil(retval, "Description of non-existent mounts returned a value") end # test that our config file is parsing and working as planned @@ -424,9 +441,6 @@ class TestFileServer < TestPuppet basedir = File.join(tmpdir, "fileserverconfigfiletesting") @@tmpfiles << basedir - conftext = "# a test config file\n \n" - - # make some dirs for mounting Dir.mkdir(basedir) mounts = {} @@ -541,6 +555,72 @@ class TestFileServer < TestPuppet end + # Test that we smoothly handle invalid config files + def test_configfailures + # create an example file with each of them + conffile = tempfile() + + invalidmounts = { + "noexist" => "[noexist] + path /this/path/does/not/exist + allow 192.168.0.* +" +} + + invalidconfigs = [ +"[not valid] + path /this/path/does/not/exist + allow 192.168.0.* +", +"[valid] + invalidstatement + path /etc + allow 192.168.0.* +", +"[valid] + allow 192.168.0.* +" +] + + invalidmounts.each { |mount, text| + File.open(conffile, "w") { |f| + f.print text + } + + + # create a server with the file + server = nil + assert_nothing_raised { + server = Puppet::Server::FileServer.new( + :Local => true, + :Config => conffile + ) + } + + assert_raise(Puppet::Server::FileServerError, + "Invalid mount was mounted") { + server.list(mount) + } + } + + invalidconfigs.each_with_index { |text, i| + File.open(conffile, "w") { |f| + f.print text + } + + + # create a server with the file + server = nil + assert_raise(Puppet::Server::FileServerError, + "Invalid config %s did not raise error" % i) { + server = Puppet::Server::FileServer.new( + :Local => true, + :Config => conffile + ) + } + } + end + # verify we reread the config file when it changes def test_filereread server = nil @@ -572,12 +652,14 @@ class TestFileServer < TestPuppet list = nil assert_nothing_raised { - list = server.list("/thing/", false, false, "test1.domain.com", "127.0.0.1") + list = server.list("/thing/", false, false, + "test1.domain.com", "127.0.0.1") } assert(list != "", "List returned nothing in rereard test") assert_raise(Puppet::Server::AuthorizationError, "List allowed invalid host") { - list = server.list("/thing/", false, false, "test2.domain.com", "127.0.0.1") + list = server.list("/thing/", false, false, + "test2.domain.com", "127.0.0.1") } sleep 1 @@ -591,11 +673,13 @@ class TestFileServer < TestPuppet } assert_raise(Puppet::Server::AuthorizationError, "List allowed invalid host") { - list = server.list("/thing/", false, false, "test1.domain.com", "127.0.0.1") + list = server.list("/thing/", false, false, + "test1.domain.com", "127.0.0.1") } assert_nothing_raised { - list = server.list("/thing/", false, false, "test2.domain.com", "127.0.0.1") + list = server.list("/thing/", false, false, + "test2.domain.com", "127.0.0.1") } assert(list != "", "List returned nothing in rereard test") |
