summaryrefslogtreecommitdiffstats
path: root/test/network/client
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:12:17 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:12:17 -0700
commit3180b9d9b2c844dade1d361326600f7001ec66dd (patch)
tree98fe7c5ac7eb942aac9c39f019a17b0b3f5a57f4 /test/network/client
parent543225970225de5697734bfaf0a6eee996802c04 (diff)
downloadpuppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.gz
puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.xz
puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.zip
Code smell: Two space indentation
Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
Diffstat (limited to 'test/network/client')
-rwxr-xr-xtest/network/client/ca.rb92
-rwxr-xr-xtest/network/client/dipper.rb42
2 files changed, 67 insertions, 67 deletions
diff --git a/test/network/client/ca.rb b/test/network/client/ca.rb
index 27350831a..5037fe48d 100755
--- a/test/network/client/ca.rb
+++ b/test/network/client/ca.rb
@@ -8,62 +8,62 @@ require 'puppet/network/client/ca'
require 'puppet/sslcertificates/support'
class TestClientCA < Test::Unit::TestCase
- include PuppetTest::ServerTest
+ include PuppetTest::ServerTest
- def setup
- Puppet::Util::SUIDManager.stubs(:asuser).yields
- super
- @ca = Puppet::Network::Handler.ca.new
- @client = Puppet::Network::Client.ca.new :CA => @ca
- end
-
- def test_request_cert
- assert_nothing_raised("Could not request cert") do
- @client.request_cert
- end
+ def setup
+ Puppet::Util::SUIDManager.stubs(:asuser).yields
+ super
+ @ca = Puppet::Network::Handler.ca.new
+ @client = Puppet::Network::Client.ca.new :CA => @ca
+ end
- [:hostprivkey, :hostcert, :localcacert].each do |name|
- assert(FileTest.exists?(Puppet.settings[name]), "Did not create cert #{name}")
- end
+ def test_request_cert
+ assert_nothing_raised("Could not request cert") do
+ @client.request_cert
end
- # Make sure the ca defaults to specific ports and names
- def test_ca_server
- Puppet.settings.stubs(:value).returns "eh"
- Puppet.settings.expects(:value).with(:ca_server).returns("myca")
- Puppet.settings.expects(:value).with(:ca_port).returns(321)
- Puppet.settings.stubs(:value).with(:http_proxy_host).returns(nil)
- Puppet.settings.stubs(:value).with(:http_proxy_port).returns(nil)
- Puppet.settings.stubs(:value).with(:http_keepalive).returns(false)
- Puppet.settings.stubs(:value).with(:configtimeout).returns(180)
-
- # Just throw an error; the important thing is the values, not what happens next.
- Net::HTTP.stubs(:new).with("myca", 321, nil, nil).raises(ArgumentError)
- assert_raise(ArgumentError) { Puppet::Network::Client.ca.new }
+ [:hostprivkey, :hostcert, :localcacert].each do |name|
+ assert(FileTest.exists?(Puppet.settings[name]), "Did not create cert #{name}")
end
+ end
- # #578
- def test_invalid_certs_are_not_written
- # Run the get once, which should be valid
+ # Make sure the ca defaults to specific ports and names
+ def test_ca_server
+ Puppet.settings.stubs(:value).returns "eh"
+ Puppet.settings.expects(:value).with(:ca_server).returns("myca")
+ Puppet.settings.expects(:value).with(:ca_port).returns(321)
+ Puppet.settings.stubs(:value).with(:http_proxy_host).returns(nil)
+ Puppet.settings.stubs(:value).with(:http_proxy_port).returns(nil)
+ Puppet.settings.stubs(:value).with(:http_keepalive).returns(false)
+ Puppet.settings.stubs(:value).with(:configtimeout).returns(180)
- assert_nothing_raised("Could not get a certificate") do
- @client.request_cert
- end
+ # Just throw an error; the important thing is the values, not what happens next.
+ Net::HTTP.stubs(:new).with("myca", 321, nil, nil).raises(ArgumentError)
+ assert_raise(ArgumentError) { Puppet::Network::Client.ca.new }
+ end
- # Now remove the cert and keys, so we get a broken cert
- File.unlink(Puppet[:hostcert])
- File.unlink(Puppet[:localcacert])
- File.unlink(Puppet[:hostprivkey])
+ # #578
+ def test_invalid_certs_are_not_written
+ # Run the get once, which should be valid
- @client = Puppet::Network::Client.ca.new :CA => @ca
- @ca.expects(:getcert).returns("yay") # not a valid cert
- # Now make sure it fails, since we'll get the old cert but have new keys
- assert_raise(Puppet::Network::Client::CA::InvalidCertificate, "Did not fail on invalid cert") do
- @client.request_cert
- end
+ assert_nothing_raised("Could not get a certificate") do
+ @client.request_cert
+ end
+
+ # Now remove the cert and keys, so we get a broken cert
+ File.unlink(Puppet[:hostcert])
+ File.unlink(Puppet[:localcacert])
+ File.unlink(Puppet[:hostprivkey])
- # And then make sure the cert isn't written to disk
- assert(! FileTest.exists?(Puppet[:hostcert]), "Invalid cert got written to disk")
+ @client = Puppet::Network::Client.ca.new :CA => @ca
+ @ca.expects(:getcert).returns("yay") # not a valid cert
+ # Now make sure it fails, since we'll get the old cert but have new keys
+ assert_raise(Puppet::Network::Client::CA::InvalidCertificate, "Did not fail on invalid cert") do
+ @client.request_cert
end
+
+ # And then make sure the cert isn't written to disk
+ assert(! FileTest.exists?(Puppet[:hostcert]), "Invalid cert got written to disk")
+ end
end
diff --git a/test/network/client/dipper.rb b/test/network/client/dipper.rb
index 17298c45b..d4f784628 100755
--- a/test/network/client/dipper.rb
+++ b/test/network/client/dipper.rb
@@ -6,29 +6,29 @@ require 'puppettest'
require 'puppet/file_bucket/dipper'
class TestDipperClient < Test::Unit::TestCase
- include PuppetTest::ServerTest
-
- def setup
- super
- @dipper = Puppet::FileBucket::Dipper.new(:Path => tempfile)
+ include PuppetTest::ServerTest
+
+ def setup
+ super
+ @dipper = Puppet::FileBucket::Dipper.new(:Path => tempfile)
+ end
+
+ # Make sure we can create a new file with 'restore'.
+ def test_restore_to_new_file
+ file = tempfile
+ text = "asdf;lkajseofiqwekj"
+ File.open(file, "w") { |f| f.puts text }
+ md5 = nil
+ assert_nothing_raised("Could not send file") do
+ md5 = @dipper.backup(file)
end
- # Make sure we can create a new file with 'restore'.
- def test_restore_to_new_file
- file = tempfile
- text = "asdf;lkajseofiqwekj"
- File.open(file, "w") { |f| f.puts text }
- md5 = nil
- assert_nothing_raised("Could not send file") do
- md5 = @dipper.backup(file)
- end
-
- newfile = tempfile
- assert_nothing_raised("could not restore to new path") do
- @dipper.restore(newfile, md5)
- end
-
- assert_equal(File.read(file), File.read(newfile), "did not restore correctly")
+ newfile = tempfile
+ assert_nothing_raised("could not restore to new path") do
+ @dipper.restore(newfile, md5)
end
+
+ assert_equal(File.read(file), File.read(newfile), "did not restore correctly")
+ end
end