Project

General

Profile

Actions

Defect #44527

closed

Stubs of initialize_ldap_con in UserTest have no effect

Added by Go MAEDA 25 days ago. Updated 23 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Resolution:
Fixed
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 #2

Updated by Go MAEDA 24 days ago

  • Status changed from New to Resolved
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch in r25158.

Actions #3

Updated by Go MAEDA 23 days ago

  • Status changed from Resolved to Closed

Merged the fix into the stable branches in r25174 and r25175.

Actions

Also available in: Atom PDF