-
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.
[stats] fix error when requesting extended stats by unauth users (#16…
…0520) ## Summary Fix #160385 Use the internal client instead of the scoped one for the extended stats ES requests to avoid an error with unauthenticated users (when anonymous access is allowed) --------- Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
3d05f74
commit 7fb8f6b
Showing
6 changed files
with
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { FtrConfigProviderContext } from '@kbn/test'; | ||
|
||
export default async function ({ readConfigFile }: FtrConfigProviderContext) { | ||
const baseIntegrationTestsConfig = await readConfigFile(require.resolve('../../config.ts')); | ||
|
||
return { | ||
...baseIntegrationTestsConfig.getAll(), | ||
kbnTestServer: { | ||
...baseIntegrationTestsConfig.get('kbnTestServer'), | ||
serverArgs: [ | ||
...baseIntegrationTestsConfig.get('kbnTestServer.serverArgs'), | ||
'--status.allowAnonymous=true', | ||
], | ||
}, | ||
testFiles: [require.resolve('.')], | ||
}; | ||
} |
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,14 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default function ({ loadTestFile }: FtrProviderContext) { | ||
describe('Stats API', () => { | ||
loadTestFile(require.resolve('./stats')); | ||
}); | ||
} |
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,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
|
||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default function ({ getService }: FtrProviderContext) { | ||
const supertest = getService('supertest'); | ||
const supertestWithoutAuth = getService('supertestWithoutAuth'); | ||
|
||
describe('GET /api/stats', () => { | ||
describe('When status.allowAnonymous is true', () => { | ||
describe('when requesting extended stats', () => { | ||
it('returns extended stats payload for authenticated requests', async () => { | ||
const { body } = await supertest | ||
.get('/api/stats?extended=true') | ||
.set('kbn-xsrf', 'kibana') | ||
.expect(200); | ||
|
||
expect(body.cluster_uuid).to.be.a('string'); | ||
expect(body.usage).to.be.an('object'); | ||
}); | ||
it('returns extended stats payload for unauthenticated requests', async () => { | ||
const { body } = await supertestWithoutAuth | ||
.get('/api/stats?extended=true') | ||
.set('kbn-xsrf', 'kibana') | ||
.expect(200); | ||
|
||
expect(body.cluster_uuid).to.be.a('string'); | ||
expect(body.usage).to.be.an('object'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |