mariadb/mysql-test/suite/plugins/t/unix_socket.test
Kristian Nielsen 3180e76262 MDEV-7089: Test failures in main.failed_auth_unixsocket and plugins.unix_socket depending on environment
The test cases had some --replace_result $USER USER. The problem is that the
value of $USER can be anything, depending on the name of the unix account that
runs the test suite. So random parts of the result can be errorneously
replaced, causing test failures.

Fix by making the replacements more specific, so they will match only the
intended stuff regardless of the value of $USER.
2014-11-12 11:10:13 +01:00

60 lines
1.5 KiB
Text

--source include/have_unix_socket.inc
if (!$USER) {
skip USER variable is undefined;
}
let $plugindir=`SELECT @@global.plugin_dir`;
eval install plugin unix_socket soname '$AUTH_SOCKET_SO';
--echo #
--echo # with named user
--echo #
--let $replace=create user $USER
--replace_result $replace "create user USER"
eval create user $USER identified via unix_socket;
--write_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt
--let $replace1=$USER@localhost
--let $replace2=$USER@%
--replace_result $replace1 "USER@localhost" $replace2 "USER@%"
select user(), current_user(), database();
EOF
--echo #
--echo # name match = ok
--echo #
--exec $MYSQL_TEST -u $USER --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt
--echo #
--echo # name does not match = failure
--echo #
--error 1
--exec $MYSQL_TEST -u foobar --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt
--let $replace=drop user $USER
--replace_result $replace "drop user USER"
eval drop user $USER;
--echo #
--echo # and now with anonymous user
--echo #
grant SELECT ON test.* TO '' identified via unix_socket;
--echo #
--echo # name match = ok
--echo #
--exec $MYSQL_TEST -u $USER --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt
--echo #
--echo # name does not match = failure
--echo #
--error 1
--exec $MYSQL_TEST -u foobar --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt
# restoring mysql.user to the original state.
delete from mysql.user where user='';
uninstall plugin unix_socket;
--remove_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt