improvement-ldap-error-message.patch

Yuichi HARADA, 2020-04-23 07:19

Download (2.68 KB)

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(l(:error_can_not_connect_ldap, 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(l(:error_can_not_connect_ldap, 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(l(:error_can_not_connect_ldap, e.message))
111 111
  end
112 112

  
113 113
  def ldap_mode
config/locales/en.yml
224 224
  error_invalid_csv_file_or_settings: "The file is not a CSV file or does not match the settings below"
225 225
  error_can_not_read_import_file: "An error occurred while reading the file to import"
226 226
  error_attachment_extension_not_allowed: "Attachment extension %{extension} is not allowed"
227
  error_can_not_connect_ldap: "Cannot connect to LDAP: %{value}"
227 228
  error_ldap_bind_credentials: "Invalid LDAP Account/Password"
228 229
  error_no_tracker_allowed_for_new_issue_in_project: "The project doesn't have any trackers for which you can create an issue"
229 230
  error_no_projects_with_tracker_allowed_for_new_issue: "There are no projects with trackers for which you can create an issue"
test/unit/auth_source_ldap_test.rb
271 271
    end
272 272
  else
273 273
    puts '(Test LDAP server not configured)'
274

  
275
    def test_authenticate_with_cannot_connect_ldap
276
      auth_source = AuthSourceLdap.find(1)
277

  
278
      error = assert_raise(AuthSourceException) do
279
        auth_source.authenticate('example1','123456')
280
      end
281
      assert_match /\ACannot connect to LDAP: /, error.message
282
    end
283

  
284
    def test_test_connection_with_cannot_connect_ldap
285
      auth_source = AuthSourceLdap.find(1)
286

  
287
      error = assert_raise(AuthSourceException) do
288
        auth_source.test_connection
289
      end
290
      assert_match /\ACannot connect to LDAP: /, error.message
291
    end
274 292
  end
275 293
end