Merge branch '2.3' into develop
This commit is contained in:
@ -135,6 +135,28 @@ exports.builder = function(yargs) {
|
||||
return updateValue(host, 'maxscale', 'data.attributes.parameters.' + argv.key, argv.value)
|
||||
})
|
||||
})
|
||||
.command('user <name> <password>', 'Alter admin user passwords', function(yargs) {
|
||||
return yargs.epilog('Changes the password for a user. To change the user type, destroy the user and then create it again.')
|
||||
.usage('Usage: alter user <name> <password>')
|
||||
}, function(argv) {
|
||||
maxctrl(argv, function(host) {
|
||||
|
||||
var user = {
|
||||
'data': {
|
||||
'id': argv.name,
|
||||
'type': 'inet',
|
||||
'attributes': {
|
||||
'password': argv.password
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return getJson(host, 'users/inet/' + argv.name)
|
||||
.then((res) => user.data.attributes.account = res.data.attributes.account)
|
||||
.then(() => doRequest(host, 'users/inet/' + argv.name, null, {method: 'DELETE'}))
|
||||
.then(() => doRequest(host, 'users/inet', null, {method: 'POST', body: user}))
|
||||
})
|
||||
})
|
||||
.usage('Usage: alter <command>')
|
||||
.help()
|
||||
.command('*', 'the default command', {}, function(argv) {
|
||||
|
||||
@ -166,12 +166,10 @@ exports.builder = function(yargs) {
|
||||
}
|
||||
}
|
||||
|
||||
if (argv.params) {
|
||||
var err = validateParams(argv, argv.params)
|
||||
if (err) {
|
||||
return Promise.reject(err)
|
||||
}
|
||||
var err = false;
|
||||
|
||||
if (argv.params) {
|
||||
err = validateParams(argv, argv.params)
|
||||
monitor.data.attributes.parameters = argv.params.reduce(to_obj, {})
|
||||
}
|
||||
|
||||
@ -189,6 +187,9 @@ exports.builder = function(yargs) {
|
||||
}
|
||||
|
||||
maxctrl(argv, function(host) {
|
||||
if (err) {
|
||||
return Promise.reject(err)
|
||||
}
|
||||
return doRequest(host, 'monitors', null, {method: 'POST', body: monitor})
|
||||
})
|
||||
})
|
||||
|
||||
@ -108,5 +108,17 @@ describe("Alter Commands", function() {
|
||||
.should.be.rejected
|
||||
})
|
||||
|
||||
it('creates user', function() {
|
||||
return verifyCommand('create user testuser test', 'users/inet/testuser')
|
||||
})
|
||||
|
||||
it('alters the password of a user', function() {
|
||||
return verifyCommand('alter user testuser test2', 'users/inet/testuser')
|
||||
})
|
||||
|
||||
it('destroys the altered user', function() {
|
||||
return doCommand('destroy user testuser')
|
||||
})
|
||||
|
||||
after(stopMaxScale)
|
||||
});
|
||||
|
||||
@ -18,6 +18,18 @@ describe("Create/Destroy Commands", function() {
|
||||
.should.be.rejected
|
||||
})
|
||||
|
||||
it('monitor without parameters fails due to missing user parameter', function() {
|
||||
return verifyCommand('create monitor my-monitor mysqlmon', 'monitors/my-monitor')
|
||||
.should.be.rejected
|
||||
})
|
||||
|
||||
it('destroy monitor created without parameters', function() {
|
||||
return doCommand('destroy monitor my-monitor')
|
||||
.should.be.fulfilled
|
||||
.then(() => doCommand('show monitor my-monitor'))
|
||||
.should.be.rejected
|
||||
})
|
||||
|
||||
it('will not destroy the same monitor again', function() {
|
||||
return doCommand('destroy monitor my-monitor')
|
||||
.should.be.rejected
|
||||
@ -38,6 +50,11 @@ describe("Create/Destroy Commands", function() {
|
||||
.should.be.rejected
|
||||
})
|
||||
|
||||
it('will not create monitor with malformed parameters', function() {
|
||||
return doCommand('create monitor my-monitor mariadbmon not-a-param')
|
||||
.should.be.rejected
|
||||
})
|
||||
|
||||
it('create monitor with options', function() {
|
||||
return doCommand('unlink monitor MariaDB-Monitor server4')
|
||||
.then(() => verifyCommand('create monitor my-monitor mysqlmon --servers server4 --monitor-user maxuser --monitor-password maxpwd',
|
||||
|
||||
@ -15,5 +15,10 @@ describe("Draining servers", function() {
|
||||
.should.eventually.have.string("Maintenance")
|
||||
})
|
||||
|
||||
it('does not drain non-existent server', function() {
|
||||
return doCommand('drain server not-a-server')
|
||||
.should.be.rejected
|
||||
})
|
||||
|
||||
after(stopMaxScale)
|
||||
});
|
||||
|
||||
@ -19,7 +19,8 @@ describe("Unknown Commands", function() {
|
||||
'alter',
|
||||
'rotate',
|
||||
'call',
|
||||
'cluster'
|
||||
'cluster',
|
||||
'drain'
|
||||
]
|
||||
|
||||
endpoints.forEach(function (i) {
|
||||
|
||||
Reference in New Issue
Block a user