summaryrefslogtreecommitdiffstats
path: root/spec/unit/util/ldap
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-01 21:20:13 -0500
committerLuke Kanies <luke@madstop.com>2008-07-01 22:22:07 -0500
commita1d1abdd5a2fc11dceeed63da8c6f48d2fa21cfe (patch)
tree2fcc0518905ad74bf5d05928556a81af109262a2 /spec/unit/util/ldap
parent4bdb793092a1aee1798d921cb82ee9c12f0c51be (diff)
downloadpuppet-a1d1abdd5a2fc11dceeed63da8c6f48d2fa21cfe.tar.gz
puppet-a1d1abdd5a2fc11dceeed63da8c6f48d2fa21cfe.tar.xz
puppet-a1d1abdd5a2fc11dceeed63da8c6f48d2fa21cfe.zip
Adding an 'instance' class method to ldap connections.
This just returns a Connection instance with the default ldap configuration information already provided.
Diffstat (limited to 'spec/unit/util/ldap')
-rwxr-xr-xspec/unit/util/ldap/connection.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/unit/util/ldap/connection.rb b/spec/unit/util/ldap/connection.rb
index 212f3ca54..9392466c7 100755
--- a/spec/unit/util/ldap/connection.rb
+++ b/spec/unit/util/ldap/connection.rb
@@ -111,4 +111,46 @@ describe Puppet::Util::Ldap::Connection do
@connection.close
end
end
+
+ it "should have a class-level method for creating a default connection" do
+ Puppet::Util::Ldap::Connection.should respond_to(:instance)
+ end
+
+ describe "when creating a default connection" do
+ before do
+ Puppet.settings.stubs(:value).returns "whatever"
+ end
+
+ it "should use the :ldapserver setting to determine the host" do
+ Puppet.settings.expects(:value).with(:ldapserver).returns "myserv"
+ Puppet::Util::Ldap::Connection.expects(:new).with { |host, port, options| host == "myserv" }
+ Puppet::Util::Ldap::Connection.instance
+ end
+
+ it "should use the :ldapport setting to determine the port" do
+ Puppet.settings.expects(:value).with(:ldapport).returns "456"
+ Puppet::Util::Ldap::Connection.expects(:new).with { |host, port, options| port == "456" }
+ Puppet::Util::Ldap::Connection.instance
+ end
+
+ it "should set ssl to :tls if tls is enabled" do
+ Puppet.settings.expects(:value).with(:ldaptls).returns true
+ Puppet::Util::Ldap::Connection.expects(:new).with { |host, port, options| options[:ssl] == :tls }
+ Puppet::Util::Ldap::Connection.instance
+ end
+
+ it "should set ssl to 'true' if ssl is enabled and tls is not" do
+ Puppet.settings.expects(:value).with(:ldaptls).returns false
+ Puppet.settings.expects(:value).with(:ldapssl).returns true
+ Puppet::Util::Ldap::Connection.expects(:new).with { |host, port, options| options[:ssl] == true }
+ Puppet::Util::Ldap::Connection.instance
+ end
+
+ it "should set ssl to false if neither ssl nor tls are enabled" do
+ Puppet.settings.expects(:value).with(:ldaptls).returns false
+ Puppet.settings.expects(:value).with(:ldapssl).returns false
+ Puppet::Util::Ldap::Connection.expects(:new).with { |host, port, options| options[:ssl] == false }
+ Puppet::Util::Ldap::Connection.instance
+ end
+ end
end