--source include/have_plugin_auth.inc
--source include/not_embedded.inc

--echo #
--echo # Bug #21235226 : THE --ENABLE-CLEARTEXT-PLUGIN IS NOT IMPLEMENTED
--echo #                 IN ALL CLIENT PROGRAMS
--echo #

CREATE DATABASE db21235226;
USE db21235226;

CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (1), (2);
SELECT * FROM t1;

CREATE USER uplain@localhost IDENTIFIED WITH 'cleartext_plugin_server'
  AS 'cleartext_test';

GRANT ALL PRIVILEGES ON *.* TO uplain@localhost;

#Reset the LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN variable.
let LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN=N;

#Scenario 1 : MYSQL_DUMP without --enable_cleartext_plugin
#             Should get CR_AUTH_PLUGIN_CANNOT_LOAD error
--error 2
--exec $MYSQL_DUMP --user=uplain --password=cleartext_test --tab=$MYSQLTEST_VARDIR/tmp/ db21235226 2>&1

#Scenario 2 : MYSQL_DUMP with --enable_cleartext_plugin
--exec $MYSQL_DUMP --enable_cleartext_plugin --user=uplain --password=cleartext_test --tab=$MYSQLTEST_VARDIR/tmp/ db21235226
--exec $MYSQL --enable_cleartext_plugin --user=uplain --password=cleartext_test db21235226 < $MYSQLTEST_VARDIR/tmp/t1.sql
SELECT * FROM t1;

#Scenario 3 : MYSQL_IMPORT without --enable_cleartext_plugin
#             Should get CR_AUTH_PLUGIN_CANNOT_LOAD error
--replace_regex /.*mysqlimport(\.exe)*/mysqlimport/
--error 1
--exec $MYSQL_IMPORT --user=uplain --password=cleartext_test --silent db21235226 $MYSQLTEST_VARDIR/tmp/t1.txt 2>&1

#Scenario 4 : MYSQL_IMPORT with --enable_cleartext_plugin
--exec $MYSQL_IMPORT --enable_cleartext_plugin --user=uplain --password=cleartext_test --silent db21235226 $MYSQLTEST_VARDIR/tmp/t1.txt
SELECT * FROM t1;

#Scenario 5 : MYSQL_SHOW without --enable_cleartext_plugin
#             Should get CR_AUTH_PLUGIN_CANNOT_LOAD error
--replace_regex /.*mysqlshow(\.exe)*/mysqlshow/
--error 1
--exec $MYSQL_SHOW --user=uplain --password=cleartext_test db21235226 2>&1

#Scenario 6 : MYSQL_SHOW with --enable_cleartext_plugin
--exec $MYSQL_SHOW --enable_cleartext_plugin --user=uplain --password=cleartext_test db21235226

#Scenario 7 : MYSQL_CHECK without --enable_cleartext_plugin
#             Should get CR_AUTH_PLUGIN_CANNOT_LOAD error
--replace_regex /.*mysqlcheck(\.exe)*/mysqlcheck/
--error 2
--exec $MYSQL_CHECK --user=uplain --password=cleartext_test db21235226 t1 2>&1

#Scenario 8 : MYSQL_CHECK with --enable_cleartext_plugin
--exec $MYSQL_CHECK --enable_cleartext_plugin --user=uplain --password=cleartext_test db21235226 t1

#Cleanup
DROP TABLE t1;
DROP DATABASE db21235226;
DROP USER uplain@localhost;
