summaryrefslogtreecommitdiffstats
path: root/test/network/xmlrpc/processor.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-06 19:03:05 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-06 19:03:05 +0000
commit46d344b9daa24047b60183cc94509d306b6b562a (patch)
tree3c11eaad696ba3d6e6dd40bd7b9e7d1a4a71af85 /test/network/xmlrpc/processor.rb
parent68233706a9ff05be8fa8ab3ab7198cd0918517d6 (diff)
downloadpuppet-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/xmlrpc/processor.rb')
-rwxr-xr-xtest/network/xmlrpc/processor.rb80
1 files changed, 80 insertions, 0 deletions
diff --git a/test/network/xmlrpc/processor.rb b/test/network/xmlrpc/processor.rb
new file mode 100755
index 000000000..7ccd52131
--- /dev/null
+++ b/test/network/xmlrpc/processor.rb
@@ -0,0 +1,80 @@
+#!/usr/bin/env ruby
+
+$:.unshift("../../lib") if __FILE__ =~ /\.rb$/
+
+require 'puppettest'
+require 'puppet/network/xmlrpc/processor'
+require 'mocha'
+
+class TestXMLRPCProcessor < Test::Unit::TestCase
+ class BaseProcessor
+ def add_handler(interface, handler)
+ @handlers ||= {}
+ @handlers[interface] = handler
+ end
+ end
+
+ # We use a base class just so super() works with add_handler.
+ class Processor < BaseProcessor
+ include Puppet::Network::XMLRPCProcessor
+
+ def set_service_hook(&block)
+ meta_def(:service, &block)
+ end
+ end
+
+ def setup
+ super
+ @processor = Processor.new
+ end
+
+ def test_handlers
+ ca = Puppet::Network::Handler.ca
+ @processor.send(:setup_processor)
+ assert(! @processor.handler_loaded?(:ca), "already have ca handler loaded")
+ assert_nothing_raised do
+ @processor.add_handler(ca.interface, ca.new())
+ end
+
+ assert(@processor.handler_loaded?(:puppetca), "ca handler not loaded by symbol")
+ assert(@processor.handler_loaded?("puppetca"), "ca handler not loaded by string")
+ end
+
+ def test_process
+ ca = Puppet::Network::Handler.ca
+ @processor.send(:setup_processor)
+ assert_nothing_raised do
+ @processor.add_handler(ca.interface, ca.new())
+ end
+
+ fakeparser = Class.new do
+ def parseMethodCall(data)
+ return data
+ end
+ end
+
+ request = Puppet::Network::ClientRequest.new("fake", "192.168.0.1", false)
+ request.handler = "myhandler"
+ request.method = "mymethod"
+
+ @processor.expects(:parser).returns(fakeparser.new)
+
+ request.expects(:handler=).with("myhandler")
+ request.expects(:method=).with("mymethod")
+
+ # I can't get this expectation to take with the argument, for some reason.
+ @processor.expects(:verify)
+ @processor.expects(:handle).with(request.call,
+ "params", request.name, request.ip)
+
+ @processor.send(:process, ["myhandler.mymethod", ["params"]], request)
+ end
+
+ def test_setup_processor
+ @processor.expects(:set_service_hook)
+ @processor.send(:setup_processor)
+ end
+end
+
+# $Id$
+