summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-11-24 14:54:38 -0600
committerLuke Kanies <luke@madstop.com>2007-11-24 14:54:38 -0600
commit8de1412d97ac9d80500efb5cb94451ab67908448 (patch)
treef45fd7794ad7c33a4f0ae2639d5ba1ced896934a /spec
parent7c36ae9f6bc8f6043443a0cf12f769c603895b00 (diff)
downloadpuppet-8de1412d97ac9d80500efb5cb94451ab67908448.tar.gz
puppet-8de1412d97ac9d80500efb5cb94451ab67908448.tar.xz
puppet-8de1412d97ac9d80500efb5cb94451ab67908448.zip
Integrating most of Matt Palmer's from
http://theshed.hezmatt.org/mattshacks/puppet/_patches/puppet-0.23.2/. There are still a few that haven't made it in, notably those related to the plugins module, which I'm planning on integrating separately.
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/network/xmlrpc/client.rb69
1 files changed, 69 insertions, 0 deletions
diff --git a/spec/unit/network/xmlrpc/client.rb b/spec/unit/network/xmlrpc/client.rb
new file mode 100755
index 000000000..e20c66c25
--- /dev/null
+++ b/spec/unit/network/xmlrpc/client.rb
@@ -0,0 +1,69 @@
+#!/usr/bin/env ruby
+#
+# Created by Luke Kanies on 2007-11-26.
+# Copyright (c) 2007. All rights reserved.
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+require 'puppet/network/xmlrpc/client'
+
+describe Puppet::Network::XMLRPCClient, " when managing http instances" do
+ it "should return an http instance created with the passed host and port" do
+ http = stub 'http', :use_ssl= => nil, :read_timeout= => nil, :open_timeout= => nil
+ Net::HTTP.expects(:new).with("me", 54321, nil, nil).returns(http)
+ Puppet::Network::XMLRPCClient.http_instance("me", 54321).should equal(http)
+ end
+
+ it "should enable ssl on the http instance" do
+ Puppet::Network::XMLRPCClient.http_instance("me", 54321).use_ssl.should be_true
+ end
+
+ it "should set the read timeout" do
+ Puppet::Network::XMLRPCClient.http_instance("me", 54321).read_timeout.should == 120
+ end
+
+ it "should set the open timeout" do
+ Puppet::Network::XMLRPCClient.http_instance("me", 54321).open_timeout.should == 120
+ end
+
+ it "should create the http instance with the proxy host and port set if the http_proxy is not set to 'none'" do
+ Puppet.settings.stubs(:value).with(:http_keepalive).returns(true)
+ Puppet.settings.stubs(:value).with(:http_proxy_host).returns("myhost")
+ Puppet.settings.stubs(:value).with(:http_proxy_port).returns(432)
+ Puppet::Network::XMLRPCClient.http_instance("me", 54321).open_timeout.should == 120
+ end
+
+ it "should default to keep-alive being enabled" do
+ Puppet.settings[:http_keepalive].should be_true
+ end
+
+ it "should cache http instances if keepalive is enabled" do
+ Puppet.settings.stubs(:value).with(:http_keepalive).returns(true)
+ Puppet.settings.stubs(:value).with(:http_proxy_host).returns("myhost")
+ Puppet.settings.stubs(:value).with(:http_proxy_port).returns(432)
+ old = Puppet::Network::XMLRPCClient.http_instance("me", 54321)
+ Puppet::Network::XMLRPCClient.http_instance("me", 54321).should equal(old)
+ end
+
+ it "should not cache http instances if keepalive is not enabled" do
+ Puppet.settings.stubs(:value).with(:http_keepalive).returns(false)
+ Puppet.settings.stubs(:value).with(:http_proxy_host).returns("myhost")
+ Puppet.settings.stubs(:value).with(:http_proxy_port).returns(432)
+ old = Puppet::Network::XMLRPCClient.http_instance("me", 54321)
+ Puppet::Network::XMLRPCClient.http_instance("me", 54321).should_not equal(old)
+ end
+
+ it "should have a mechanism for clearing the http cache" do
+ Puppet.settings.stubs(:value).with(:http_keepalive).returns(true)
+ Puppet.settings.stubs(:value).with(:http_proxy_host).returns("myhost")
+ Puppet.settings.stubs(:value).with(:http_proxy_port).returns(432)
+ old = Puppet::Network::XMLRPCClient.http_instance("me", 54321)
+ Puppet::Network::XMLRPCClient.http_instance("me", 54321).should equal(old)
+ old = Puppet::Network::XMLRPCClient.http_instance("me", 54321)
+ Puppet::Network::XMLRPCClient.clear_http_instances
+ Puppet::Network::XMLRPCClient.http_instance("me", 54321).should_not equal(old)
+ end
+
+ after do
+ Puppet::Network::XMLRPCClient.clear_http_instances
+ end
+end