Skip to content

Commit 87dab5b

Browse files
Bogdan Degtyariovrsomla1
authored andcommitted
WL#15239: Add PLUGIN_DIR env variable for webauthn_test, use different accounts for Fido and WebAuthn
Change-Id: I179ff2126a8bbac46e0db5e83058fade087b1fda
1 parent 18b3dc2 commit 87dab5b

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

jdbc/test/unit/classes/connection.cpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3965,22 +3965,22 @@ void connection::tls_deprecation()
39653965

39663966
/*
39673967
Testing FIDO/WebAuthn connection and callback functionality.
3968-
3968+
39693969
These tests are designed for manual run. They require the following preparation steps:
3970-
3970+
39713971
1. Install FIDO auth plugin on the server:
39723972
39733973
INSTALL PLUGIN authentication_fido SONAME 'authentication_fido.so'
39743974
39753975
2. Create user with FIDO/Webauthn authentication:
39763976
3977-
CREATE USER 'u2'@'localhost'
3977+
CREATE USER 'ufido'@'localhost'
39783978
IDENTIFIED WITH caching_sha2_password BY 'sha2_password'
39793979
AND IDENTIFIED WITH authentication_webauthn
39803980
39813981
3. Register FIDO:
39823982
3983-
mysql --port=13000 --protocol=tcp --user=u2 --password1 --fido-register-factor=2
3983+
mysql --port=13000 --protocol=tcp --user=ufido --password1 --fido-register-factor=2
39843984
39853985
4. Set env variable MYSQL_FIDO to non-empty value
39863986
*/
@@ -4024,19 +4024,15 @@ class MyWindowWebAuthn : public sql::WebAuthn_Callback
40244024
*/
40254025

40264026
template <class CB, class MY>
4027-
void connection::test_fido_webauthn(bool callback_ignored)
4027+
void connection::test_fido_webauthn(sql::ConnectOptionsMap &opt, bool callback_ignored)
40284028
{
40294029
using std::string;
40304030
using std::cout;
40314031
using std::endl;
4032-
4033-
String fido_user = "u2";
4034-
String fido_pwd = "sha2_password";
40354032

4036-
sql::ConnectOptionsMap opt;
40374033
opt[OPT_HOSTNAME] = url;
4038-
opt[OPT_USERNAME] = fido_user;
4039-
opt[OPT_PASSWORD] = fido_pwd;
4034+
if (getenv("PLUGIN_DIR"))
4035+
opt[OPT_PLUGIN_DIR] = getenv("PLUGIN_DIR");
40404036

40414037
sql::Driver * driver = sql::mysql::get_driver_instance();
40424038

@@ -4057,7 +4053,6 @@ void connection::test_fido_webauthn(bool callback_ignored)
40574053
try
40584054
{
40594055

4060-
40614056
cout << endl << "Default callback (0)" << endl;
40624057
test_connection(0);
40634058

@@ -4138,7 +4133,7 @@ void connection::test_fido_webauthn(bool callback_ignored)
41384133

41394134

41404135
/*
4141-
Note: This test is expecting account `u2` configured to use
4136+
Note: This test is expecting account `ufido` configured to use
41424137
`authentication_fido` plugin.
41434138
*/
41444139

@@ -4150,17 +4145,21 @@ void connection::fido_test()
41504145
if(!getenv("MYSQL_FIDO"))
41514146
return;
41524147

4153-
test_fido_webauthn<sql::Fido_Callback, MyWindowFido>();
4148+
sql::ConnectOptionsMap opt;
4149+
opt[OPT_USERNAME] = "ufido";
4150+
opt[OPT_PASSWORD] = "sha2_password";
4151+
4152+
test_fido_webauthn<sql::Fido_Callback, MyWindowFido>(opt);
41544153

41554154
cout << endl
4156-
<< "Check that webauthn callback is not used for fido accounts" << endl;
4155+
<< "Check that webauthn callback is not used for fido accounts" << endl;
41574156

4158-
test_fido_webauthn<sql::WebAuthn_Callback, MyWindowWebAuthn>(true);
4157+
test_fido_webauthn<sql::WebAuthn_Callback, MyWindowWebAuthn>(opt, true);
41594158
}
41604159

41614160

41624161
/*
4163-
Note: This test is expecting account `u2` configured to use
4162+
Note: This test is expecting account `uwebauthn` configured to use
41644163
`authentication_webauthn` plugin.
41654164
*/
41664165

@@ -4172,13 +4171,17 @@ void connection::webauthn_test()
41724171
if(!getenv("MYSQL_FIDO") && !getenv("MYSQL_WEBAUTHN"))
41734172
return;
41744173

4175-
test_fido_webauthn<sql::WebAuthn_Callback, MyWindowWebAuthn>();
4174+
sql::ConnectOptionsMap opt;
4175+
opt[OPT_USERNAME] = "uwebauthn";
4176+
opt[OPT_PASSWORD] = "sha2_password";
4177+
4178+
test_fido_webauthn<sql::WebAuthn_Callback, MyWindowWebAuthn>(opt);
41764179

41774180
// Note: The fido callback should also work
41784181

41794182
cout << endl << "Running tests with Fido callbacks" << endl;
41804183

4181-
test_fido_webauthn<sql::Fido_Callback, MyWindowFido>();
4184+
test_fido_webauthn<sql::Fido_Callback, MyWindowFido>(opt);
41824185

41834186
cout << endl << "Overwrite WebAuthn callback with Fido one" << endl;
41844187

jdbc/test/unit/classes/connection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class connection : public unit_fixture
4848
typedef unit_fixture super;
4949

5050
template <class CB, class MY>
51-
void test_fido_webauthn(bool = false);
51+
void test_fido_webauthn(sql::ConnectOptionsMap&, bool = false);
5252

5353
protected:
5454

0 commit comments

Comments
 (0)