Redmine 4.1.1
This commit is contained in:
parent
33e7b881a5
commit
3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -41,6 +43,8 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
|||
assert_nil auth_source.attr_mail
|
||||
assert_equal false, auth_source.onthefly_register
|
||||
assert_equal false, auth_source.tls
|
||||
assert_equal true, auth_source.verify_peer
|
||||
assert_equal :ldap, auth_source.ldap_mode
|
||||
assert_nil auth_source.filter
|
||||
assert_nil auth_source.timeout
|
||||
end
|
||||
|
@ -78,6 +82,42 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
|||
assert a.valid?
|
||||
end
|
||||
|
||||
test 'ldap_mode setter sets tls and verify_peer' do
|
||||
a = AuthSourceLdap.new
|
||||
|
||||
a.ldap_mode = 'ldaps_verify_peer'
|
||||
assert a.tls
|
||||
assert a.verify_peer
|
||||
|
||||
a.ldap_mode = 'ldaps_verify_none'
|
||||
assert a.tls
|
||||
assert !a.verify_peer
|
||||
|
||||
a.ldap_mode = 'ldap'
|
||||
assert !a.tls
|
||||
assert !a.verify_peer
|
||||
end
|
||||
|
||||
test 'ldap_mode getter reads from tls and verify_peer' do
|
||||
a = AuthSourceLdap.new
|
||||
|
||||
a.tls = true
|
||||
a.verify_peer = true
|
||||
assert_equal :ldaps_verify_peer, a.ldap_mode
|
||||
|
||||
a.tls = true
|
||||
a.verify_peer = false
|
||||
assert_equal :ldaps_verify_none, a.ldap_mode
|
||||
|
||||
a.tls = false
|
||||
a.verify_peer = false
|
||||
assert_equal :ldap, a.ldap_mode
|
||||
|
||||
a.tls = false
|
||||
a.verify_peer = true
|
||||
assert_equal :ldap, a.ldap_mode
|
||||
end
|
||||
|
||||
if ldap_configured?
|
||||
test '#authenticate with a valid LDAP user should return the user attributes' do
|
||||
auth = AuthSourceLdap.find(1)
|
||||
|
@ -151,7 +191,7 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_search_with_exception_should_return_an_empty_array
|
||||
Net::LDAP.stubs(:new).raises(Net::LDAP::LdapError, 'Cannot connect')
|
||||
Net::LDAP.stubs(:new).raises(Net::LDAP::Error, 'Cannot connect')
|
||||
|
||||
results = AuthSource.search("exa")
|
||||
assert_equal [], results
|
||||
|
@ -160,7 +200,7 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
|||
def test_test_connection_with_correct_host_and_port
|
||||
auth_source = AuthSourceLdap.find(1)
|
||||
|
||||
assert_nothing_raised Net::LDAP::Error do
|
||||
assert_nothing_raised do
|
||||
auth_source.test_connection
|
||||
end
|
||||
end
|
||||
|
@ -170,7 +210,7 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
|||
auth_source.host = "badhost"
|
||||
auth_source.save!
|
||||
|
||||
assert_raise Net::LDAP::Error do
|
||||
assert_raise AuthSourceException do
|
||||
auth_source.test_connection
|
||||
end
|
||||
end
|
||||
|
@ -180,7 +220,7 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
|||
auth_source.port = 1234
|
||||
auth_source.save!
|
||||
|
||||
assert_raise Net::LDAP::Error do
|
||||
assert_raise AuthSourceException do
|
||||
auth_source.test_connection
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue