MXS-1354: Add creation of basic/admin users to maxctrl
The type of the created user can now be specified with the --type option. Expanded tests that cover the user creation. Also added a test case that checks that basic users are only allowed to read through the REST API.
This commit is contained in:
@ -174,6 +174,13 @@ exports.builder = function(yargs) {
|
||||
return doRequest(host, 'services/' + argv.service + '/listeners', null, {method: 'POST', body: listener})
|
||||
})
|
||||
})
|
||||
.group(['type'], 'Create user options:')
|
||||
.option('type', {
|
||||
describe: 'Type of user to create',
|
||||
type: 'string',
|
||||
default: 'basic',
|
||||
choices: ['admin', 'basic']
|
||||
})
|
||||
.command('user <name> <password>', 'Create a new network user', {}, function(argv) {
|
||||
|
||||
var user = {
|
||||
@ -181,7 +188,8 @@ exports.builder = function(yargs) {
|
||||
'id': argv.name,
|
||||
'type': 'inet',
|
||||
'attributes': {
|
||||
'password': argv.password
|
||||
'password': argv.password,
|
||||
'account': argv.type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,11 +35,21 @@ exports.builder = function(yargs) {
|
||||
})
|
||||
}
|
||||
})
|
||||
.group(['type'], 'Enable account options:')
|
||||
.option('type', {
|
||||
describe: 'Type of user to create',
|
||||
type: 'string',
|
||||
default: 'basic',
|
||||
choices: ['admin', 'basic']
|
||||
})
|
||||
.command('account <name>', 'Activate a Linux user account for administrative use', {}, function(argv) {
|
||||
var req_body = {
|
||||
data: {
|
||||
id: argv.name,
|
||||
type: 'unix'
|
||||
type: 'unix',
|
||||
attributes: {
|
||||
'account': argv.type
|
||||
}
|
||||
}
|
||||
}
|
||||
maxctrl(argv, function(host) {
|
||||
|
@ -131,14 +131,38 @@ describe("Create/Destroy Commands", function() {
|
||||
})
|
||||
|
||||
it('create user', function() {
|
||||
return verifyCommand('create user testuser test',
|
||||
'users/inet/testuser')
|
||||
.should.be.fulfilled
|
||||
return verifyCommand('create user testuser test', 'users/inet/testuser')
|
||||
})
|
||||
|
||||
it('destroy user', function() {
|
||||
return doCommand('destroy user testuser')
|
||||
.should.be.fulfilled
|
||||
})
|
||||
|
||||
it('create admin user', function() {
|
||||
return verifyCommand('create user testadmin test --type=admin', 'users/inet/testadmin')
|
||||
.then((res) => {
|
||||
res.data.attributes.account.should.equal('admin')
|
||||
})
|
||||
})
|
||||
|
||||
it('destroy admin user', function() {
|
||||
return doCommand('destroy user testadmin')
|
||||
})
|
||||
|
||||
it('create basic user', function() {
|
||||
return verifyCommand('create user testbasic test --type=basic', 'users/inet/testbasic')
|
||||
.then((res) => {
|
||||
res.data.attributes.account.should.equal('basic')
|
||||
})
|
||||
})
|
||||
|
||||
it('destroy basic user', function() {
|
||||
return doCommand('destroy user testbasic')
|
||||
})
|
||||
|
||||
it('create user with bad type', function() {
|
||||
return doCommand('create user testadmin test --type=superuser')
|
||||
.should.be.rejected
|
||||
})
|
||||
|
||||
after(stopMaxScale)
|
||||
|
Reference in New Issue
Block a user