diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-06-11 18:07:34 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-06-11 18:07:34 +0000 |
| commit | c826be96f30f209895083a74eabf8ee1d329bd28 (patch) | |
| tree | 366b83d932cd0141c2551640c8e8d210f807a85b /test/network/server | |
| parent | b50c85dc0fb24b69255feaed91183cb5fde578a0 (diff) | |
| download | puppet-c826be96f30f209895083a74eabf8ee1d329bd28.tar.gz puppet-c826be96f30f209895083a74eabf8ee1d329bd28.tar.xz puppet-c826be96f30f209895083a74eabf8ee1d329bd28.zip | |
Adding a simple unit test for mongrel, and adding the ability to select the header used to store the client SSL dn.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2558 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/network/server')
| -rwxr-xr-x | test/network/server/mongrel_test.rb | 66 | ||||
| -rwxr-xr-x | test/network/server/webrick.rb | 2 |
2 files changed, 67 insertions, 1 deletions
diff --git a/test/network/server/mongrel_test.rb b/test/network/server/mongrel_test.rb new file mode 100755 index 000000000..992ac6940 --- /dev/null +++ b/test/network/server/mongrel_test.rb @@ -0,0 +1,66 @@ +#!/usr/bin/env ruby + +$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ + +require 'puppettest' +require 'puppet/network/server/mongrel' + +class TestMongrelServer < PuppetTest::TestCase + confine "Missing mongrel" => Puppet.features.mongrel? + + include PuppetTest::ServerTest + + def mkserver(handlers = nil) + handlers ||= { :Status => nil } + mongrel = Puppet::Network::Server::Mongrel.new(handlers) + end + + # Make sure client info is correctly extracted. + def test_client_info + obj = Object.new + obj.metaclass.send(:attr_accessor, :params) + params = {} + obj.params = params + + mongrel = mkserver + + ip = Facter.value(:ipaddress) + params["REMOTE_ADDR"] = ip + params[Puppet[:ssl_client_header]] = "/CN=host.domain.com" + + info = nil + assert_nothing_raised("Could not call client_info") do + info = mongrel.send(:client_info, obj) + end + + assert(info.authenticated?, "Client info object was not marked valid even though the header was present") + assert_equal(ip, info.ip, "Did not copy over ip correctly") + assert_equal("host.domain.com", info.name, "Did not copy over hostname correctly") + + # Now try it with a different header name + params.delete(Puppet[:ssl_client_header]) + Puppet[:ssl_client_header] = "header_testing" + params["header_testing"] = "/CN=other.domain.com" + info = nil + assert_nothing_raised("Could not call client_info with other header") do + info = mongrel.send(:client_info, obj) + end + + assert(info.authenticated?, "Client info object was not marked valid even though the header was present") + assert_equal(ip, info.ip, "Did not copy over ip correctly") + assert_equal("other.domain.com", info.name, "Did not copy over hostname correctly") + + # Now make sure it's considered invalid without that header + params.delete("header_testing") + info = nil + assert_nothing_raised("Could not call client_info with no header") do + info = mongrel.send(:client_info, obj) + end + + assert(! info.authenticated?, "Client info object was marked valid without header") + assert_equal(ip, info.ip, "Did not copy over ip correctly") + assert_equal(Resolv.getname(ip), info.name, "Did not look up hostname correctly") + end +end + +# $Id$ diff --git a/test/network/server/webrick.rb b/test/network/server/webrick.rb index bfa5cc3ef..3404a5089 100755 --- a/test/network/server/webrick.rb +++ b/test/network/server/webrick.rb @@ -5,7 +5,7 @@ $:.unshift("../../lib") if __FILE__ =~ /\.rb$/ require 'puppettest' require 'puppet/network/server/webrick' -class TestServer < Test::Unit::TestCase +class TestWebrickServer < Test::Unit::TestCase include PuppetTest::ServerTest # Make sure we can create a server, and that it knows how to create its |
