def test___search_ldap_with_search_referrals(self):
        """
        LDAP: test `_search_ldap` method w/returned search referrals
        """
        self.app.config["AUTH_LDAP_BIND_USER"] = "uid=admin,ou=users,dc=example,dc=org"
        self.app.config["AUTH_LDAP_BIND_PASSWORD"] = "admin_password"
        self.app.config["AUTH_LDAP_SEARCH"] = "ou=users,dc=example,dc=org"
        self.appbuilder = AppBuilder(self.app, self.db.session)
        sm = self.appbuilder.sm
        create_default_users(self.appbuilder.session)

        user_alice = (
            "cn=alice,ou=users,dc=example,dc=org",
            {
                "uid": ["alice"],
                "userPassword": ["alice_password"],
                "memberOf": [b"cn=staff,ou=groups,o=test"],
                "givenName": [b"Alice"],
                "sn": [b"Doe"],
                "mail": [b"alice@example.org"],
            },
        )
        # run `_search_ldap` method w/mocked ldap connection
        mock_con = Mock()
        mock_con.search_s.return_value = [
            (
                None,
                [
                    "ldap://ForestDnsZones.mycompany.com/"
                    "DC=ForestDnsZones,DC=mycompany,DC=com"
                ],
            ),
            user_alice,
            (None, ["ldap://mycompany.com/CN=Configuration,DC=mycompany,DC=com"]),
        ]
        user_dn, user_attributes = sm._search_ldap(ldap, mock_con, "alice")

        # validate - search returned expected data
        self.assertEqual(user_dn, user_alice[0])
        self.assertEqual(user_attributes["givenName"], user_alice[1]["givenName"])
        self.assertEqual(user_attributes["sn"], user_alice[1]["sn"])
        self.assertEqual(user_attributes["mail"], user_alice[1]["mail"])

        mock_con.search_s.assert_called()

        LDAP: test `_search_ldap` method w/returned search referrals
        
tests/security/test_auth_ldap.py