mariadb/mysql-test/suite/sys_vars/t/secure_auth_func.test
Dmitry Shulga eeb00ceffd MDEV-35617: DROP USER should leave no active session for that user
Follow-up patch with adjustments of test files and updates of result
files for tests.

Some of tests were rewritten slighlty. Everywhere where common
pattern used:
-----
  CREATE USER userA;
  --connect con1 ... userA ...
   <sql statements...>
  --disconnect con1
  DROP USER userA;
-----
the DROP USER statement has been eclosed into the directive
--disable_warnings
--enable_warnings

This change is caused by the race conddition between --disconnect
and DROP USER since a number of currently running sessions
established on behalf the user being dropped is counted by
holding the rw_lock THD_list_iterator::lock that is not acquired on
execution the DROP USER statement but the lock is taken as the last
step on handling disconnection (when the client is already sending
the next statement). Therefore, for the cases where the command
 --disconnect precedes the DROP USER statement
we hide the possible warnings about presence of active sessions
for the user being deleted to make tests deterministic.
2025-06-09 18:24:28 +07:00

124 lines
3.6 KiB
Text

############# mysql-test\t\secure_auth_func.test ##########################
# #
# Variable Name: secure_auth #
# Scope: GLOBAL #
# Access Type: Dynamic #
# Data Type: boolean #
# Default Value: FALSE #
# Values: TRUE / 1, FALSE / 0 #
# #
# #
# Creation Date: 2008-02-22 #
# Author: Sharique Abdullah #
# #
# Description: Test Cases of Dynamic System Variable "secure_auth " #
# that checks behavior of this variable in the following ways#
# * Default Value #
# * Valid & Invalid values #
# * Scope & Access method #
# * Cache behaviors #
# #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
# server-system-variables.html#option_mysqld_secure_auth #
# #
###########################################################################
--echo ** Setup **
--echo
#
# Setup
#
--source include/not_embedded.inc
#
# Save initial value
#
SET @old_secure_auth = @@GLOBAL.secure_auth;
--echo '#--------------------FN_DYNVARS_144_01-------------------------#'
#
# Testing command line option value
#
SELECT @@GLOBAL.secure_auth;
--echo 1 / ON Expected
--echo '#--------------------FN_DYNVARS_144_02-------------------------#'
#
# Value OFF
#
SET GLOBAL secure_auth = OFF;
#
# Creating user with password in NEW format
#
CREATE USER 'testUser'@'localhost' IDENTIFIED BY 'newpass';
connect (con_user1,localhost,testUser,newpass,);
connection default;
#
# Setting password in OLD format
#
SET PASSWORD FOR 'testUser'@'localhost' = OLD_PASSWORD('newpass');
connect (con_user2,localhost,testUser,newpass,,,,auth=mysql_old_password:mysql_native_password);
connection default;
--echo '#--------------------FN_DYNVARS_144_03-------------------------#'
#
# Value ON
#
SET GLOBAL secure_auth = ON;
#
# Setting password in NEW format
#
SET PASSWORD FOR 'testUser'@'localhost' = PASSWORD('newpass');
connect (con_user3,localhost,testUser,newpass,);
connection default;
#
# Setting password in OLD format
#
SET PASSWORD FOR 'testUser'@'localhost' = OLD_PASSWORD('newpass');
--disable_query_log
--error ER_SERVER_IS_IN_SECURE_AUTH_MODE
connect (con_user4,localhost,testUser,newpass,);
--enable_query_log
--echo Expected error "Server is in secure auth mode"
connection default;
#
# Setting password back in NEW format
#
SET PASSWORD FOR 'testUser'@'localhost' = PASSWORD('newpass');
connect (con_user4,localhost,testUser,newpass,);
connection default;
#
# Cleanup
#
SET GLOBAL secure_auth = @old_secure_auth;
disconnect con_user1;
disconnect con_user2;
disconnect con_user3;
disconnect con_user4;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'testUser'@'localhost';
--disable_warnings
DROP USER 'testUser'@'localhost';
--enable_warnings