Project

General

Profile

Feature #33345 » 33345-v2.patch

Go MAEDA, 2021-10-15 02:58

View differences:

app/models/auth_source_ldap.rb
63 63
      end
64 64
    end
65 65
  rescue *NETWORK_EXCEPTIONS => e
66
    raise AuthSourceException.new(e.message)
66
    raise AuthSourceException.new("#{auth_method_name}: #{e.message}")
67 67
  end
68 68

  
69 69
  # Test the connection to the LDAP
......
77 77
      end
78 78
    end
79 79
  rescue *NETWORK_EXCEPTIONS => e
80
    raise AuthSourceException.new(e.message)
80
    raise AuthSourceException.new("#{auth_method_name}: #{e.message}")
81 81
  end
82 82

  
83 83
  def auth_method_name
......
107 107
    end
108 108
    results
109 109
  rescue *NETWORK_EXCEPTIONS => e
110
    raise AuthSourceException.new(e.message)
110
    raise AuthSourceException.new("#{auth_method_name}: #{e.message}")
111 111
  end
112 112

  
113 113
  def ldap_mode
......
144 144
      return yield
145 145
    end
146 146
  rescue Timeout::Error => e
147
    raise AuthSourceTimeoutException.new(e.message)
147
    raise AuthSourceTimeoutException.new("#{auth_method_name}: #{e.message}")
148 148
  end
149 149

  
150 150
  def ldap_filter
test/unit/auth_source_ldap_test.rb
168 168
      auth_source.timeout = 1
169 169
      def auth_source.initialize_ldap_con(*args); sleep(5); end
170 170

  
171
      assert_raise AuthSourceTimeoutException do
171
      error = assert_raise AuthSourceTimeoutException do
172 172
        auth_source.authenticate 'example1', '123456'
173 173
      end
174
      assert_match /\ALDAP: /, error.message
174 175
    end
175 176

  
176 177
    def test_search_should_return_matching_entries
......
210 211
      auth_source.host = "badhost"
211 212
      auth_source.save!
212 213

  
213
      assert_raise AuthSourceException do
214
      error = assert_raise AuthSourceException do
214 215
        auth_source.test_connection
215 216
      end
217
      assert_match /\ALDAP: /, error.message
216 218
    end
217 219

  
218 220
    def test_test_connection_with_incorrect_port
(4-4/4)