]> source.dussan.org Git - redmine.git/commitdiff
Include an authentication method name in LDAP connection error messages (#33345).
authorGo MAEDA <maeda@farend.jp>
Mon, 13 Dec 2021 09:16:46 +0000 (09:16 +0000)
committerGo MAEDA <maeda@farend.jp>
Mon, 13 Dec 2021 09:16:46 +0000 (09:16 +0000)
Contributed by Yuichi HARADA.

git-svn-id: http://svn.redmine.org/redmine/trunk@21310 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/auth_source_ldap.rb
test/unit/auth_source_ldap_test.rb

index 8ed7ce27f8430e63a85c261124255c3c6f907635..888493338f8e2139d49e3bf65b0dff2cffbe8bf5 100644 (file)
@@ -63,7 +63,7 @@ class AuthSourceLdap < AuthSource
       end
     end
   rescue *NETWORK_EXCEPTIONS => e
-    raise AuthSourceException.new(e.message)
+    raise AuthSourceException.new("#{auth_method_name}: #{e.message}")
   end
 
   # Test the connection to the LDAP
@@ -77,7 +77,7 @@ class AuthSourceLdap < AuthSource
       end
     end
   rescue *NETWORK_EXCEPTIONS => e
-    raise AuthSourceException.new(e.message)
+    raise AuthSourceException.new("#{auth_method_name}: #{e.message}")
   end
 
   def auth_method_name
@@ -107,7 +107,7 @@ class AuthSourceLdap < AuthSource
     end
     results
   rescue *NETWORK_EXCEPTIONS => e
-    raise AuthSourceException.new(e.message)
+    raise AuthSourceException.new("#{auth_method_name}: #{e.message}")
   end
 
   def ldap_mode
@@ -144,7 +144,7 @@ class AuthSourceLdap < AuthSource
       return yield
     end
   rescue Timeout::Error => e
-    raise AuthSourceTimeoutException.new(e.message)
+    raise AuthSourceTimeoutException.new("#{auth_method_name}: #{e.message}")
   end
 
   def ldap_filter
index cec88ae7eb085d19b61599d62041f5f9f64b2d4a..dd85067884f8fcd82dfc1247874bbc21a2bc20f9 100644 (file)
@@ -168,9 +168,10 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
       auth_source.timeout = 1
       def auth_source.initialize_ldap_con(*args); sleep(5); end
 
-      assert_raise AuthSourceTimeoutException do
+      error = assert_raise AuthSourceTimeoutException do
         auth_source.authenticate 'example1', '123456'
       end
+      assert_match /\ALDAP: /, error.message
     end
 
     def test_search_should_return_matching_entries
@@ -210,9 +211,10 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
       auth_source.host = "badhost"
       auth_source.save!
 
-      assert_raise AuthSourceException do
+      error = assert_raise AuthSourceException do
         auth_source.test_connection
       end
+      assert_match /\ALDAP: /, error.message
     end
 
     def test_test_connection_with_incorrect_port