MXS-1354: Update mxs729_maxadmin test

Updated test to check the new behavior of the admin users.
This commit is contained in:
Markus Mäkelä 2017-08-19 10:18:56 +03:00
parent cc8fb995cd
commit 80ef13c7f2

View File

@ -19,6 +19,7 @@ using namespace std;
const char * only_root = "Enabled Linux accounts (secure) : \n";
const char * user_added = "The Linux user %s has successfully been enabled.\n";
const char * user_removed = "The Linux user %s has successfully been disabled.\n";
const char * remove_last_admin = "Cannot remove the last admin account";
const char * root_added = "User root has been successfully added.\n";
const char * user_and_root = "Enabled Linux accounts (secure) : %s\n";
const char * user_only = "Enabled Linux accounts (secure) : %s\n";
@ -55,9 +56,9 @@ void add_remove_maxadmin_user(TestConnections* Test)
Test->tprintf("trying maxadmin with 'root':\n");
int st5 = Test->ssh_maxscale(true, "maxadmin show users");
if (st5 != 0)
if (st5 == 0)
{
Test->add_result(1, "User added and access to MaxAdmin as 'root' became impossible\n");
Test->add_result(1, "User added and access to MaxAdmin as 'root' is still possible\n");
}
else
{
@ -77,13 +78,15 @@ void add_remove_maxadmin_user(TestConnections* Test)
Test->tprintf("OK\n");
}
Test->tprintf("removing user '%s'\n", Test->maxscale_access_user);
char * st8 = Test->ssh_maxscale_output(true, "maxadmin disable account %s", Test->maxscale_access_user);
Test->tprintf("trying maxadmin with 'root': %s\n", st8);
sprintf(str, user_removed, Test->maxscale_access_user);
if (strstr(st8, str) == NULL)
Test->tprintf("creating readonly user");
Test->ssh_maxscale(false, "maxadmin add readonly-user test test");
Test->tprintf("trying to remove user '%s'\n", Test->maxscale_access_user);
char * st8 = Test->ssh_maxscale_output(false, "maxadmin disable account %s", Test->maxscale_access_user);
if (strstr(st8, remove_last_admin) == NULL)
{
Test->add_result(1, "Wrong output of disable command\n");
Test->add_result(1, "Wrong output of disable command: %s", st8);
}
else
{
@ -92,10 +95,9 @@ void add_remove_maxadmin_user(TestConnections* Test)
Test->tprintf("Trying with removed user '%s'\n", Test->maxscale_access_user);
int st9 = Test->ssh_maxscale(false, "maxadmin show users");
if (st9 == 0)
if (st9 != 0)
{
Test->add_result(1, "User '%s'' removed, but access to MaxAdmin as '%s' is still possible\n",
Test->maxscale_access_user, Test->maxscale_access_user);
Test->add_result(1, "Last user '%s' should not be removed", Test->maxscale_access_user);
}
else
{