diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-12-26 11:23:53 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-12-26 11:23:53 +0000 |
commit | 7b8ebb7e3ffc62e28396fadbd009216eb0e53c5f (patch) | |
tree | 43269790cccebe4e886064e897b9cb0d59edb31b /test/unit/auth_source_ldap_test.rb | |
parent | eba4efc9d0ad6222818a32a5bac2190cef0d45b0 (diff) | |
download | redmine-7b8ebb7e3ffc62e28396fadbd009216eb0e53c5f.tar.gz redmine-7b8ebb7e3ffc62e28396fadbd009216eb0e53c5f.zip |
Auto-populate fields while creating a new user with LDAP (#10286).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11080 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/auth_source_ldap_test.rb')
-rw-r--r-- | test/unit/auth_source_ldap_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/unit/auth_source_ldap_test.rb b/test/unit/auth_source_ldap_test.rb index 60558f798..5e5f90b97 100644 --- a/test/unit/auth_source_ldap_test.rb +++ b/test/unit/auth_source_ldap_test.rb @@ -124,6 +124,30 @@ class AuthSourceLdapTest < ActiveSupport::TestCase auth_source.authenticate 'example1', '123456' end end + + def test_search_should_return_matching_entries + results = AuthSource.search("exa") + assert_equal 1, results.size + result = results.first + assert_kind_of Hash, result + assert_equal "example1", result[:login] + assert_equal "Example", result[:firstname] + assert_equal "One", result[:lastname] + assert_equal "example1@redmine.org", result[:mail] + assert_equal 1, result[:auth_source_id] + end + + def test_search_with_no_match_should_return_an_empty_array + results = AuthSource.search("wro") + assert_equal [], results + end + + def test_search_with_exception_should_return_an_empty_array + Net::LDAP.stubs(:new).raises(Net::LDAP::LdapError, 'Cannot connect') + + results = AuthSource.search("exa") + assert_equal [], results + end else puts '(Test LDAP server not configured)' end |