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;