-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FTR] enable roles management testing for Observability project (#196514
) ## Summary This PR makes changes in FTR `saml_auth` service to allow creating custom role for Oblt serverless project, when roles management is explicitly enabled with `--xpack.security.roleManagementEnabled=true` in Kibana server arguments. I also added [role_management/custom_role_access.ts ](x-pack/test_serverless/functional/test_suites/observability/role_management/custom_role_access.ts) as a test example. Currently roles management is enabled in `x-pack/test_serverless/functional/test_suites/observability/config.feature_flags.ts` and after this PR is merged, more tests with custom roles can be added for Oblt project. How to run tests: ``` node scripts/functional_tests --config x-pack/test_serverless/functional/test_suites/observability/config.feature_flags.ts ``` (cherry picked from commit 16c965f)
- Loading branch information
1 parent
9ad35b8
commit a2b973c
Showing
7 changed files
with
165 additions
and
4 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
100 changes: 100 additions & 0 deletions
100
...est_serverless/functional/test_suites/observability/role_management/custom_role_access.ts
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,100 @@ | ||
/* | ||
* 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'; | ||
import { RoleCredentials } from '../../../../shared/services'; | ||
|
||
export default function ({ getPageObjects, getService }: FtrProviderContext) { | ||
const pageObjects = getPageObjects(['svlCommonPage', 'timePicker', 'common', 'header']); | ||
const samlAuth = getService('samlAuth'); | ||
const supertestWithoutAuth = getService('supertestWithoutAuth'); | ||
const esArchiver = getService('esArchiver'); | ||
const kibanaServer = getService('kibanaServer'); | ||
const testSubjects = getService('testSubjects'); | ||
let roleAuthc: RoleCredentials; | ||
|
||
describe('With custom role', function () { | ||
// skipping on MKI while we are working on a solution | ||
this.tags(['skipMKI']); | ||
before(async () => { | ||
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); | ||
await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); | ||
await kibanaServer.uiSettings.update({ | ||
defaultIndex: 'logstash-*', | ||
}); | ||
await samlAuth.setCustomRole({ | ||
elasticsearch: { | ||
indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], | ||
}, | ||
kibana: [ | ||
{ | ||
feature: { | ||
discover: ['read'], | ||
}, | ||
spaces: ['*'], | ||
}, | ||
], | ||
}); | ||
// login with custom role | ||
await pageObjects.svlCommonPage.loginWithCustomRole(); | ||
await pageObjects.svlCommonPage.assertUserAvatarExists(); | ||
}); | ||
|
||
after(async () => { | ||
await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); | ||
await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); | ||
await kibanaServer.uiSettings.replace({}); | ||
await kibanaServer.savedObjects.cleanStandardList(); | ||
if (roleAuthc) { | ||
await samlAuth.invalidateM2mApiKeyWithRoleScope(roleAuthc); | ||
} | ||
// delete custom role | ||
await samlAuth.deleteCustomRole(); | ||
}); | ||
|
||
it('should have limited navigation menu', async () => { | ||
await pageObjects.svlCommonPage.assertUserAvatarExists(); | ||
// discover navigation link is present | ||
await testSubjects.existOrFail('~nav-item-id-last-used-logs-viewer'); | ||
|
||
// all other links in navigation menu are hidden | ||
await testSubjects.missingOrFail('~nav-item-id-dashboards'); | ||
await testSubjects.missingOrFail('~nav-item-id-observability-overview:alerts'); | ||
await testSubjects.missingOrFail('~nav-item-id-observability-overview:cases'); | ||
await testSubjects.missingOrFail('~nav-item-id-slo'); | ||
await testSubjects.missingOrFail('~nav-item-id-aiops'); | ||
await testSubjects.missingOrFail('~nav-item-id-inventory'); | ||
await testSubjects.missingOrFail('~nav-item-id-apm'); | ||
await testSubjects.missingOrFail('~nav-item-id-metrics'); | ||
await testSubjects.missingOrFail('~nav-item-id-synthetics'); | ||
|
||
// TODO: 'Add data' and 'Project Settings' should be hidden | ||
// await testSubjects.missingOrFail('~nav-item-id-observabilityOnboarding'); | ||
// await testSubjects.missingOrFail('~nav-item-id-project_settings_project_nav'); | ||
}); | ||
|
||
it('should access Discover app', async () => { | ||
await pageObjects.common.navigateToApp('discover'); | ||
await pageObjects.timePicker.setDefaultAbsoluteRange(); | ||
await pageObjects.header.waitUntilLoadingHasFinished(); | ||
expect(await testSubjects.exists('unifiedHistogramChart')).to.be(true); | ||
expect(await testSubjects.exists('discoverQueryHits')).to.be(true); | ||
}); | ||
|
||
it('should access console with API key', async () => { | ||
roleAuthc = await samlAuth.createM2mApiKeyWithRoleScope('customRole'); | ||
const { body } = await supertestWithoutAuth | ||
.get('/api/console/api_server') | ||
.set(roleAuthc.apiKeyHeader) | ||
.set(samlAuth.getInternalRequestHeader()) | ||
.set({ 'kbn-xsrf': 'true' }) | ||
.expect(200); | ||
expect(body.es).to.be.ok(); | ||
}); | ||
}); | ||
} |
14 changes: 14 additions & 0 deletions
14
x-pack/test_serverless/functional/test_suites/observability/role_management/index.ts
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('Role Management', function () { | ||
loadTestFile(require.resolve('./custom_role_access')); | ||
}); | ||
} |
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