Skip to content

Commit 895cf84

Browse files
committed
WL#15239: Do necessary callback cleanups in tests.
1 parent 87dab5b commit 895cf84

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

jdbc/test/unit/classes/connection.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4083,7 +4083,6 @@ void connection::test_fido_webauthn(sql::ConnectOptionsMap &opt, bool callback_i
40834083
driver->setCallBack(CB{nullptr});
40844084
test_connection(0);
40854085

4086-
40874086
cout << endl << "Multi driver tests: " << endl;
40884087

40894088
auto multi_drv_test = [test_connection_drv]()
@@ -4102,6 +4101,11 @@ void connection::test_fido_webauthn(sql::ConnectOptionsMap &opt, bool callback_i
41024101

41034102
test_connection_drv(111, driver1);
41044103
test_connection_drv(222, driver2);
4104+
4105+
// Multi-driver callbacks have to be reset too.
4106+
// Otherwise they will remain set in the next test.
4107+
driver1->setCallBack(CB{nullptr});
4108+
driver2->setCallBack(CB{nullptr});
41054109
};
41064110

41074111
multi_drv_test();
@@ -4127,7 +4131,6 @@ void connection::test_fido_webauthn(sql::ConnectOptionsMap &opt, bool callback_i
41274131
cout << e.what() << endl;
41284132
FAIL("Unexpected error!");
41294133
}
4130-
41314134
cout << "Success\n";
41324135
}
41334136

@@ -4155,6 +4158,10 @@ void connection::fido_test()
41554158
<< "Check that webauthn callback is not used for fido accounts" << endl;
41564159

41574160
test_fido_webauthn<sql::WebAuthn_Callback, MyWindowWebAuthn>(opt, true);
4161+
4162+
// Clear up the callback.
4163+
sql::Driver *driver = sql::mysql::get_driver_instance();
4164+
driver->setCallBack(sql::WebAuthn_Callback{nullptr});
41584165
}
41594166

41604167

@@ -4181,6 +4188,11 @@ void connection::webauthn_test()
41814188

41824189
cout << endl << "Running tests with Fido callbacks" << endl;
41834190

4191+
// Prevent errors by resetting callback set as Webauthn_Callback
4192+
// because the next test uses Fido_Callback.
4193+
sql::Driver *driver = sql::mysql::get_driver_instance();
4194+
driver->setCallBack(sql::WebAuthn_Callback{nullptr});
4195+
41844196
test_fido_webauthn<sql::Fido_Callback, MyWindowFido>(opt);
41854197

41864198
cout << endl << "Overwrite WebAuthn callback with Fido one" << endl;
@@ -4196,6 +4208,9 @@ void connection::webauthn_test()
41964208
catch (sql::SQLException&)
41974209
{}
41984210
}
4211+
4212+
// Clear up the callback.
4213+
driver->setCallBack(sql::WebAuthn_Callback{nullptr});
41994214
}
42004215

42014216

0 commit comments

Comments
 (0)