summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-03-01 16:26:10 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-03-01 16:26:10 +0000
commit60741b3e1c025f50e93e6f5847716ed930b319a0 (patch)
treecb3d11d718d1ae9340418103648ceceb5623de07 /test
parentab46c52d4a3e993d3ca59cca976e1235ee2e2ed7 (diff)
downloadredmine-60741b3e1c025f50e93e6f5847716ed930b319a0.tar.gz
redmine-60741b3e1c025f50e93e6f5847716ed930b319a0.zip
Adds an optional LDAP filter (#1060).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9044 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/auth_source_ldap_test.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/unit/auth_source_ldap_test.rb b/test/unit/auth_source_ldap_test.rb
index 5dc532f23..55e1479b8 100644
--- a/test/unit/auth_source_ldap_test.rb
+++ b/test/unit/auth_source_ldap_test.rb
@@ -18,6 +18,7 @@
require File.expand_path('../../test_helper', __FILE__)
class AuthSourceLdapTest < ActiveSupport::TestCase
+ include Redmine::I18n
fixtures :auth_sources
def setup
@@ -44,6 +45,18 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
assert_equal 389, a.port
end
+ def test_filter_should_be_validated
+ set_language_if_valid 'en'
+
+ a = AuthSourceLdap.new(:name => 'My LDAP', :host => 'ldap.example.net', :port => 389, :attr_login => 'sn')
+ a.filter = "(mail=*@redmine.org"
+ assert !a.valid?
+ assert_equal "is invalid", a.errors[:filter].to_s
+
+ a.filter = "(mail=*@redmine.org)"
+ assert a.valid?
+ end
+
if ldap_configured?
context '#authenticate' do
setup do
@@ -83,6 +96,23 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
end
end
+ context 'without filter' do
+ should 'return any user' do
+ assert @auth.authenticate('example1','123456')
+ assert @auth.authenticate('edavis', '123456')
+ end
+ end
+
+ context 'with filter' do
+ setup do
+ @auth.filter = "(mail=*@redmine.org)"
+ end
+
+ should 'return user who matches the filter only' do
+ assert @auth.authenticate('example1','123456')
+ assert_nil @auth.authenticate('edavis', '123456')
+ end
+ end
end
else
puts '(Test LDAP server not configured)'