Actions
Defect #44527
openStubs of initialize_ldap_con in UserTest have no effect
Resolution:
Affected version:
Description
The three "failed connection to the LDAP server" tests in test/unit/user_test.rb try to simulate a connection failure with the following stub, but it does not take effect:
AuthSource.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::Error, 'Cannot connect')
Since initialize_ldap_con is defined in AuthSourceLdap, the subclass method takes precedence over the stub on AuthSource. As a result, the tests actually attempt to connect to the test LDAP server (127.0.0.1:389 by default) and pass only because the connection happens to be refused.
The attached patch stubs AuthSourceLdap.any_instance instead, as test/functional/auth_sources_controller_test.rb already does, so that the stub takes effect as originally intended.
Files
Actions