Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raises errors when giving encryption as non-Hash object #257

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 && [email protected]_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_initializer_requires_hash_encryption
assert_raise ArgumentError, "encryption must be given as Hash" do
Net::LDAP.new encryption: [ :simple_tls ]
end
end
end