@@ -26,7 +26,7 gem "rbpdf", "~> 1.19.0" | |||||
26 |
|
26 | |||
27 | # Optional gem for LDAP authentication |
|
27 | # Optional gem for LDAP authentication | |
28 | group :ldap do |
|
28 | group :ldap do | |
29 |
gem "net-ldap", "~> 0.12. |
|
29 | gem "net-ldap", "~> 0.12.0" | |
30 | end |
|
30 | end | |
31 |
|
31 | |||
32 | # Optional gem for OpenID authentication |
|
32 | # Optional gem for OpenID authentication |
@@ -21,7 +21,7 require 'timeout' | |||||
21 |
|
21 | |||
22 | class AuthSourceLdap < AuthSource |
|
22 | class AuthSourceLdap < AuthSource | |
23 | NETWORK_EXCEPTIONS = [ |
|
23 | NETWORK_EXCEPTIONS = [ | |
24 | Net::LDAP::Error, |
|
24 | Net::LDAP::LdapError, | |
25 | Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET, |
|
25 | Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET, | |
26 | Errno::EHOSTDOWN, Errno::EHOSTUNREACH, |
|
26 | Errno::EHOSTDOWN, Errno::EHOSTUNREACH, | |
27 | SocketError |
|
27 | SocketError | |
@@ -117,7 +117,7 class AuthSourceLdap < AuthSource | |||||
117 | if filter.present? |
|
117 | if filter.present? | |
118 | Net::LDAP::Filter.construct(filter) |
|
118 | Net::LDAP::Filter.construct(filter) | |
119 | end |
|
119 | end | |
120 | rescue Net::LDAP::Error, Net::LDAP::FilterSyntaxInvalidError |
|
120 | rescue Net::LDAP::LdapError, Net::LDAP::FilterSyntaxInvalidError | |
121 | nil |
|
121 | nil | |
122 | end |
|
122 | end | |
123 |
|
123 |
@@ -134,7 +134,7 class AuthSourcesControllerTest < Redmine::ControllerTest | |||||
134 | end |
|
134 | end | |
135 |
|
135 | |||
136 | def test_test_connection_with_failure |
|
136 | def test_test_connection_with_failure | |
137 | AuthSourceLdap.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::Error.new("Something went wrong")) |
|
137 | AuthSourceLdap.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::LdapError.new("Something went wrong")) | |
138 |
|
138 | |||
139 | get :test_connection, :id => 1 |
|
139 | get :test_connection, :id => 1 | |
140 | assert_redirected_to '/auth_sources' |
|
140 | assert_redirected_to '/auth_sources' |
@@ -150,7 +150,7 class AuthSourceLdapTest < ActiveSupport::TestCase | |||||
150 | end |
|
150 | end | |
151 |
|
151 | |||
152 | def test_search_with_exception_should_return_an_empty_array |
|
152 | def test_search_with_exception_should_return_an_empty_array | |
153 | Net::LDAP.stubs(:new).raises(Net::LDAP::Error, 'Cannot connect') |
|
153 | Net::LDAP.stubs(:new).raises(Net::LDAP::LdapError, 'Cannot connect') | |
154 |
|
154 | |||
155 | results = AuthSource.search("exa") |
|
155 | results = AuthSource.search("exa") | |
156 | assert_equal [], results |
|
156 | assert_equal [], results |
@@ -643,7 +643,7 class UserTest < ActiveSupport::TestCase | |||||
643 | if ldap_configured? |
|
643 | if ldap_configured? | |
644 | test "#try_to_login using LDAP with failed connection to the LDAP server" do |
|
644 | test "#try_to_login using LDAP with failed connection to the LDAP server" do | |
645 | auth_source = AuthSourceLdap.find(1) |
|
645 | auth_source = AuthSourceLdap.find(1) | |
646 | AuthSource.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::Error, 'Cannot connect') |
|
646 | AuthSource.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::LdapError, 'Cannot connect') | |
647 |
|
647 | |||
648 | assert_nil User.try_to_login('edavis', 'wrong') |
|
648 | assert_nil User.try_to_login('edavis', 'wrong') | |
649 | end |
|
649 | end |
General Comments 0
You need to be logged in to leave comments.
Login now