summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-30 23:17:40 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-30 23:17:40 +0000
commit4615e3a70cf53ba62a00d5d8f01a6d0ec9dffc26 (patch)
tree87245a7401376531048c90e6b8afcddf1b1a452a /test
parentca5d0682705a3b5ee175e25b6cb5fca939a85443 (diff)
Fixing Client.read_cert so that it automatically adds the certificate information to the driver when the certificate is correctly read. This makes sure the Net::Http instance has the cert all set up.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2375 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/network/client/client.rb47
1 files changed, 41 insertions, 6 deletions
diff --git a/test/network/client/client.rb b/test/network/client/client.rb
index 91f2f25af..75f36c81b 100755
--- a/test/network/client/client.rb
+++ b/test/network/client/client.rb
@@ -3,10 +3,18 @@
$:.unshift("../../lib") if __FILE__ =~ /\.rb$/
require 'puppettest'
+require 'mocha'
require 'puppet/network/client'
class TestClient < Test::Unit::TestCase
include PuppetTest::ServerTest
+ class FakeClient < Puppet::Network::Client
+ @drivername = :Test
+ end
+
+ class FakeDriver
+ end
+
# a single run through of connect, auth, etc.
def disabled_test_sslInitWithAutosigningLocalServer
# autosign everything, for simplicity
@@ -180,10 +188,10 @@ class TestClient < Test::Unit::TestCase
libdir = File.join([dir, %w{puppet network client}].flatten)
FileUtils.mkdir_p(libdir)
- file = File.join(libdir, "fake.rb")
+ file = File.join(libdir, "faker.rb")
File.open(file, "w") do |f|
f.puts %{class Puppet::Network::Client
- class Fake < Client
+ class Faker < Client
end
end
}
@@ -194,16 +202,16 @@ class TestClient < Test::Unit::TestCase
client = nil
assert_nothing_raised do
- client = Puppet::Network::Client.client(:fake)
+ client = Puppet::Network::Client.client(:faker)
end
+ assert(client, "did not load client")
assert_nothing_raised do
- assert_equal(client, Puppet::Network::Client.fake,
+ assert_equal(client, Puppet::Network::Client.faker,
"Did not get client back from client method")
end
- assert(client, "did not load client")
# Now make sure the client behaves correctly
- assert_equal(:Fake, client.name, "name was not calculated correctly")
+ assert_equal(:Faker, client.name, "name was not calculated correctly")
end
# Make sure we get a client class for each handler type.
@@ -219,6 +227,33 @@ class TestClient < Test::Unit::TestCase
end
end
end
+
+ # Make sure that reading the cert in also sets up the cert stuff for the driver
+ def test_read_cert
+ ca = Puppet::Network::Handler.ca.new
+ caclient = Puppet::Network::Client.ca.new :CA => ca
+
+ caclient.request_cert
+
+ # First make sure it doesn't get called when the driver doesn't support :cert_setup
+ client = FakeClient.new :Test => FakeDriver.new
+ driver = client.driver
+
+ assert_nothing_raised("Could not read cert") do
+ client.read_cert
+ end
+
+ # And then that it does when the driver supports it
+ client = FakeClient.new :Test => FakeDriver.new
+
+ driver = client.driver
+ driver.meta_def(:cert_setup) { |c| }
+ driver.expects(:cert_setup).with(client)
+
+ assert_nothing_raised("Could not read cert") do
+ client.read_cert
+ end
+ end
end
# $Id$