[8.x] [FTR] support custom native roles in serverless tests (#194677)#196351
Merged
dmlemeshko merged 2 commits intoelastic:8.xfrom Oct 16, 2024
Merged
[8.x] [FTR] support custom native roles in serverless tests (#194677)#196351dmlemeshko merged 2 commits intoelastic:8.xfrom
dmlemeshko merged 2 commits intoelastic:8.xfrom
Conversation
## Summary
This PR updates FTR services to support authentication with custom
native role. Few notes:
- for compatibility with MKI we reserve **"customRole"** as a custom
role name used in tests
- test user is **automatically assigned** to this role, but before login
in browser/ generating cookie header or API key in each test suite
**role privileges must me updated according test scenario**
How to test:
I added a new test file for Search project:
`x-pack/test_serverless/functional/test_suites/search/custom_role_access.ts`
It can be run locally with:
```
node scripts/functional_tests --config=x-pack/test_serverless/functional/test_suites/search/config.ts --grep "With custom role"
```
FTR UI test example:
```ts
// First set privileges for custom role
await samlAuth.setCustomRole({
elasticsearch: {
indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }],
},
kibana: [
{
feature: {
discover: ['read'],
},
spaces: ['*'],
},
],
});
});
// Then you can login in browser as a user with newly defined privileges
await pageObjects.svlCommonPage.loginWithCustomRole();
```
FTR api_integration test example:
```ts
// First set privileges for custom role
await samlAuth.setCustomRole({
elasticsearch: {
indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }],
},
kibana: [
{
feature: {
discover: ['read'],
},
spaces: ['*'],
},
],
});
});
// Then you can generate an API key with newly defined privileges
const roleAuthc = await samlAuth.createM2mApiKeyWithRoleScope('customRole');
// Don't forget to invalidate the API key in the end
await samlAuth.invalidateM2mApiKeyWithRoleScope(roleAuthc);
```
(cherry picked from commit f00ac7a)
# Conflicts:
# packages/kbn-ftr-common-functional-services/services/saml_auth/serverless/auth_provider.ts
# packages/kbn-ftr-common-functional-services/services/saml_auth/stateful/auth_provider.ts
# x-pack/test_serverless/api_integration/test_suites/common/platform_security/authorization.ts
# x-pack/test_serverless/functional/config.base.ts
pheyos
approved these changes
Oct 16, 2024
wayneseymour
approved these changes
Oct 16, 2024
Contributor
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Any counts in public APIs
History
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
mainto8.x:Questions ?
Please refer to the Backport tool documentation