Skip to content

Commit 717c307

Browse files
committed
Raises errors when giving encryption as non-Hash object
fix ruby-ldap#250
1 parent f1659c5 commit 717c307

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/net/ldap.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ def initialize(args = {})
540540
@base = args[:base] || DefaultTreebase
541541
@force_no_page = args[:force_no_page] || DefaultForceNoPage
542542
@encryption = args[:encryption] # may be nil
543+
if !@encryption.nil? and !@encryption.is_a?(Hash)
544+
raise ArgumentError, "encryption must be given as Hash"
545+
end
543546
@connect_timeout = args[:connect_timeout]
544547

545548
if pr = @auth[:password] and pr.respond_to?(:call)

test/test_ldap.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,10 @@ def test_encryption
9191

9292
assert_equal enc[:method], :start_tls
9393
end
94+
95+
def test_initialize
96+
assert_raise ArgumentError, "encryption must be given as Hash" do
97+
Net::LDAP.new encryption: [ :simple_tls ]
98+
end
99+
end
94100
end

0 commit comments

Comments
 (0)