mirror of
https://github.com/redmine/redmine.git
synced 2025-10-26 07:46:17 +01:00
Makes the test LDAP host configurable (#21674).
git-svn-id: http://svn.redmine.org/redmine/trunk@15088 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
2
test/fixtures/auth_sources.yml
vendored
2
test/fixtures/auth_sources.yml
vendored
@@ -3,7 +3,7 @@ auth_sources_001:
|
||||
id: 1
|
||||
type: AuthSourceLdap
|
||||
name: 'LDAP test server'
|
||||
host: '127.0.0.1'
|
||||
host: '<%= $redmine_test_ldap_server %>'
|
||||
port: 389
|
||||
base_dn: 'OU=Person,DC=redmine,DC=org'
|
||||
attr_login: uid
|
||||
|
||||
@@ -22,6 +22,8 @@ if ENV["COVERAGE"]
|
||||
SimpleCov.start 'rails'
|
||||
end
|
||||
|
||||
$redmine_test_ldap_server = ENV['REDMINE_TEST_LDAP_SERVER'] || '127.0.0.1'
|
||||
|
||||
ENV["RAILS_ENV"] = "test"
|
||||
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
||||
require 'rails/test_help'
|
||||
@@ -122,7 +124,7 @@ class ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
def self.ldap_configured?
|
||||
@test_ldap = Net::LDAP.new(:host => '127.0.0.1', :port => 389)
|
||||
@test_ldap = Net::LDAP.new(:host => $redmine_test_ldap_server, :port => 389)
|
||||
return @test_ldap.bind
|
||||
rescue Exception => e
|
||||
# LDAP is not listening
|
||||
|
||||
@@ -156,11 +156,9 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
||||
assert_equal [], results
|
||||
end
|
||||
|
||||
def test_ldap_with_correct_host
|
||||
def test_ldap_with_correct_host_and_port
|
||||
auth_source = AuthSourceLdap.find(1)
|
||||
|
||||
assert_equal "127.0.0.1", auth_source.host
|
||||
assert_equal 389, auth_source.port
|
||||
assert_nothing_raised Net::LDAP::Error do
|
||||
auth_source.test_connection
|
||||
end
|
||||
@@ -171,30 +169,16 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
||||
auth_source.host = "badhost"
|
||||
auth_source.save!
|
||||
|
||||
assert_equal "badhost", auth_source.host
|
||||
assert_equal 389, auth_source.port
|
||||
assert_raise Net::LDAP::Error do
|
||||
auth_source.test_connection
|
||||
end
|
||||
end
|
||||
|
||||
def test_ldap_with_correct_port
|
||||
auth_source = AuthSourceLdap.find(1)
|
||||
|
||||
assert_equal "127.0.0.1", auth_source.host
|
||||
assert_equal 389, auth_source.port
|
||||
assert_nothing_raised Net::LDAP::Error do
|
||||
auth_source.test_connection
|
||||
end
|
||||
end
|
||||
|
||||
def test_ldap_with_incorrect_port
|
||||
auth_source = AuthSourceLdap.find(1)
|
||||
auth_source.port = 1234
|
||||
auth_source.save!
|
||||
|
||||
assert_equal "127.0.0.1", auth_source.host
|
||||
assert_equal 1234, auth_source.port
|
||||
assert_raise Net::LDAP::Error do
|
||||
auth_source.test_connection
|
||||
end
|
||||
@@ -206,8 +190,6 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
||||
auth_source.account_password = "secret"
|
||||
auth_source.save!
|
||||
|
||||
assert_equal "127.0.0.1", auth_source.host
|
||||
assert_equal 389, auth_source.port
|
||||
assert_equal "cn=admin,dc=redmine,dc=org", auth_source.account
|
||||
assert_equal "secret", auth_source.account_password
|
||||
assert_nil auth_source.test_connection
|
||||
@@ -216,8 +198,6 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
||||
def test_ldap_bind_without_account_and_password
|
||||
auth_source = AuthSourceLdap.find(1)
|
||||
|
||||
assert_equal "127.0.0.1", auth_source.host
|
||||
assert_equal 389, auth_source.port
|
||||
assert_nil auth_source.account
|
||||
assert_equal "", auth_source.account_password
|
||||
assert_nil auth_source.test_connection
|
||||
@@ -229,8 +209,6 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
||||
auth_source.account_password = "secret"
|
||||
auth_source.save!
|
||||
|
||||
assert_equal "127.0.0.1", auth_source.host
|
||||
assert_equal 389, auth_source.port
|
||||
assert_equal "cn=baduser,dc=redmine,dc=org", auth_source.account
|
||||
assert_equal "secret", auth_source.account_password
|
||||
assert_raise AuthSourceException do
|
||||
@@ -244,8 +222,6 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
||||
auth_source.account_password = "badpassword"
|
||||
auth_source.save!
|
||||
|
||||
assert_equal "127.0.0.1", auth_source.host
|
||||
assert_equal 389, auth_source.port
|
||||
assert_equal "cn=admin,dc=redmine,dc=org", auth_source.account
|
||||
assert_equal "badpassword", auth_source.account_password
|
||||
assert_raise AuthSourceException do
|
||||
|
||||
Reference in New Issue
Block a user