Defect #4483 » fixed-4483.patch
| app/models/auth_source_ldap.rb | ||
|---|---|---|
|
with_timeout do
|
||
|
ldap_con = initialize_ldap_con(self.account, self.account_password)
|
||
|
ldap_con.open {}
|
||
|
if self.account.present? && !self.account.include?("$login") && self.account_password.present?
|
||
|
ldap_auth = authenticate_dn(self.account, self.account_password)
|
||
|
raise AuthSourceException.new(l(:error_ldap_bind_credentials)) if !ldap_auth
|
||
|
end
|
||
|
return if self.account.present? && self.account.include?("$login")
|
||
|
ldap_auth = authenticate_dn(self.account, self.account_password)
|
||
|
raise AuthSourceException.new(l(:error_ldap_bind_credentials)) if !ldap_auth
|
||
|
end
|
||
|
rescue *NETWORK_EXCEPTIONS => e
|
||
|
raise AuthSourceException.new(e.message)
|
||
| test/unit/auth_source_ldap_test.rb | ||
|---|---|---|
|
assert_equal [], results
|
||
|
end
|
||
|
def test_test_connection_with_correct_host_and_port
|
||
|
auth_source = AuthSourceLdap.find(1)
|
||
|
assert_nothing_raised do
|
||
|
auth_source.test_connection
|
||
|
end
|
||
|
end
|
||
|
def test_test_connection_with_incorrect_host
|
||
|
auth_source = AuthSourceLdap.find(1)
|
||
|
auth_source.host = "badhost"
|
||
| ... | ... | |
|
assert_equal "cn=admin,dc=redmine,dc=org", auth_source.account
|
||
|
assert_equal "secret", auth_source.account_password
|
||
|
assert_nil auth_source.test_connection
|
||
|
assert_nothing_raised do
|
||
|
auth_source.test_connection
|
||
|
end
|
||
|
end
|
||
|
def test_test_connection_bind_with_dynamic_bind_account
|
||
|
auth_source = AuthSourceLdap.find(1)
|
||
|
auth_source.account = "cn=$login,dc=redmine,dc=org"
|
||
|
auth_source.save!
|
||
|
assert_equal "cn=$login,dc=redmine,dc=org", auth_source.account
|
||
|
assert_nothing_raised do
|
||
|
auth_source.test_connection
|
||
|
end
|
||
|
end
|
||
|
def test_test_connection_bind_without_account_and_password
|
||
| ... | ... | |
|
assert_nil auth_source.account
|
||
|
assert_equal "", auth_source.account_password
|
||
|
assert_nil auth_source.test_connection
|
||
|
assert_raise AuthSourceException do
|
||
|
auth_source.test_connection
|
||
|
end
|
||
|
end
|
||
|
def test_test_connection_bind_with_incorrect_account
|
||
- « Previous
- 1
- 2
- Next »