-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add error messages when setup mode is not enabled, disable it for use…
…rs without the necessary permissions, and change one query to relax the privilege requirements
- Loading branch information
1 parent
19f7e99
commit b3455a0
Showing
5 changed files
with
150 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
x-pack/test/api_integration/apis/monitoring/setup/collection/security.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
|
||
export default function ({ getService }) { | ||
const supertest = getService('supertest'); | ||
const esArchiver = getService('esArchiver'); | ||
const security = getService('security'); | ||
const supertestWithoutAuth = getService('supertestWithoutAuth'); | ||
|
||
describe('security', () => { | ||
const archive = 'monitoring/setup/collection/kibana_exclusive_mb'; | ||
const timeRange = { | ||
min: '2019-04-09T00:00:00.741Z', | ||
max: '2019-04-09T23:59:59.741Z' | ||
}; | ||
|
||
before('load archive', () => { | ||
return esArchiver.load(archive); | ||
}); | ||
|
||
after('unload archive', () => { | ||
return esArchiver.unload(archive); | ||
}); | ||
|
||
it('should allow access to elevated user', async () => { | ||
const { body } = await supertest | ||
.post('/api/monitoring/v1/setup/collection/cluster?skipLiveData=true') | ||
.set('kbn-xsrf', 'xxx') | ||
.send({ timeRange }) | ||
.expect(200); | ||
|
||
expect(body.hasPermissions).to.not.be(false); | ||
}); | ||
|
||
it('should say permission denied for limited user', async () => { | ||
const username = 'limited_user'; | ||
const password = 'changeme'; | ||
|
||
await security.user.create(username, { | ||
password: password, | ||
full_name: 'Limited User', | ||
roles: ['kibana_user', 'monitoring_user'] | ||
}); | ||
|
||
const { body } = await supertestWithoutAuth | ||
.post('/api/monitoring/v1/setup/collection/cluster?skipLiveData=true') | ||
.auth(username, password) | ||
.set('kbn-xsrf', 'xxx') | ||
.send({ timeRange }) | ||
.expect(200); | ||
|
||
expect(body.hasPermissions).to.be(false); | ||
}); | ||
}); | ||
} |