From 753c61997de1acc85e1d13fc13656c4be3d353dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 26 Sep 2017 07:48:45 +0300 Subject: [PATCH] MXS-1451: Expand test case The test now checks that both users with passwords and users without passwords work through MaxScale when skip_authentication is enabled. In addition to this, the test also makes sure that the wrong password and a missing password are properly detected. --- maxscale-system-test/mxs1451_skip_auth.cpp | 35 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/maxscale-system-test/mxs1451_skip_auth.cpp b/maxscale-system-test/mxs1451_skip_auth.cpp index 3a44fa908..972873ac9 100644 --- a/maxscale-system-test/mxs1451_skip_auth.cpp +++ b/maxscale-system-test/mxs1451_skip_auth.cpp @@ -11,28 +11,51 @@ int main(int argc, char *argv[]) TestConnections test(argc, argv); test.set_timeout(60); - test.tprintf("Creating user..."); + test.tprintf("Creating users"); test.repl->connect(); execute_query(test.repl->nodes[0], "CREATE USER 'auth_test'@'%s' IDENTIFIED BY 'test'", test.maxscale_ip()); execute_query(test.repl->nodes[0], "GRANT ALL ON *.* to 'auth_test'@'%s'", test.maxscale_ip()); + execute_query(test.repl->nodes[0], "CREATE USER 'auth_test_nopw'@'%s'", test.maxscale_ip()); + execute_query(test.repl->nodes[0], "GRANT ALL ON *.* to 'auth_test_nopw'@'%s'", test.maxscale_ip()); test.repl->sync_slaves(); test.repl->close_connections(); - test.set_timeout(60); test.tprintf("Trying to connect through MaxScale"); + + test.set_timeout(60); + test.tprintf("... with correct credentials"); MYSQL* conn = open_conn_db(test.rwsplit_port, test.maxscale_ip(), "test", "auth_test", "test", false); test.try_query(conn, "SHOW DATABASES"); mysql_close(conn); - test.tprintf("Trying query with bad credentials"); - conn = open_conn_db(test.rwsplit_port, test.maxscale_ip(), "test", "wrong_user", "wrong_password", false); - test.add_result(execute_query_silent(conn, "SHOW DATABASES") == 0, "Connection with bad credentials should fail"); + test.set_timeout(60); + test.tprintf("... without a password"); + conn = open_conn_db(test.rwsplit_port, test.maxscale_ip(), "test", "auth_test_nopw", "", false); + test.try_query(conn, "SHOW DATABASES"); mysql_close(conn); test.set_timeout(60); - test.tprintf("Dropping user"); + test.tprintf("... with wrong password"); + conn = open_conn_db(test.rwsplit_port, test.maxscale_ip(), "test", "auth_test", "wrong_password", false); + test.add_result(mysql_errno(conn) == 0, "Connection with wrong password should fail"); + mysql_close(conn); + + test.set_timeout(60); + test.tprintf("... with a password for user without a password"); + conn = open_conn_db(test.rwsplit_port, test.maxscale_ip(), "test", "auth_test_nopw", "test", false); + test.add_result(mysql_errno(conn) == 0, "Connection with wrong password to user without a password should fail"); + mysql_close(conn); + + test.tprintf("... with bad credentials"); + conn = open_conn_db(test.rwsplit_port, test.maxscale_ip(), "test", "wrong_user", "wrong_password", false); + test.add_result(mysql_errno(conn) == 0, "Connection with bad credentials should fail"); + mysql_close(conn); + + test.set_timeout(60); + test.tprintf("Dropping users"); test.repl->connect(); execute_query(test.repl->nodes[0], "DROP USER 'auth_test'@'%s'", test.maxscale_ip()); + execute_query(test.repl->nodes[0], "DROP USER 'auth_test_nopw'@'%s'", test.maxscale_ip()); test.repl->close_connections(); return test.global_result;