# 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
class AuthSourceLdap < AuthSource
NETWORK_EXCEPTIONS = [
- Net::LDAP::LdapError,
+ Net::LDAP::Error,
Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET,
Errno::EHOSTDOWN, Errno::EHOSTUNREACH,
SocketError
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
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'
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
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