Do only local auth checks (do ldap tests via integration tests).
This commit is contained in:
parent
4426e83643
commit
6df9dad5b4
4 changed files with 20 additions and 70 deletions
|
@ -1,46 +1,11 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
# set config
|
class AuthTest < ActiveSupport::TestCase
|
||||||
if !ENV['LDAP_HOST']
|
test 'auth' do
|
||||||
fail "ERROR: Need LDAP_HOST - hint LDAP_HOST='ldap://ci.zammad.org'"
|
|
||||||
end
|
|
||||||
|
|
||||||
Setting.create_or_update(
|
user = User.find_by(email: 'nicole.braun@zammad.org')
|
||||||
title: 'Authentication via LDAP',
|
|
||||||
name: 'auth_ldap',
|
|
||||||
area: 'Security::Authentication',
|
|
||||||
description: 'Enables user authentication via LDAP.',
|
|
||||||
state: {
|
|
||||||
adapter: 'Auth::Ldap',
|
|
||||||
host: ENV['LDAP_HOST'],
|
|
||||||
port: 389,
|
|
||||||
bind_dn: 'cn=Manager,dc=example,dc=org',
|
|
||||||
bind_pw: 'example',
|
|
||||||
uid: 'mail',
|
|
||||||
base: 'dc=example,dc=org',
|
|
||||||
always_filter: '',
|
|
||||||
always_roles: %w(Admin Agent),
|
|
||||||
always_groups: ['Users'],
|
|
||||||
sync_params: {
|
|
||||||
firstname: 'sn',
|
|
||||||
lastname: 'givenName',
|
|
||||||
email: 'mail',
|
|
||||||
login: 'mail',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
frontend: false
|
|
||||||
)
|
|
||||||
|
|
||||||
user = User.lookup(email: 'nicole.braun@zammad.org')
|
|
||||||
if user
|
|
||||||
user.update_attributes(
|
user.update_attributes(
|
||||||
login: 'nicole.braun',
|
|
||||||
password: 'some_pass',
|
|
||||||
active: true,
|
|
||||||
)
|
|
||||||
else
|
|
||||||
User.create_if_not_exists(
|
|
||||||
login: 'nicole.braun',
|
login: 'nicole.braun',
|
||||||
firstname: 'Nicole',
|
firstname: 'Nicole',
|
||||||
lastname: 'Braun',
|
lastname: 'Braun',
|
||||||
|
@ -50,10 +15,7 @@ else
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1
|
created_by_id: 1
|
||||||
)
|
)
|
||||||
end
|
|
||||||
|
|
||||||
class AuthTest < ActiveSupport::TestCase
|
|
||||||
test 'auth' do
|
|
||||||
tests = [
|
tests = [
|
||||||
|
|
||||||
# test 1
|
# test 1
|
||||||
|
@ -99,18 +61,6 @@ class AuthTest < ActiveSupport::TestCase
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
# test 5
|
|
||||||
{
|
|
||||||
username: 'paige.chen@example.org',
|
|
||||||
password: 'password',
|
|
||||||
result: true,
|
|
||||||
verify: {
|
|
||||||
firstname: 'Chen',
|
|
||||||
lastname: 'Paige',
|
|
||||||
email: 'paige.chen@example.org',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
]
|
]
|
||||||
tests.each { |test|
|
tests.each { |test|
|
||||||
user = User.authenticate(test[:username], test[:password])
|
user = User.authenticate(test[:username], test[:password])
|
||||||
|
|
Loading…
Reference in a new issue