summaryrefslogtreecommitdiffstats
path: root/test/network
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:05:04 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:05:04 -0700
commit9ee56f2e67be973da49b1d3f21de1bf87de35e6f (patch)
treeddab8c01509f47664c52c8a6b165bb5a974f138f /test/network
parent051bd98751d9d4bc97f93f66723d9b7a00c0cfb4 (diff)
downloadpuppet-9ee56f2e67be973da49b1d3f21de1bf87de35e6f.tar.gz
puppet-9ee56f2e67be973da49b1d3f21de1bf87de35e6f.tar.xz
puppet-9ee56f2e67be973da49b1d3f21de1bf87de35e6f.zip
Code smell: Inconsistent indentation and related formatting issues
* Replaced 163 occurances of defined\? +([@a-zA-Z_.0-9?=]+) with defined?(\1) This makes detecting subsequent patterns easier. 3 Examples: The code: if ! defined? @parse_config becomes: if ! defined?(@parse_config) The code: return @option_parser if defined? @option_parser becomes: return @option_parser if defined?(@option_parser) The code: if defined? @local and @local becomes: if defined?(@local) and @local * Eliminate trailing spaces. Replaced 428 occurances of ^(.*?) +$ with \1 1 file was skipped. test/ral/providers/host/parsed.rb because 0 * Replace leading tabs with an appropriate number of spaces. Replaced 306 occurances of ^(\t+)(.*) with Tabs are not consistently expanded in all environments. * Don't arbitrarily wrap on sprintf (%) operator. Replaced 143 occurances of (.*['"] *%) +(.*) with Splitting the line does nothing to aid clarity and hinders further refactorings. 3 Examples: The code: raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] becomes: raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] The code: Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig] becomes: Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig] The code: $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus] becomes: $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus] * Don't break short arrays/parameter list in two. Replaced 228 occurances of (.*) +(.*) with 3 Examples: The code: puts @format.wrap(type.provider(prov).doc, :indent => 4, :scrub => true) becomes: puts @format.wrap(type.provider(prov).doc, :indent => 4, :scrub => true) The code: assert(FileTest.exists?(daily), "Did not make daily graph for %s" % type) becomes: assert(FileTest.exists?(daily), "Did not make daily graph for %s" % type) The code: assert(prov.target_object(:first).read !~ /^notdisk/, "Did not remove thing from disk") becomes: assert(prov.target_object(:first).read !~ /^notdisk/, "Did not remove thing from disk") * If arguments must wrap, treat them all equally Replaced 510 occurances of lines ending in things like ...(foo, or ...(bar(1,3), with \1 \2 3 Examples: The code: midscope.to_hash(false), becomes: assert_equal( The code: botscope.to_hash(true), becomes: # bottomscope, then checking that we see the right stuff. The code: :path => link, becomes: * Replaced 4516 occurances of ^( *)(.*) with The present code base is supposed to use four-space indentation. In some places we failed to maintain that standard. These should be fixed regardless of the 2 vs. 4 space question. 15 Examples: The code: def run_comp(cmd) puts cmd results = [] old_sync = $stdout.sync $stdout.sync = true line = [] begin open("| #{cmd}", "r") do |f| until f.eof? do c = f.getc becomes: def run_comp(cmd) puts cmd results = [] old_sync = $stdout.sync $stdout.sync = true line = [] begin open("| #{cmd}", "r") do |f| until f.eof? do c = f.getc The code: s.gsub!(/.{4}/n, '\\\\u\&') } string.force_encoding(Encoding::UTF_8) string rescue Iconv::Failure => e raise GeneratorError, "Caught #{e.class}: #{e}" end else def utf8_to_pson(string) # :nodoc: string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] } string.gsub!(/( becomes: s.gsub!(/.{4}/n, '\\\\u\&') } string.force_encoding(Encoding::UTF_8) string rescue Iconv::Failure => e raise GeneratorError, "Caught #{e.class}: #{e}" end else def utf8_to_pson(string) # :nodoc: string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] } string.gsub!(/( The code: end } rvalues: rvalue | rvalues comma rvalue { if val[0].instance_of?(AST::ASTArray) result = val[0].push(val[2]) else result = ast AST::ASTArray, :children => [val[0],val[2]] end } becomes: end } rvalues: rvalue | rvalues comma rvalue { if val[0].instance_of?(AST::ASTArray) result = val[0].push(val[2]) else result = ast AST::ASTArray, :children => [val[0],val[2]] end } The code: #passwdproc = proc { @password } keytext = @key.export( OpenSSL::Cipher::DES.new(:EDE3, :CBC), @password ) File.open(@keyfile, "w", 0400) { |f| f << keytext } becomes: # passwdproc = proc { @password } keytext = @key.export( OpenSSL::Cipher::DES.new(:EDE3, :CBC), @password ) File.open(@keyfile, "w", 0400) { |f| f << keytext } The code: end def to_manifest "%s { '%s':\n%s\n}" % [self.type.to_s, self.name, @params.collect { |p, v| if v.is_a? Array " #{p} => [\'#{v.join("','")}\']" else " #{p} => \'#{v}\'" end }.join(",\n") becomes: end def to_manifest "%s { '%s':\n%s\n}" % [self.type.to_s, self.name, @params.collect { |p, v| if v.is_a? Array " #{p} => [\'#{v.join("','")}\']" else " #{p} => \'#{v}\'" end }.join(",\n") The code: via the augeas tool. Requires: - augeas to be installed (http://www.augeas.net) - ruby-augeas bindings Sample usage with a string:: augeas{\"test1\" : context => \"/files/etc/sysconfig/firstboot\", changes => \"set RUN_FIRSTBOOT YES\", becomes: via the augeas tool. Requires: - augeas to be installed (http://www.augeas.net) - ruby-augeas bindings Sample usage with a string:: augeas{\"test1\" : context => \"/files/etc/sysconfig/firstboot\", changes => \"set RUN_FIRSTBOOT YES\", The code: names.should_not be_include("root") end describe "when generating a purgeable resource" do it "should be included in the generated resources" do Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource] @resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref) end end describe "when the instance's do not have an ensure property" do becomes: names.should_not be_include("root") end describe "when generating a purgeable resource" do it "should be included in the generated resources" do Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource] @resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref) end end describe "when the instance's do not have an ensure property" do The code: describe "when the instance's do not have an ensure property" do it "should not be included in the generated resources" do @no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo') Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource] @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref) end end describe "when the instance's ensure property does not accept absent" do it "should not be included in the generated resources" do @no_absent_resource = Puppet::Type.type(:service).new(:name => 'foobar') becomes: describe "when the instance's do not have an ensure property" do it "should not be included in the generated resources" do @no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo') Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource] @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref) end end describe "when the instance's ensure property does not accept absent" do it "should not be included in the generated resources" do @no_absent_resource = Puppet::Type.type(:service).new(:name => 'foobar') The code: func = nil assert_nothing_raised do func = Puppet::Parser::AST::Function.new( :name => "template", :ftype => :rvalue, :arguments => AST::ASTArray.new( :children => [stringobj(template)] ) becomes: func = nil assert_nothing_raised do func = Puppet::Parser::AST::Function.new( :name => "template", :ftype => :rvalue, :arguments => AST::ASTArray.new( :children => [stringobj(template)] ) The code: assert( @store.allowed?("hostname.madstop.com", "192.168.1.50"), "hostname not allowed") assert( ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"), "subname name allowed") becomes: assert( @store.allowed?("hostname.madstop.com", "192.168.1.50"), "hostname not allowed") assert( ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"), "subname name allowed") The code: assert_nothing_raised { server = Puppet::Network::Handler.fileserver.new( :Local => true, :Config => false ) } becomes: assert_nothing_raised { server = Puppet::Network::Handler.fileserver.new( :Local => true, :Config => false ) } The code: 'yay', { :failonfail => false, :uid => @user.uid, :gid => @user.gid } ).returns('output') output = Puppet::Util::SUIDManager.run_and_capture 'yay', @user.uid, @user.gid becomes: 'yay', { :failonfail => false, :uid => @user.uid, :gid => @user.gid } ).returns('output') output = Puppet::Util::SUIDManager.run_and_capture 'yay', @user.uid, @user.gid The code: ).times(1) pkg.provider.expects( :aptget ).with( '-y', '-q', 'remove', 'faff' becomes: ).times(1) pkg.provider.expects( :aptget ).with( '-y', '-q', 'remove', 'faff' The code: johnny one two billy three four\n" # Just parse and generate, to make sure it's isomorphic. assert_nothing_raised do assert_equal(text, @parser.to_file(@parser.parse(text)), "parsing was not isomorphic") end end def test_valid_attrs becomes: johnny one two billy three four\n" # Just parse and generate, to make sure it's isomorphic. assert_nothing_raised do assert_equal(text, @parser.to_file(@parser.parse(text)), "parsing was not isomorphic") end end def test_valid_attrs The code: "testing", :onboolean => [true, "An on bool"], :string => ["a string", "A string arg"] ) result = [] should = [] assert_nothing_raised("Add args failed") do @config.addargs(result) end @config.each do |name, element| becomes: "testing", :onboolean => [true, "An on bool"], :string => ["a string", "A string arg"] ) result = [] should = [] assert_nothing_raised("Add args failed") do @config.addargs(result) end @config.each do |name, element|
Diffstat (limited to 'test/network')
-rwxr-xr-xtest/network/authconfig.rb20
-rwxr-xr-xtest/network/authorization.rb8
-rwxr-xr-xtest/network/authstore.rb130
-rwxr-xr-xtest/network/client/ca.rb6
-rwxr-xr-xtest/network/handler/ca.rb5
-rwxr-xr-xtest/network/handler/fileserver.rb256
-rwxr-xr-xtest/network/rights.rb5
-rwxr-xr-xtest/network/server/webrick.rb20
-rwxr-xr-xtest/network/xmlrpc/processor.rb3
-rwxr-xr-xtest/network/xmlrpc/server.rb3
-rwxr-xr-xtest/network/xmlrpc/webrick_servlet.rb5
11 files changed, 299 insertions, 162 deletions
diff --git a/test/network/authconfig.rb b/test/network/authconfig.rb
index b619bec7e..6437aefea 100755
--- a/test/network/authconfig.rb
+++ b/test/network/authconfig.rb
@@ -43,16 +43,11 @@ class TestAuthConfig < Test::Unit::TestCase
}
assert_nothing_raised {
- assert(config.allowed?(request("pelementserver.describe",
- "culain.madstop.com", "1.1.1.1")), "Did not allow host")
- assert(! config.allowed?(request("pelementserver.describe",
- "culain.madstop.com", "10.10.1.1")), "Allowed host")
- assert(config.allowed?(request("fileserver.yay",
- "culain.madstop.com", "10.1.1.1")), "Did not allow host to fs")
- assert(! config.allowed?(request("fileserver.yay",
- "culain.madstop.com", "10.10.1.1")), "Allowed host to fs")
- assert(config.allowed?(request("fileserver.list",
- "culain.madstop.com", "10.10.1.1")), "Did not allow host to fs.list")
+ assert(config.allowed?(request("pelementserver.describe", "culain.madstop.com", "1.1.1.1")), "Did not allow host")
+ assert(! config.allowed?(request("pelementserver.describe", "culain.madstop.com", "10.10.1.1")), "Allowed host")
+ assert(config.allowed?(request("fileserver.yay", "culain.madstop.com", "10.1.1.1")), "Did not allow host to fs")
+ assert(! config.allowed?(request("fileserver.yay", "culain.madstop.com", "10.10.1.1")), "Allowed host to fs")
+ assert(config.allowed?(request("fileserver.list", "culain.madstop.com", "10.10.1.1")), "Did not allow host to fs.list")
}
end
@@ -63,7 +58,10 @@ class TestAuthConfig < Test::Unit::TestCase
other = nil
assert_nothing_raised { other = Puppet::Network::AuthConfig.main }
- assert_equal(auth.object_id, other.object_id,
+
+ assert_equal(
+ auth.object_id, other.object_id,
+
"did not get same authconfig from class")
end
end
diff --git a/test/network/authorization.rb b/test/network/authorization.rb
index 3c1f71e49..680d5676d 100755
--- a/test/network/authorization.rb
+++ b/test/network/authorization.rb
@@ -61,8 +61,7 @@ class TestAuthConfig < Test::Unit::TestCase
auth = nil
assert_nothing_raised { auth = obj.send(:authconfig) }
assert(auth, "did not get auth")
- assert_equal(Puppet::Network::AuthConfig.main.object_id, auth.object_id,
- "did not get main authconfig")
+ assert_equal(Puppet::Network::AuthConfig.main.object_id, auth.object_id, "did not get main authconfig")
end
def test_authorize
@@ -84,7 +83,10 @@ class TestAuthConfig < Test::Unit::TestCase
# Now set our run_mode to master, so calls are allowed
Puppet.run_mode.stubs(:master?).returns true
- assert(@obj.authorized?(@request),
+
+ assert(
+ @obj.authorized?(@request),
+
"Denied call with no config file and master")
assert_logged(:debug, /Allowing/, "did not log call")
diff --git a/test/network/authstore.rb b/test/network/authstore.rb
index 93f379164..c225b246b 100755
--- a/test/network/authstore.rb
+++ b/test/network/authstore.rb
@@ -93,9 +93,15 @@ class TestAuthStore < Test::Unit::TestCase
@store.deny("*.sub.madstop.com")
}
- assert(@store.allowed?("hostname.madstop.com", "192.168.1.50"),
+
+ assert(
+ @store.allowed?("hostname.madstop.com", "192.168.1.50"),
+
"hostname not allowed")
- assert(! @store.allowed?("name.sub.madstop.com", "192.168.0.50"),
+
+ assert(
+ ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"),
+
"subname name allowed")
end
@@ -105,9 +111,15 @@ class TestAuthStore < Test::Unit::TestCase
@store.deny("192.168.0.0/24")
}
- assert(@store.allowed?("hostname.madstop.com", "192.168.1.50"),
+
+ assert(
+ @store.allowed?("hostname.madstop.com", "192.168.1.50"),
+
"hostname not allowed")
- assert(! @store.allowed?("hostname.madstop.com", "192.168.0.50"),
+
+ assert(
+ ! @store.allowed?("hostname.madstop.com", "192.168.0.50"),
+
"Host allowed over IP")
end
@@ -128,22 +140,31 @@ class TestAuthStore < Test::Unit::TestCase
def test_store
assert_nothing_raised do
- assert_nil(@store.send(:store, :allow, "*.host.com"),
+
+ assert_nil(
+ @store.send(:store, :allow, "*.host.com"),
+
"store did not return nil")
end
assert_equal([Declaration.new(:allow, "*.host.com")],
- @store.send(:instance_variable_get, "@declarations"),
+ @store.send(:instance_variable_get, "@declarations"),
"Did not store declaration")
# Now add another one and make sure it gets sorted appropriately
assert_nothing_raised do
- assert_nil(@store.send(:store, :allow, "me.host.com"),
+
+ assert_nil(
+ @store.send(:store, :allow, "me.host.com"),
+
"store did not return nil")
end
- assert_equal([
- Declaration.new(:allow, "me.host.com"),
- Declaration.new(:allow, "*.host.com")
+
+ assert_equal(
+ [
+ Declaration.new(:allow, "me.host.com"),
+
+ Declaration.new(:allow, "*.host.com")
],
@store.send(:instance_variable_get, "@declarations"),
"Did not sort declarations")
@@ -160,11 +181,17 @@ class TestAuthStore < Test::Unit::TestCase
store = Puppet::Network::AuthStore.new
assert_nothing_raised do
- assert_nil(store.allow("*"),
+
+ assert_nil(
+ store.allow("*"),
+
"allow did not return nil")
end
- assert(store.globalallow?,
+
+ assert(
+ store.globalallow?,
+
"did not enable global allow")
end
@@ -186,7 +213,10 @@ class TestAuthStore < Test::Unit::TestCase
inval$id
}.each { |pat|
- assert_raise(Puppet::AuthStoreError,
+
+ assert_raise(
+ Puppet::AuthStoreError,
+
"name '%s' was allowed" % pat) {
@store.allow(pat)
}
@@ -216,7 +246,10 @@ class TestAuthStore < Test::Unit::TestCase
@store.allow("domain.*.com")
}
- assert(!@store.allowed?("very.long.domain.name.com", "1.2.3.4"),
+
+ assert(
+ !@store.allowed?("very.long.domain.name.com", "1.2.3.4"),
+
"Long hostname allowed")
assert_raise(Puppet::AuthStoreError) {
@@ -229,14 +262,16 @@ class TestAuthStore < Test::Unit::TestCase
@store.allow("hostname.com")
%w{hostname.com Hostname.COM hostname.Com HOSTNAME.COM}.each do |name|
- assert(@store.allowed?(name, "127.0.0.1"),
- "did not allow %s" % name)
+ assert(@store.allowed?(name, "127.0.0.1"), "did not allow %s" % name)
end
end
def test_allowed?
Puppet[:trace] = false
- assert(@store.allowed?(nil, nil),
+
+ assert(
+ @store.allowed?(nil, nil),
+
"Did not default to true for local checks")
assert_raise(Puppet::DevError, "did not fail on one input") do
@store.allowed?("host.com", nil)
@@ -252,13 +287,19 @@ class TestAuthStore < Test::Unit::TestCase
@store.allow("host.madstop.com")
@store.deny("*.madstop.com")
- assert(@store.allowed?("host.madstop.com", "192.168.0.1"),
+
+ assert(
+ @store.allowed?("host.madstop.com", "192.168.0.1"),
+
"More specific allowal by name failed")
@store.allow("192.168.0.1")
@store.deny("192.168.0.0/24")
- assert(@store.allowed?("host.madstop.com", "192.168.0.1"),
+
+ assert(
+ @store.allowed?("host.madstop.com", "192.168.0.1"),
+
"More specific allowal by ip failed")
end
@@ -344,8 +385,7 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
end
[:name, :pattern, :length].zip(output).each do |method, value|
- assert_equal(value, @decl.send(method),
- "Got incorrect value for %s from %s" % [method, input])
+ assert_equal(value, @decl.send(method), "Got incorrect value for %s from %s" % [method, input])
end
end
@@ -365,14 +405,16 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
def test_result
["allow", :allow].each do |val|
assert_nothing_raised { @decl.type = val }
- assert_equal(true, @decl.result, "did not result to true with %s" %
- val.inspect)
+ assert_equal(true, @decl.result, "did not result to true with %s" % val.inspect)
end
[:deny, "deny"].each do |val|
assert_nothing_raised { @decl.type = val }
- assert_equal(false, @decl.result,
- "did not result to false with %s" % val.inspect)
+
+ assert_equal(
+ false, @decl.result,
+
+ "did not result to false with %s" % val.inspect)
end
["yay", 1, nil, false, true].each do |val|
@@ -391,8 +433,7 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
"*.HOSTNAME.Com" => %w{com hostname *},
}.each do |input, output|
- assert_equal(output, @decl.send(:munge_name, input),
- "munged %s incorrectly" % input)
+ assert_equal(output, @decl.send(:munge_name, input), "munged %s incorrectly" % input)
end
end
@@ -414,10 +455,16 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
ip_exact = Declaration.new(:allow, "192.168.0.1")
ip_range = Declaration.new(:allow, "192.168.0.*")
- assert_equal(-1, host_exact <=> host_range,
+
+ assert_equal(
+ -1, host_exact <=> host_range,
+
"exact name match did not sort first")
- assert_equal(-1, ip_exact <=> ip_range,
+
+ assert_equal(
+ -1, ip_exact <=> ip_range,
+
"exact ip match did not sort first")
# Next make sure we sort by length
@@ -431,10 +478,12 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
assert_equal(-1, ip24 <=> ip16, "/16 sorted before /24 in ip with masks")
# Make sure ip checks sort before host checks
- assert_equal(-1, ip_exact <=> host_exact,
- "IP exact did not sort before host exact")
+ assert_equal(-1, ip_exact <=> host_exact, "IP exact did not sort before host exact")
+
+
+ assert_equal(
+ -1, ip_range <=> host_range,
- assert_equal(-1, ip_range <=> host_range,
"IP range did not sort before host range")
host_long = Declaration.new(:allow, "*.domain.host.com")
@@ -447,20 +496,21 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
assert_equal(-1, host_deny <=> host_exact, "deny did not sort before allow when exact")
host_range_deny = Declaration.new(:deny, "*.host.com")
- assert_equal(-1, host_range_deny <=> host_range,
- "deny did not sort before allow when ranged")
+ assert_equal(-1, host_range_deny <=> host_range, "deny did not sort before allow when ranged")
ip_allow = Declaration.new(:allow, "192.168.0.0/16")
ip_deny = Declaration.new(:deny, "192.168.0.0/16")
- assert_equal(-1, ip_deny <=> ip_allow,
+
+ assert_equal(
+ -1, ip_deny <=> ip_allow,
+
"deny did not sort before allow in ip range")
%w{host.com *.domain.com 192.168.0.1 192.168.0.1/24}.each do |decl|
assert_equal(0, Declaration.new(:allow, decl) <=>
Declaration.new(:allow, decl),
- "Equivalent declarations for %s were considered different" %
- decl
+ "Equivalent declarations for %s were considered different" % decl
)
end
end
@@ -481,10 +531,8 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
assert(! host.send(:matchname?, "yay.com"), "incorrect match")
domain = Declaration.new(:allow, "*.domain.com")
- %w{host.domain.com domain.com very.long.domain.com very-long.domain.com
- }.each do |name|
- assert(domain.send(:matchname?, name),
- "Did not match %s" % name)
+ %w{host.domain.com domain.com very.long.domain.com very-long.domain.com }.each do |name|
+ assert(domain.send(:matchname?, name), "Did not match %s" % name)
end
end
end
diff --git a/test/network/client/ca.rb b/test/network/client/ca.rb
index 1741c850a..ae81547db 100755
--- a/test/network/client/ca.rb
+++ b/test/network/client/ca.rb
@@ -23,8 +23,7 @@ class TestClientCA < Test::Unit::TestCase
end
[:hostprivkey, :hostcert, :localcacert].each do |name|
- assert(FileTest.exists?(Puppet.settings[name]),
- "Did not create cert %s" % name)
+ assert(FileTest.exists?(Puppet.settings[name]), "Did not create cert %s" % name)
end
end
@@ -64,8 +63,7 @@ class TestClientCA < Test::Unit::TestCase
end
# And then make sure the cert isn't written to disk
- assert(! FileTest.exists?(Puppet[:hostcert]),
- "Invalid cert got written to disk")
+ assert(! FileTest.exists?(Puppet[:hostcert]), "Invalid cert got written to disk")
end
end
diff --git a/test/network/handler/ca.rb b/test/network/handler/ca.rb
index 503d0188d..4d1531228 100755
--- a/test/network/handler/ca.rb
+++ b/test/network/handler/ca.rb
@@ -191,8 +191,11 @@ class TestCA < Test::Unit::TestCase
server = nil
Puppet.stubs(:master?).returns true
assert_nothing_raised {
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @@port,
+
:Handlers => {
:CA => {}, # so that certs autogenerate
:Status => nil
diff --git a/test/network/handler/fileserver.rb b/test/network/handler/fileserver.rb
index f17d82bf6..357192716 100755
--- a/test/network/handler/fileserver.rb
+++ b/test/network/handler/fileserver.rb
@@ -72,8 +72,11 @@ class TestFileServer < Test::Unit::TestCase
def test_namefailures
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -95,8 +98,11 @@ class TestFileServer < Test::Unit::TestCase
# and make our fileserver
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -129,8 +135,11 @@ class TestFileServer < Test::Unit::TestCase
file = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -183,8 +192,11 @@ class TestFileServer < Test::Unit::TestCase
checks = Puppet::Network::Handler.fileserver::CHECKPARAMS
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -221,8 +233,11 @@ class TestFileServer < Test::Unit::TestCase
def test_mountroot
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -250,8 +265,11 @@ class TestFileServer < Test::Unit::TestCase
def test_recursionlevels
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -301,8 +319,11 @@ class TestFileServer < Test::Unit::TestCase
def test_listedpath
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -344,8 +365,11 @@ class TestFileServer < Test::Unit::TestCase
def test_widelists
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -384,8 +408,11 @@ class TestFileServer < Test::Unit::TestCase
checks = Puppet::Network::Handler.fileserver::CHECKPARAMS
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -425,7 +452,10 @@ class TestFileServer < Test::Unit::TestCase
# Now try to describe some sources that don't even exist
retval = nil
- assert_raise(Puppet::Network::Handler::FileServerError,
+
+ assert_raise(
+ Puppet::Network::Handler::FileServerError,
+
"Describing non-existent mount did not raise an error") {
retval = server.describe("/notmounted/" + "noexisties")
}
@@ -480,14 +510,17 @@ class TestFileServer < Test::Unit::TestCase
path #{basedir}/those
"
- }
+ }
- # create a server with the file
- assert_nothing_raised {
- server = Puppet::Network::Handler.fileserver.new(
- :Local => false,
- :Config => conffile
+ # create a server with the file
+ assert_nothing_raised {
+
+ server = Puppet::Network::Handler.fileserver.new(
+
+ :Local => false,
+
+ :Config => conffile
)
}
@@ -545,15 +578,16 @@ class TestFileServer < Test::Unit::TestCase
case type
when :deny
- assert_raise(Puppet::AuthorizationError,
- "Host %s, ip %s, allowed %s" %
- [host, ip, mount]) {
+
+ assert_raise(
+ Puppet::AuthorizationError,
+
+ "Host %s, ip %s, allowed %s" % [host, ip, mount]) {
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, :manage, true, false, host, ip)
+ assert_nothing_raised("Host %s, ip %s, denied %s" % [host, ip, mount]) {
+ list = server.list(mount, :manage, true, false, host, ip)
}
end
}
@@ -574,8 +608,8 @@ class TestFileServer < Test::Unit::TestCase
"
}
- invalidconfigs = [
-"[not valid]
+ invalidconfigs = [
+ "[not valid]
path /this/path/does/not/exist
allow 192.168.0.*
",
@@ -589,24 +623,30 @@ class TestFileServer < Test::Unit::TestCase
"
]
- invalidmounts.each { |mount, text|
- File.open(conffile, "w") { |f|
- f.print text
+ 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::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => conffile
)
}
- assert_raise(Puppet::Network::Handler::FileServerError,
- "Invalid mount was mounted") {
- server.list(mount, :manage)
+
+ assert_raise(
+ Puppet::Network::Handler::FileServerError,
+
+ "Invalid mount was mounted") {
+ server.list(mount, :manage)
}
}
@@ -618,11 +658,17 @@ class TestFileServer < Test::Unit::TestCase
# create a server with the file
server = nil
- assert_raise(Puppet::Network::Handler::FileServerError,
- "Invalid config %s did not raise error" % i) {
- server = Puppet::Network::Handler.fileserver.new(
- :Local => true,
- :Config => conffile
+
+ assert_raise(
+ Puppet::Network::Handler::FileServerError,
+
+ "Invalid config %s did not raise error" % i) {
+
+ server = Puppet::Network::Handler.fileserver.new(
+
+ :Local => true,
+
+ :Config => conffile
)
}
}
@@ -643,29 +689,34 @@ class TestFileServer < Test::Unit::TestCase
path #{dir}
allow test1.domain.com
"
- }
+ }
- # Reset the timeout, so we reload faster
- Puppet[:filetimeout] = 0.5
+ # Reset the timeout, so we reload faster
+ Puppet[:filetimeout] = 0.5
- # start our server with a fast timeout
- assert_nothing_raised {
- server = Puppet::Network::Handler.fileserver.new(
- :Local => false,
- :Config => conffile
+ # start our server with a fast timeout
+ assert_nothing_raised {
+
+ server = Puppet::Network::Handler.fileserver.new(
+
+ :Local => false,
+
+ :Config => conffile
)
}
list = nil
assert_nothing_raised {
- list = server.list("/thing/", :manage, 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/", :manage, false, false,
- "test2.domain.com", "127.0.0.1")
+ list = server.list("/thing/", :manage, false, false, "test2.domain.com", "127.0.0.1")
}
sleep 1
@@ -676,16 +727,14 @@ class TestFileServer < Test::Unit::TestCase
path #{dir}
allow test2.domain.com
"
- }
+ }
- assert_raise(Puppet::AuthorizationError, "List allowed invalid host") {
- list = server.list("/thing/", :manage, false, false,
- "test1.domain.com", "127.0.0.1")
+ assert_raise(Puppet::AuthorizationError, "List allowed invalid host") {
+ list = server.list("/thing/", :manage, false, false, "test1.domain.com", "127.0.0.1")
}
assert_nothing_raised {
- list = server.list("/thing/", :manage, false, false,
- "test2.domain.com", "127.0.0.1")
+ list = server.list("/thing/", :manage, false, false, "test2.domain.com", "127.0.0.1")
}
assert(list != "", "List returned nothing in rereard test")
@@ -716,8 +765,11 @@ class TestFileServer < Test::Unit::TestCase
File.open(file, "w") { |f| f.puts "yay" }
File.symlink(file, link)
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -773,8 +825,7 @@ class TestFileServer < Test::Unit::TestCase
client1_hostdir => "client1\n",
client2_fqdndir => client2 + "\n"
}
- [fsdir, hostdir, fqdndir,
- client1_hostdir, client2_fqdndir].each { |d| Dir.mkdir(d) }
+ [fsdir, hostdir, fqdndir, client1_hostdir, client2_fqdndir].each { |d| Dir.mkdir(d) }
[client1_hostdir, client2_fqdndir].each do |d|
File.open(File.join(d, "file.txt"), "w") do |f|
@@ -791,13 +842,16 @@ allow *
path #{fqdndir}/%H
allow *
")
- end
+ end
- server = nil
- assert_nothing_raised {
- server = Puppet::Network::Handler.fileserver.new(
- :Local => true,
- :Config => conffile
+ server = nil
+ assert_nothing_raised {
+
+ server = Puppet::Network::Handler.fileserver.new(
+
+ :Local => true,
+
+ :Config => conffile
)
}
@@ -938,34 +992,37 @@ allow *
# Do a round of checks with a fake client
client = "host.domain.com"
{"%h" => "host", # Short name
- "%H" => client, # Full name
- "%d" => "domain.com", # domain
- "%%" => "%", # escape
- "%o" => "%o" # other
- }.each do |pat, repl|
- result = check.call(client, pat, repl)
- end
+ "%H" => client, # Full name
+ "%d" => "domain.com", # domain
+ "%%" => "%", # escape
+ "%o" => "%o" # other
+ }.each do |pat, repl|
+ result = check.call(client, pat, repl)
+ end
# Now, check that they use Facter info
client = nil
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(:to_hash).returns({
- :ipaddress => "127.0.0.1",
- :hostname => "myhost",
- :domain => "mydomain.com",
+
+ Facter.stubs(:to_hash).returns(
+ {
+ :ipaddress => "127.0.0.1",
+ :hostname => "myhost",
+ :domain => "mydomain.com",
+
})
{"%h" => "myhost", # Short name
- "%H" => "myhost.mydomain.com", # Full name
- "%d" => "mydomain.com", # domain
- "%%" => "%", # escape
- "%o" => "%o" # other
- }.each do |pat, repl|
- check.call(client, pat, repl)
- end
+ "%H" => "myhost.mydomain.com", # Full name
+ "%d" => "mydomain.com", # domain
+ "%%" => "%", # escape
+ "%o" => "%o" # other
+ }.each do |pat, repl|
+ check.call(client, pat, repl)
+ end
end
@@ -973,8 +1030,11 @@ allow *
def test_fileserver_expansion
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -986,11 +1046,14 @@ allow *
ip = '127.0.0.1'
- Facter.stubs(:to_hash).returns({
- :kernel => kernel_fact,
- :ipaddress => "127.0.0.1",
- :hostname => "myhost",
- :domain => "mydomain.com",
+
+ Facter.stubs(:to_hash).returns(
+ {
+ :kernel => kernel_fact,
+ :ipaddress => "127.0.0.1",
+ :hostname => "myhost",
+ :domain => "mydomain.com",
+
})
Dir.mkdir(dir)
@@ -1047,7 +1110,7 @@ allow *
File::open(file, "w") { |f| f.print name }
end
- Puppet::Module::find(name)
+ Puppet::Module::find(name)
end
conffile = tempfile
@@ -1057,8 +1120,11 @@ allow *
# create a server with the file
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler::FileServer.new(
+
:Local => false ,
+
:Config => conffile
)
}
@@ -1080,8 +1146,7 @@ allow *
end
assert_nothing_raised("Host 'allow' denied #{mount}") {
- server.list(mount, :manage, true, false,
- 'allow.example.com', "192.168.0.1")
+ server.list(mount, :manage, true, false, 'allow.example.com', "192.168.0.1")
}
end
end
@@ -1109,14 +1174,17 @@ allow *
path #{basedir}/thing
allow 192.168.0.*
"
- }
+ }
- # create a server with the file
- server = nil
- assert_nothing_raised {
- server = Puppet::Network::Handler::FileServer.new(
- :Local => false,
- :Config => conffile
+ # create a server with the file
+ server = nil
+ assert_nothing_raised {
+
+ server = Puppet::Network::Handler::FileServer.new(
+
+ :Local => false,
+
+ :Config => conffile
)
}
@@ -1136,14 +1204,15 @@ allow *
assert_describe(mount, file, server)
# now let's check that things are being correctly forbidden
- assert_raise(Puppet::AuthorizationError,
- "Host 'deny' allowed #{mount}") {
- server.list(mount, :manage, true, false,
- 'deny.example.com', "192.168.1.1")
+
+ assert_raise(
+ Puppet::AuthorizationError,
+
+ "Host 'deny' allowed #{mount}") {
+ server.list(mount, :manage, true, false, 'deny.example.com', "192.168.1.1")
}
assert_nothing_raised("Host 'allow' denied #{mount}") {
- server.list(mount, :manage, true, false,
- 'allow.example.com', "192.168.0.1")
+ server.list(mount, :manage, true, false, 'allow.example.com', "192.168.0.1")
}
end
@@ -1161,8 +1230,11 @@ allow *
].each do |failer|
File.open(config, "w") { |f| f.puts failer }
assert_raise(Puppet::Network::Handler::FileServerError, "Did not fail on %s" % failer.inspect) {
+
server = Puppet::Network::Handler::FileServer.new(
+
:Local => false,
+
:Config => config
)
}
@@ -1172,8 +1244,8 @@ allow *
def test_can_start_without_configuration
Puppet[:fileserverconfig] = tempfile
assert_nothing_raised("Could not create fileserver when configuration is absent") do
- server = Puppet::Network::Handler::FileServer.new(
- :Local => false
+ server = Puppet::Network::Handler::FileServer.new(
+ :Local => false
)
end
end
diff --git a/test/network/rights.rb b/test/network/rights.rb
index 71b8c3765..80d6ceafe 100755
--- a/test/network/rights.rb
+++ b/test/network/rights.rb
@@ -23,7 +23,10 @@ class TestRights < Test::Unit::TestCase
@store.newright(:write)
}
- assert(! @store.allowed?(:write, "host.madstop.com", "0.0.0.0"),
+
+ assert(
+ ! @store.allowed?(:write, "host.madstop.com", "0.0.0.0"),
+
"Defaulted to allowing access")
assert_nothing_raised {
diff --git a/test/network/server/webrick.rb b/test/network/server/webrick.rb
index e2493b424..7fd362b39 100755
--- a/test/network/server/webrick.rb
+++ b/test/network/server/webrick.rb
@@ -24,8 +24,11 @@ class TestWebrickServer < Test::Unit::TestCase
def test_basics
server = nil
assert_raise(Puppet::Error, "server succeeded with no cert") do
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @@port,
+
:Handlers => {
:Status => nil
}
@@ -33,8 +36,11 @@ class TestWebrickServer < Test::Unit::TestCase
end
assert_nothing_raised("Could not create simple server") do
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @@port,
+
:Handlers => {
:CA => {}, # so that certs autogenerate
:Status => nil
@@ -70,8 +76,11 @@ class TestWebrickServer < Test::Unit::TestCase
client = nil
assert_nothing_raised() {
- client = Puppet::Network::Client.status.new(
+
+ client = Puppet::Network::Client.status.new(
+
:Server => "localhost",
+
:Port => @@port
)
}
@@ -82,8 +91,11 @@ class TestWebrickServer < Test::Unit::TestCase
server = nil
Puppet[:certdnsnames] = "localhost"
assert_nothing_raised() {
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @@port,
+
:Handlers => {
:CA => {}, # so that certs autogenerate
:Status => nil
diff --git a/test/network/xmlrpc/processor.rb b/test/network/xmlrpc/processor.rb
index 079194efa..0b0646728 100755
--- a/test/network/xmlrpc/processor.rb
+++ b/test/network/xmlrpc/processor.rb
@@ -65,8 +65,7 @@ class TestXMLRPCProcessor < Test::Unit::TestCase
request.expects(:method=).with("mymethod")
@processor.stubs(:verify)
- @processor.expects(:handle).with(request.call,
- "params", request.name, request.ip)
+ @processor.expects(:handle).with(request.call, "params", request.name, request.ip)
@processor.send(:process, ["myhandler.mymethod", ["params"]], request)
end
diff --git a/test/network/xmlrpc/server.rb b/test/network/xmlrpc/server.rb
index ae9f17ddf..88652a261 100755
--- a/test/network/xmlrpc/server.rb
+++ b/test/network/xmlrpc/server.rb
@@ -18,8 +18,7 @@ class TestXMLRPCServer < Test::Unit::TestCase
assert(@server.get_service_hook, "no service hook defined")
assert_nothing_raised("Did not init @loadedhandlers") do
- assert(! @server.handler_loaded?(:puppetca),
- "server thinks handlers are loaded")
+ assert(! @server.handler_loaded?(:puppetca), "server thinks handlers are loaded")
end
end
end
diff --git a/test/network/xmlrpc/webrick_servlet.rb b/test/network/xmlrpc/webrick_servlet.rb
index 1d83d36ad..d3daa4c0d 100755
--- a/test/network/xmlrpc/webrick_servlet.rb
+++ b/test/network/xmlrpc/webrick_servlet.rb
@@ -24,7 +24,10 @@ class TestXMLRPCWEBrickServlet < Test::Unit::TestCase
assert(servlet.get_service_hook, "service hook was not set up")
- assert(servlet.handler_loaded?(:puppetca),
+
+ assert(
+ servlet.handler_loaded?(:puppetca),
+
"Did not load handler")
end
end