From d37125dfe98b295cb8dd15d7c12ed2c97a122e8d Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Thu, 2 Feb 2017 02:24:50 +0000 Subject: [PATCH] replace depricated Net::LDAP::LdapError by Net::LDAP::Error (#24970) git-svn-id: http://svn.redmine.org/redmine/trunk@16322 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- Gemfile | 2 +- app/models/auth_source_ldap.rb | 4 ++-- test/functional/auth_sources_controller_test.rb | 2 +- test/unit/auth_source_ldap_test.rb | 2 +- test/unit/user_test.rb | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index b539a769d..57f6c072f 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,7 @@ gem "rbpdf", "~> 1.19.0" # Optional gem for LDAP authentication group :ldap do - gem "net-ldap", "~> 0.12.0" + gem "net-ldap", "~> 0.12.1" end # Optional gem for OpenID authentication diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb index d2aa25212..1301e326c 100644 --- a/app/models/auth_source_ldap.rb +++ b/app/models/auth_source_ldap.rb @@ -21,7 +21,7 @@ require 'timeout' class AuthSourceLdap < AuthSource NETWORK_EXCEPTIONS = [ - Net::LDAP::LdapError, + Net::LDAP::Error, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EHOSTDOWN, Errno::EHOSTUNREACH, SocketError @@ -117,7 +117,7 @@ class AuthSourceLdap < AuthSource if filter.present? Net::LDAP::Filter.construct(filter) end - rescue Net::LDAP::LdapError, Net::LDAP::FilterSyntaxInvalidError + rescue Net::LDAP::Error, Net::LDAP::FilterSyntaxInvalidError nil end diff --git a/test/functional/auth_sources_controller_test.rb b/test/functional/auth_sources_controller_test.rb index 1ad829655..f711ce159 100644 --- a/test/functional/auth_sources_controller_test.rb +++ b/test/functional/auth_sources_controller_test.rb @@ -134,7 +134,7 @@ class AuthSourcesControllerTest < Redmine::ControllerTest end def test_test_connection_with_failure - AuthSourceLdap.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::LdapError.new("Something went wrong")) + AuthSourceLdap.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::Error.new("Something went wrong")) get :test_connection, :id => 1 assert_redirected_to '/auth_sources' diff --git a/test/unit/auth_source_ldap_test.rb b/test/unit/auth_source_ldap_test.rb index eac13ff70..3ce7fa98e 100644 --- a/test/unit/auth_source_ldap_test.rb +++ b/test/unit/auth_source_ldap_test.rb @@ -150,7 +150,7 @@ class AuthSourceLdapTest < ActiveSupport::TestCase end def test_search_with_exception_should_return_an_empty_array - Net::LDAP.stubs(:new).raises(Net::LDAP::LdapError, 'Cannot connect') + Net::LDAP.stubs(:new).raises(Net::LDAP::Error, 'Cannot connect') results = AuthSource.search("exa") assert_equal [], results diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index ebc7d6532..3b42a7dec 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -643,7 +643,7 @@ class UserTest < ActiveSupport::TestCase if ldap_configured? test "#try_to_login using LDAP with failed connection to the LDAP server" do auth_source = AuthSourceLdap.find(1) - AuthSource.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::LdapError, 'Cannot connect') + AuthSource.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::Error, 'Cannot connect') assert_nil User.try_to_login('edavis', 'wrong') end -- 2.39.5