@@ -2141,6 +2141,108 @@ TEST_F(MySQL_upgrade_check_test, deprecated_auth_method_check_fido) {
2141
2141
ASSERT_NO_THROW (session->execute (" drop schema if exists test;" ));
2142
2142
}
2143
2143
2144
+ namespace {
2145
+ std::string local_usr (const std::string &user) { return user + " @localhost" ; }
2146
+
2147
+ void drop_user (std::shared_ptr<mysqlshdk::db::ISession> session,
2148
+ const std::string &user) {
2149
+ ASSERT_NO_THROW (
2150
+ session->execute (" drop user if exists '" + user + " '@'localhost';" ));
2151
+ }
2152
+
2153
+ void add_user (std::shared_ptr<mysqlshdk::db::ISession> session,
2154
+ const std::string &user, const std::string &plugin) {
2155
+ ASSERT_NO_THROW (session->execute (" create user '" + user +
2156
+ " '@'localhost' identified with "
2157
+ " '" +
2158
+ plugin + " ';" ));
2159
+ }
2160
+ } // namespace
2161
+
2162
+ TEST_F (MySQL_upgrade_check_test, deprecated_router_auth_method_check) {
2163
+ bool authentication_fido_installed = is_plugin_loaded (" authentication_fido" );
2164
+ bool uninstall_authentication_fido = false ;
2165
+ if (!authentication_fido_installed) {
2166
+ authentication_fido_installed = install_plugin (" authentication_fido" );
2167
+ if (!authentication_fido_installed) {
2168
+ SKIP_TEST (
2169
+ " This test requires loaded authentication_fido MySQL Server plugin." );
2170
+ } else {
2171
+ uninstall_authentication_fido = true ;
2172
+ }
2173
+ }
2174
+
2175
+ const std::string k_usr_sha = " user_sha_auth2" ;
2176
+ const std::string k_usr_native = " usr_native_auth2" ;
2177
+ const std::string k_usr_fido = " user_fido_auth2" ;
2178
+ const std::string k_router_user1 = " mysql_router1_79mwl0xo1ep5" ;
2179
+ const std::string k_router_user2 = " mysql_router335_cb43tc6945rz" ;
2180
+
2181
+ const std::string k_auth_sha = " sha256_password" ;
2182
+ const std::string k_auth_native = " mysql_native_password" ;
2183
+ const std::string k_auth_fido = " authentication_fido" ;
2184
+
2185
+ shcore::Scoped_callback cleanup ([this , uninstall_authentication_fido,
2186
+ &k_usr_sha, &k_usr_native, &k_usr_fido,
2187
+ &k_router_user1, &k_router_user2]() {
2188
+ drop_user (session, k_usr_sha);
2189
+ drop_user (session, k_usr_native);
2190
+ drop_user (session, k_usr_fido);
2191
+ drop_user (session, k_router_user1);
2192
+ drop_user (session, k_router_user2);
2193
+ if (uninstall_authentication_fido) {
2194
+ uninstall_plugin (" authentication_fido" );
2195
+ }
2196
+ });
2197
+
2198
+ PrepareTestDatabase (" test" );
2199
+
2200
+ Upgrade_check::Upgrade_info temp_info;
2201
+ temp_info.target_version = Version (8 , 4 , 0 );
2202
+ auto check =
2203
+ Sql_upgrade_check::get_deprecated_router_auth_method_check (temp_info);
2204
+
2205
+ EXPECT_ISSUES (check.get (), 0 );
2206
+
2207
+ add_user (session, k_usr_sha, k_auth_sha);
2208
+ add_user (session, k_usr_native, k_auth_native);
2209
+ add_user (session, k_usr_fido, k_auth_fido);
2210
+
2211
+ EXPECT_ISSUES (check.get (), 0 );
2212
+
2213
+ add_user (session, k_router_user1, k_auth_native);
2214
+ add_user (session, k_router_user2, k_auth_sha);
2215
+
2216
+ EXPECT_ISSUES (check.get (), 2 );
2217
+
2218
+ EXPECT_EQ (issues[0 ].schema , local_usr (k_router_user1));
2219
+ EXPECT_EQ (issues[0 ].level , Upgrade_issue::Level::ERROR);
2220
+ EXPECT_EQ (issues[0 ].description ,
2221
+ " - router user with deprecated authentication method." );
2222
+
2223
+ EXPECT_EQ (issues[1 ].schema , local_usr (k_router_user2));
2224
+ EXPECT_EQ (issues[1 ].level , Upgrade_issue::Level::ERROR);
2225
+ EXPECT_EQ (issues[1 ].description ,
2226
+ " - router user with deprecated authentication method." );
2227
+
2228
+ temp_info.target_version = Version (8 , 2 , 0 );
2229
+ check = Sql_upgrade_check::get_deprecated_router_auth_method_check (temp_info);
2230
+
2231
+ EXPECT_ISSUES (check.get (), 2 );
2232
+
2233
+ EXPECT_EQ (issues[0 ].schema , local_usr (k_router_user1));
2234
+ EXPECT_EQ (issues[0 ].level , Upgrade_issue::Level::WARNING);
2235
+ EXPECT_EQ (issues[0 ].description ,
2236
+ " - router user with deprecated authentication method." );
2237
+
2238
+ EXPECT_EQ (issues[1 ].schema , local_usr (k_router_user2));
2239
+ EXPECT_EQ (issues[1 ].level , Upgrade_issue::Level::WARNING);
2240
+ EXPECT_EQ (issues[1 ].description ,
2241
+ " - router user with deprecated authentication method." );
2242
+
2243
+ ASSERT_NO_THROW (session->execute (" drop schema if exists test;" ));
2244
+ }
2245
+
2144
2246
namespace dep_def_auth_check {
2145
2247
void set_authentication_policy (std::shared_ptr<mysqlshdk::db::ISession> session,
2146
2248
const std::string &val) {
0 commit comments