From d2b474e02169862df32ccd747b4fa05639744505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 7 Sep 2017 19:27:50 +0300 Subject: [PATCH] Fix enabled admin users being shown as basic users The enabled admins for the Linux users were shown as basic users. This was caused by the separation of the two admin types. Added tests that check that enabled Linux accounts show the correct type in the output. --- maxctrl/test/enabledisable.js | 12 +++++++++++- server/core/adminusers.cc | 8 +++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/maxctrl/test/enabledisable.js b/maxctrl/test/enabledisable.js index f7ea37beb..b7bbbab17 100644 --- a/maxctrl/test/enabledisable.js +++ b/maxctrl/test/enabledisable.js @@ -29,7 +29,7 @@ describe("Enable/Disable Commands", function() { it('enable account', function() { return verifyCommand('enable account test', 'users/unix/test') - .should.be.fulfilled + .should.eventually.have.deep.property('data.attributes.account', 'basic') }) it('disable account', function() { @@ -37,5 +37,15 @@ describe("Enable/Disable Commands", function() { .should.be.fulfilled }) + it('enable admin account', function() { + return verifyCommand('enable account test --type=admin', 'users/unix/test') + .should.eventually.have.deep.property('data.attributes.account', 'admin') + }) + + it('disable admin account', function() { + return doCommand('disable account test') + .should.be.fulfilled + }) + after(stopMaxScale) }); diff --git a/server/core/adminusers.cc b/server/core/adminusers.cc index 0de140af4..17e9d2868 100644 --- a/server/core/adminusers.cc +++ b/server/core/adminusers.cc @@ -178,7 +178,13 @@ static std::string path_from_type(enum user_type type) json_t* admin_user_to_json(const char* host, const char* user, enum user_type type) { - user_account_type account = admin_user_is_inet_admin(user) ? USER_ACCOUNT_ADMIN : USER_ACCOUNT_BASIC; + user_account_type account = USER_ACCOUNT_BASIC; + if ((type == USER_TYPE_INET && admin_user_is_inet_admin(user)) || + (type == USER_TYPE_UNIX && admin_user_is_unix_admin(user))) + { + account = USER_ACCOUNT_ADMIN; + } + std::string path = path_from_type(type); path += "/"; path += user;