#
# Testing mysql_config_editor utility.
#
################################################
# Tests for mysql_config_editor's insert command
################################################
#
# Default login path (client)
# done..
# 'test-login-path1'
# done..
# 'test-login-path2'
# done..
# 'test-login-path3'
# done..

################################################
# Tests for mysql_config_editor's print command
################################################
#
# Default path
[client]
user = test_user1
host = localhost

#
# test-login-path1
[test-login-path1]
user = test_user2
host = 127.0.0.1

#
# test-login-path2
[test-login-path2]
user = test_user3
host = www.mysql.com

#
# all the paths
[client]
user = test_user1
host = localhost
[test-login-path1]
user = test_user2
host = 127.0.0.1
[test-login-path2]
user = test_user3
host = www.mysql.com
[test-login-path3]
user = test_user4
host = 127.0.0.1
socket = /tmp/configtest.sock
port = 15000

#
# Overwrite existing paths, test-login-path2 & default
#
# all the paths again
[test-login-path1]
user = test_user2
host = 127.0.0.1
[test-login-path3]
user = test_user4
host = 127.0.0.1
socket = /tmp/configtest.sock
port = 15000
[test-login-path2]
user = test_user4
[client]
user = test_user5

################################################
# Tests for mysql_config_editor's remove command
################################################
#
# Default path
# done..
# test-login-path1
# done..
# test-login-path3
# done..

########################
# Printing the leftovers
########################
#
# using all
[test-login-path3]
user = test_user4
host = 127.0.0.1
[test-login-path2]
user = test_user4

###############################################
# Tests for mysql_config_editor's reset command
###############################################
# done..
# Print-all to check if everything got deleted.

##############################################
# Tests for mysql_config_editor's help command
##############################################
Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

MySQL Configuration Utility.
  -?, --help          Display this help and exit.
  -v, --verbose       Write more information.
  -V, --version       Output version information and exit.

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- ----------------------------------------
verbose                           FALSE

Where command can be any one of the following :
       set [command options]     Sets user name/password/host name/socket/port
                                 for a given login path (section).
       remove [command options]  Remove a login path from the login file.
       print [command options]   Print all the options for a specified
                                 login path.
       reset [command options]   Deletes the contents of the login file.
       help                      Display this usage/help information.

# done..

######################
# Testing client tools
######################
#
# Inserting login paths default & test-login-path1
File exists.
File has the required permission.
Opening the file.
Reading the login key.
Login key read successfully.
Executing set command.
Successfully decrypted the login file.
Key successfully written to the file.
Successfully written encrypted data to the login file.
File exists.
File has the required permission.
Opening the file.
Reading the login key.
Login key read successfully.
Executing set command.
Successfully decrypted the login file.
Key successfully written to the file.
Successfully written encrypted data to the login file.
File exists.
File has the required permission.
Opening the file.
Reading the login key.
Login key read successfully.
Executing set command.
Successfully decrypted the login file.
Key successfully written to the file.
Successfully written encrypted data to the login file.
# done..

# Connecting using 'test_user1'
#
ERROR 1045 (28000): Access denied for user 'test_user1'@'localhost' (using password: NO)

# Connecting using 'test_user2'
#
ERROR 1045 (28000): Access denied for user 'test_user2'@'localhost' (using password: NO)
# Creating user 'test_user1'
CREATE USER test_user1;
# Creating user 'test_user2'
CREATE USER test_user2;
FLUSH PRIVILEGES;
#
# Now trying to connect again..
# Connecting using 'test_user1'
#
mysqld is alive
mysqld is alive

# Connecting using 'test_user2'
#
mysqld is alive
mysqld is alive
#
# Inserting a login path to test group suffix (client_suffix1)

# Printing all the paths..
[client]
user = test_user1
host = localhost
[test-login-path1]
user = test_user2
host = 127.0.0.1
[test-login-path2]
user = test_user3
host = 127.0.0.1
socket = /tmp/configtest.sock
port = 15000
[client_suffix1]
user = test_user3

# Now trying to connect using 'test_user3'
# Note : In this case options from login
#        paths 'client' (default) and 
#        client_suffix1 will be read..
ERROR 1045 (28000): Access denied for user 'test_user3'@'localhost' (using password: NO)
## Running my_print_defaults ##
#
# (a) With --no-defaults option..
# It should print the options under the default
# login path 'client'.
--user=test_user1
--host=localhost

# (b) With --no-defaults & --login-path
--user=test_user1
--host=localhost
--user=test_user2
--host=127.0.0.1
--user=test_user1
--host=localhost
--user=test_user3
--host=127.0.0.1
--socket=/tmp/configtest.sock
--port=15000

# (c) With --no-defaults & --defaults-group-suffix
--user=test_user1
--host=localhost
--user=test_user3

# (d) With --no-defaults, --login-path & --defaults-group-suffix
--user=test_user1
--host=localhost
--user=test_user2
--host=127.0.0.1

# Dropping users 'test_user1' & 'test_user2'
DROP USER test_user1, test_user2;

###############################
# Resetting the test login file
###############################
# done..

####################################
# Testing with an invalid login file
####################################
# mysql_config_editor.test
This is non-standard test login file.
# The 'invalid' login file should not cause
# any problem.
#
mysqld is alive
###############################
# Dropping the test login file
###############################

#################################
# Testing with login file removed
#################################
# Even if login file does not exist, the
# tools should be able to continue
# normally.
mysqld is alive
#### End of test ####
#
# Bug #24557925: MYSQL_CONFIG_EDITOR CAN MAKE SERVER UNBOOTABLE
#
# Restarting the server. Should work
# Cleanup
# End of 5.6 tests
