-
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.
[8.16] [FTR] enable roles management testing for Observability project (
#196514) (#196862) # Backport This will backport the following commits from `main` to `8.16`: - [[FTR] enable roles management testing for Observability project (#196514)](#196514) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Dzmitry Lemechko","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-18T12:17:13Z","message":"[FTR] enable roles management testing for Observability project (#196514)\n\n## Summary\r\n\r\nThis PR makes changes in FTR `saml_auth` service to allow creating\r\ncustom role for Oblt serverless project, when roles management is\r\nexplicitly enabled with `--xpack.security.roleManagementEnabled=true` in\r\nKibana server arguments.\r\n\r\nI also added [role_management/custom_role_access.ts\r\n](x-pack/test_serverless/functional/test_suites/observability/role_management/custom_role_access.ts)\r\nas a test example. Currently roles management is enabled in\r\n`x-pack/test_serverless/functional/test_suites/observability/config.feature_flags.ts`\r\nand after this PR is merged, more tests with custom roles can be added\r\nfor Oblt project.\r\n\r\nHow to run tests:\r\n\r\n```\r\nnode scripts/functional_tests --config x-pack/test_serverless/functional/test_suites/observability/config.feature_flags.ts\r\n```","sha":"16c965f853f17565e2da996b1f2ab21e9e33a003","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","v8.16.0","backport:version"],"title":"[FTR] enable roles management testing for Observability project","number":196514,"url":"https://github.com/elastic/kibana/pull/196514","mergeCommit":{"message":"[FTR] enable roles management testing for Observability project (#196514)\n\n## Summary\r\n\r\nThis PR makes changes in FTR `saml_auth` service to allow creating\r\ncustom role for Oblt serverless project, when roles management is\r\nexplicitly enabled with `--xpack.security.roleManagementEnabled=true` in\r\nKibana server arguments.\r\n\r\nI also added [role_management/custom_role_access.ts\r\n](x-pack/test_serverless/functional/test_suites/observability/role_management/custom_role_access.ts)\r\nas a test example. Currently roles management is enabled in\r\n`x-pack/test_serverless/functional/test_suites/observability/config.feature_flags.ts`\r\nand after this PR is merged, more tests with custom roles can be added\r\nfor Oblt project.\r\n\r\nHow to run tests:\r\n\r\n```\r\nnode scripts/functional_tests --config x-pack/test_serverless/functional/test_suites/observability/config.feature_flags.ts\r\n```","sha":"16c965f853f17565e2da996b1f2ab21e9e33a003"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196514","number":196514,"mergeCommit":{"message":"[FTR] enable roles management testing for Observability project (#196514)\n\n## Summary\r\n\r\nThis PR makes changes in FTR `saml_auth` service to allow creating\r\ncustom role for Oblt serverless project, when roles management is\r\nexplicitly enabled with `--xpack.security.roleManagementEnabled=true` in\r\nKibana server arguments.\r\n\r\nI also added [role_management/custom_role_access.ts\r\n](x-pack/test_serverless/functional/test_suites/observability/role_management/custom_role_access.ts)\r\nas a test example. Currently roles management is enabled in\r\n`x-pack/test_serverless/functional/test_suites/observability/config.feature_flags.ts`\r\nand after this PR is merged, more tests with custom roles can be added\r\nfor Oblt project.\r\n\r\nHow to run tests:\r\n\r\n```\r\nnode scripts/functional_tests --config x-pack/test_serverless/functional/test_suites/observability/config.feature_flags.ts\r\n```","sha":"16c965f853f17565e2da996b1f2ab21e9e33a003"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Dzmitry Lemechko <[email protected]>
- Loading branch information
1 parent
d7bbd0a
commit e42cc1f
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