summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-11-24 14:55:01 -0600
committerLuke Kanies <luke@madstop.com>2007-11-24 14:55:01 -0600
commit1b7f0ee67a7589e824c705c4f6f06fd6c59bc586 (patch)
tree6f8ae366bf64e71e3f37bf73a2664be320b13ab2 /spec
parente53693e3ff244f8e782b5dc863aa659d46f9a286 (diff)
parent8de1412d97ac9d80500efb5cb94451ab67908448 (diff)
downloadpuppet-1b7f0ee67a7589e824c705c4f6f06fd6c59bc586.tar.gz
puppet-1b7f0ee67a7589e824c705c4f6f06fd6c59bc586.tar.xz
puppet-1b7f0ee67a7589e824c705c4f6f06fd6c59bc586.zip
Merge branch 'wombles-patches'
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/network/xmlrpc/client.rb69
-rwxr-xr-xspec/unit/util/settings.rb11
2 files changed, 80 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
diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb
index 620c04009..2856c574e 100755
--- a/spec/unit/util/settings.rb
+++ b/spec/unit/util/settings.rb
@@ -323,6 +323,17 @@ describe Puppet::Util::Settings, " when parsing its configuration" do
@settings[:myfile].should == "/other/file"
@settings.metadata(:myfile).should == {:owner => "luke"}
end
+
+ it "should allow empty values" do
+ @settings.setdefaults :section, :myarg => ["myfile", "a"]
+
+ text = "[main]
+ myarg =
+ "
+ @settings.stubs(:read_file).returns(text)
+ @settings.parse("/some/file")
+ @settings[:myarg].should == ""
+ end
end
describe Puppet::Util::Settings, " when reparsing its configuration" do