Skip to content

Commit

Permalink
Raises errors when giving encryption as non-Hash object
Browse files Browse the repository at this point in the history
  • Loading branch information
satoryu committed Jan 13, 2016
1 parent f1659c5 commit 717c307
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/net/ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ def initialize(args = {})
@base = args[:base] || DefaultTreebase
@force_no_page = args[:force_no_page] || DefaultForceNoPage
@encryption = args[:encryption] # may be nil
if !@encryption.nil? and !@encryption.is_a?(Hash)
raise ArgumentError, "encryption must be given as Hash"
end
@connect_timeout = args[:connect_timeout]

if pr = @auth[:password] and pr.respond_to?(:call)
Expand Down
6 changes: 6 additions & 0 deletions test/test_ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,10 @@ def test_encryption

assert_equal enc[:method], :start_tls
end

def test_initialize
assert_raise ArgumentError, "encryption must be given as Hash" do
Net::LDAP.new encryption: [ :simple_tls ]
end
end
end

0 comments on commit 717c307

Please sign in to comment.