695 |
695 |
assert_equal "ADMIN", user.login
|
696 |
696 |
end
|
697 |
697 |
|
698 |
|
if ldap_configured?
|
699 |
|
test "#try_to_login using LDAP with failed connection to the LDAP server" do
|
700 |
|
auth_source = AuthSourceLdap.find(1)
|
701 |
|
AuthSource.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::Error, 'Cannot connect')
|
|
698 |
test "#try_to_login! using LDAP with existing user and failed connection to the LDAP server" do
|
|
699 |
auth_source = AuthSourceLdap.find(1)
|
|
700 |
user = users(:users_001)
|
|
701 |
user.update_column :auth_source_id, auth_source.id
|
|
702 |
AuthSource.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::Error, 'Cannot connect')
|
|
703 |
assert_raise(AuthSourceException){ User.try_to_login!('admin', 'admin') }
|
|
704 |
end
|
702 |
705 |
|
703 |
|
assert_nil User.try_to_login('edavis', 'wrong')
|
704 |
|
end
|
|
706 |
test "#try_to_login using LDAP with existing user and failed connection to the LDAP server" do
|
|
707 |
auth_source = AuthSourceLdap.find(1)
|
|
708 |
user = users(:users_001)
|
|
709 |
user.update_column :auth_source_id, auth_source.id
|
|
710 |
AuthSource.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::Error, 'Cannot connect')
|
|
711 |
assert_nil User.try_to_login('admin', 'admin')
|
|
712 |
end
|
|
713 |
|
|
714 |
test "#try_to_login using LDAP with new user and failed connection to the LDAP server" do
|
|
715 |
auth_source = AuthSourceLdap.find(1)
|
|
716 |
auth_source.update onthefly_register: true
|
|
717 |
AuthSource.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::Error, 'Cannot connect')
|
|
718 |
|
|
719 |
assert_nil User.try_to_login('edavis', 'wrong')
|
|
720 |
end
|
|
721 |
|
|
722 |
if ldap_configured?
|
705 |
723 |
|
706 |
724 |
test "#try_to_login using LDAP" do
|
707 |
725 |
assert_nil User.try_to_login('edavis', 'wrong')
|