diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-02-16 16:40:50 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-02-16 16:40:50 +0000 |
commit | 7b6b147761a689aa07d83068e77348a3d3f84cfa (patch) | |
tree | e7a8166d2adc4bdf5924672f81b4b6a508e17ffd /test/unit/auth_source_ldap_test.rb | |
parent | 49bfee053593604ad2a3eb487ac1e5b9fef5dd8c (diff) | |
download | redmine-7b6b147761a689aa07d83068e77348a3d3f84cfa.tar.gz redmine-7b6b147761a689aa07d83068e77348a3d3f84cfa.zip |
Added some tests for the LDAP authentication.
Includes an export of an LDAP database to use in testing.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3438 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 | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/unit/auth_source_ldap_test.rb b/test/unit/auth_source_ldap_test.rb index d0f7a6edf..16cc614fb 100644 --- a/test/unit/auth_source_ldap_test.rb +++ b/test/unit/auth_source_ldap_test.rb @@ -33,4 +33,62 @@ class AuthSourceLdapTest < ActiveSupport::TestCase assert a.save assert_equal 'givenName', a.reload.attr_firstname end + + if ldap_configured? + context '#authenticate' do + setup do + @auth = AuthSourceLdap.generate!(:name => 'on the fly', + :host => '127.0.0.1', + :port => 389, + :base_dn => 'OU=Person,DC=redmine,DC=org', + :attr_login => 'uid', + :attr_firstname => 'givenName', + :attr_lastname => 'sn', + :attr_mail => 'mail', + :onthefly_register => true) + + end + + context 'with a valid LDAP user' do + should 'return the firstname user attributes' do + response = @auth.authenticate('example1','123456') + assert response + assert_equal 'Example', response.first[:firstname] + end + + should 'return the lastname user attributes' do + response = @auth.authenticate('example1','123456') + assert response + assert_equal 'One', response.first[:lastname] + end + + should 'return mail user attributes' do + response = @auth.authenticate('example1','123456') + assert response + assert_equal 'example1@redmine.org', response.first[:mail] + end + end + + context 'with an invalid LDAP user' do + should 'return nil' do + assert_equal nil, @auth.authenticate('nouser','123456') + end + end + + context 'without a login' do + should 'return nil' do + assert_equal nil, @auth.authenticate('','123456') + end + end + + context 'without a password' do + should 'return nil' do + assert_equal nil, @auth.authenticate('edavis','') + end + end + + end + else + puts '(Test LDAP server not configured)' + end end |