From c878146c240cd6171e6cd8854d43c4e0aff419f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 29 Aug 2018 23:05:28 +0300 Subject: [PATCH] MXS-1947: Add test case The test checks that composite roles work. --- maxscale-system-test/CMakeLists.txt | 4 ++ .../mxs1947_composite_roles.cpp | 55 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 maxscale-system-test/mxs1947_composite_roles.cpp diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index d18cea2ff..a2bbbc342 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -487,6 +487,10 @@ add_test_executable(mxs827_write_timeout.cpp mxs827_write_timeout mxs827_write_t # https://jira.mariadb.org/browse/MXS-872 add_test_executable(mxs872_roles.cpp mxs872_roles replication LABELS REPL_BACKEND) +# MXS-1947: Composite roles are not supported +# https://jira.mariadb.org/browse/MXS-1947 +add_test_executable(mxs1947_composite_roles.cpp mxs1947_composite_roles replication LABELS REPL_BACKEND) + # Block and unblock first and second slaves and check that they are recovered add_test_executable(mxs874_slave_recovery.cpp mxs874_slave_recovery mxs874 LABELS readwritesplit REPL_BACKEND) diff --git a/maxscale-system-test/mxs1947_composite_roles.cpp b/maxscale-system-test/mxs1947_composite_roles.cpp new file mode 100644 index 000000000..70c90b6b7 --- /dev/null +++ b/maxscale-system-test/mxs1947_composite_roles.cpp @@ -0,0 +1,55 @@ +/** + * MXS-1947: Composite roles are not supported + * + * https://jira.mariadb.org/browse/MXS-1947 + */ + +#include "testconnections.h" + +int main(int argc, char** argv) +{ + TestConnections test(argc, argv); + + test.repl->connect(); + + auto prepare = + { + "DROP USER test@'%'", + "CREATE USER test@'%' IDENTIFIED BY 'test';", + "CREATE ROLE a;", + "CREATE ROLE b;", + "CREATE DATABASE db;", + "GRANT ALL ON db.* TO a;", + "GRANT a TO b;", + "GRANT b TO test@'%';", + "SET DEFAULT ROLE b FOR test@'%';" + }; + + for (auto a : prepare) + { + execute_query_silent(test.repl->nodes[0], a); + } + + // Wait for the users to replicate + test.repl->sync_slaves(); + + test.tprintf("Connect with a user that has a composite role as the default role"); + MYSQL* conn = open_conn_db(test.maxscales->rwsplit_port[0], test.maxscales->IP[0], "db", "test", "test"); + test.assert(mysql_errno(conn) == 0, "Connection failed: %s", mysql_error(conn)); + mysql_close(conn); + + auto cleanup = + { + "DROP DATABASE IF EXISTS db;", + "DROP ROLE IF EXISTS a;", + "DROP ROLE IF EXISTS b;", + "DROP USER 'test'@'%';" + }; + + for (auto a : cleanup) + { + execute_query_silent(test.repl->nodes[0], a); + } + + return test.global_result; +}