diff --git a/lib/net/ldap.rb b/lib/net/ldap.rb index 4ba27339..bff101b7 100644 --- a/lib/net/ldap.rb +++ b/lib/net/ldap.rb @@ -541,6 +541,7 @@ def initialize(args = {}) @force_no_page = args[:force_no_page] || DefaultForceNoPage @encryption = normalize_encryption(args[:encryption]) # may be nil @connect_timeout = args[:connect_timeout] + @socket_class = args[:socket_class] if pr = @auth[:password] and pr.respond_to?(:call) @auth[:password] = pr.call @@ -1305,7 +1306,8 @@ def new_connection :hosts => @hosts, :encryption => @encryption, :instrumentation_service => @instrumentation_service, - :connect_timeout => @connect_timeout + :connect_timeout => @connect_timeout, + :socket_class => @socket_class # Force connect to see if there's a connection error connection.socket diff --git a/lib/net/ldap/connection.rb b/lib/net/ldap/connection.rb index f8ba0b61..a1e55bf7 100644 --- a/lib/net/ldap/connection.rb +++ b/lib/net/ldap/connection.rb @@ -22,7 +22,7 @@ def initialize(server = {}) @instrumentation_service = server[:instrumentation_service] # Allows tests to parameterize what socket class to use - @socket_class = server.fetch(:socket_class, DefaultSocket) + @socket_class = server.fetch(:socket_class, DefaultSocket) || DefaultSocket yield self if block_given? end