diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-06 19:03:05 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-06 19:03:05 +0000 |
commit | 46d344b9daa24047b60183cc94509d306b6b562a (patch) | |
tree | 3c11eaad696ba3d6e6dd40bd7b9e7d1a4a71af85 /test/network/authconfig.rb | |
parent | 68233706a9ff05be8fa8ab3ab7198cd0918517d6 (diff) | |
download | puppet-46d344b9daa24047b60183cc94509d306b6b562a.tar.gz puppet-46d344b9daa24047b60183cc94509d306b6b562a.tar.xz puppet-46d344b9daa24047b60183cc94509d306b6b562a.zip |
Merging the webserver_portability branch from version 2182 to version 2258.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2259 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/network/authconfig.rb')
-rwxr-xr-x | test/network/authconfig.rb | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/test/network/authconfig.rb b/test/network/authconfig.rb new file mode 100755 index 000000000..2f99f0ede --- /dev/null +++ b/test/network/authconfig.rb @@ -0,0 +1,72 @@ +#!/usr/bin/env ruby + +$:.unshift("../lib") if __FILE__ =~ /\.rb$/ + +require 'puppettest' + +require 'puppet/network/authconfig' + +class TestAuthConfig < Test::Unit::TestCase + include PuppetTest + + def request(call, client, ip) + r = Puppet::Network::ClientRequest.new(client, ip, false) + h, m = call.split(".") + r.handler = h + r.method = m + r + end + + def test_parsingconfigfile + file = tempfile() + assert(Puppet[:authconfig], "No config path") + + Puppet[:authconfig] = file + + File.open(file, "w") { |f| + f.puts "[pelementserver.describe] + allow *.madstop.com + deny 10.10.1.1 + +[fileserver] + allow *.madstop.com + deny 10.10.1.1 + +[fileserver.list] + allow 10.10.1.1 +" + } + + config = nil + assert_nothing_raised { + config = Puppet::Network::AuthConfig.new(file) + } + + 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") + } + end + + def test_singleton + auth = nil + assert_nothing_raised { auth = Puppet::Network::AuthConfig.main } + assert(auth, "did not get main authconfig") + + other = nil + assert_nothing_raised { other = Puppet::Network::AuthConfig.main } + assert_equal(auth.object_id, other.object_id, + "did not get same authconfig from class") + end +end + +# $Id$ + |