-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FTR] support "deployment agnostic" api-integration tests #188737
Conversation
hostOptions, | ||
log, | ||
isCloud: config.env.CLOUD_SERVERLESS, | ||
cloudUsersFilePath: `${REPO_ROOT}/.ftr/${rolesFilename}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason not able to use path.resolve
here: Do not import Node.js builtin module "path"
Let me know if there is the way to do it in a reliable way (this code will fail on Windows)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding change: I believe passing the absolute path to the file with credentials gives a better flexibility and also less logic inside SamlSessionManager, which now will be used for both svl & stateful
/ci |
/ci |
/ci |
/ci |
/ci |
/ci |
/ci |
This reverts commit 22fedf1.
…ibana into ftr/unify-saml-auth-service
/ci |
/ci |
import { KibanaServer } from '../..'; | ||
|
||
import { ServerlessAuthProvider } from './serverless/auth_provider'; | ||
import { StatefuAuthProvider } from './stateful/auth_provider'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a typo here. Should be StatefulAuthProvider
/ci |
…ibana into ftr/unify-saml-auth-service
/ci |
/ci |
…ibana into ftr/unify-saml-auth-service
/ci |
⏳ Build in-progress, with failuresFailed CI Steps
Test Failures
History
To update your PR or re-run it, just comment with: |
…services (#189613) ## Summary While working on #188737 I had to move `supertestWithoutAuth` into `kbn-ftr-common-functional-services` package. This change seems to be bigger than initially planned. Moving it to the separate PR with following changes: - move FTR `SupertestWithoutAuthProvider` service to package - remove "duplicates" in favour of service from package - update service type where needed
Work is finished in #189853 |
## Summary ### This PR introduces a new type of API integration tests in FTR: deployment-agnostic ![8zcgq0 (1)](https://github.com/user-attachments/assets/17c6d4ee-7848-4a4c-a006-7ae54e523243) #### Test suite is considered deployment-agnostic when it fulfils the following criteria: **Functionality**: It tests Kibana APIs that are **logically identical in both stateful and serverless environments** for the same SAML roles. **Design**: The test design is **clean and does not require additional logic** to execute in either stateful or serverless environments. ### How It Works Most existing stateful tests use basic authentication for API testing. In contrast, serverless tests use SAML authentication with project-specific role mapping. Since stateful deployments also support SAML, deployment-agnostic tests **configure Elasticsearch and Kibana with SAML authentication in both cases**. For roles, stateful deployments define 'viewer', 'editor', and 'admin' roles with serverless-alike privileges. New `samlAuth` service has `AuthProvider` interface with 2 different implementations: depending on environment context (serverless or stateful) appropriate implementation is used. But it remains on service level and hidden in test suite. test example ``` export default function ({ getService }: DeploymentAgnosticFtrProviderContext) { const samlAuth = getService('samlAuth'); const supertestWithoutAuth = getService('supertestWithoutAuth'); let roleAuthc: RoleCredentials; let internalHeaders: InternalRequestHeader; describe('GET /api/console/api_server', () => { before(async () => { roleAuthc = await samlAuth.createM2mApiKeyWithRoleScope('admin'); internalHeaders = samlAuth.getInternalRequestHeader(); }); after(async () => { await samlAuth.invalidateM2mApiKeyWithRoleScope(roleAuthc); }); it('returns autocomplete definitions', async () => { const { body } = await supertestWithoutAuth .get('/api/console/api_server') .set(roleAuthc.apiKeyHeader) .set(internalHeaders) .set('kbn-xsrf', 'true') .expect(200); expect(body.es).to.be.ok(); const { es: { name, globals, endpoints }, } = body; expect(name).to.be.ok(); expect(Object.keys(globals).length).to.be.above(0); expect(Object.keys(endpoints).length).to.be.above(0); }); }); } ``` Please read [readme](https://github.com/elastic/kibana/blob/966822ac872c71284258faf61682176251bcf2c2/x-pack/test/api_integration/deployment_agnostic/README.md) for more details and step-by-step guide. It should help migrating existing serverless tests to deployment-agnostic, assuming requirements are met. ### Examples Deployment-agnostic tests: ``` x-pack/test/api_integration/deployment_agnostic/apis/console/spec_definitions.ts x-pack/test/api_integration/deployment_agnostic/apis/core/compression.ts x-pack/test/api_integration/deployment_agnostic/apis/painless_lab/painless_lab.ts ``` Configs to run it: ``` node scripts/functional_tests --config x-pack/test/api_integration/deployment_agnostic/oblt.serverless.config.ts node scripts/functional_tests --config x-pack/test/api_integration/deployment_agnostic/search.serverless.config.ts node scripts/functional_tests --config x-pack/test/api_integration/deployment_agnostic/security.serverless.config.ts node scripts/functional_tests --config x-pack/test/api_integration/deployment_agnostic/stateful.config.ts ``` PR is a compact version of #188737 with reduced changes in existing serverless tests. --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: elena-shostak <[email protected]> Co-authored-by: Aleh Zasypkin <[email protected]>
Summary
Closed in favour of #189853
This PR adds capability to create a single test file and run it against both serverless project and stateful deployment.
How it works:
svlUserManager
service is using newSamlAuthProvider
service for SAML authentication for serverless and stateful both locally and in Elastic CloudDeploymentAgnosticFtrProviderContext
limits the scope of FTR services only the ones that compatible in both serverless & statefultest example
stateful config example:
serverless Oblt example
Code changes:
This PR modifies serveless-specific
SvlUserManagerProvider
into deployment agnosticSamlAuthProvider
and moves service intokbn-ftr-common-functional-services
package. Though it is a "common" service, it shouldn't be loaded in tests that use basic authentication (more details in comment below)In oder to guarantee the test to work in both serverless and stateful environments (especially MKI and cloud deployments), it is important for every used FTR service to be "deployment-agnostic".
SamlAuthProvider
can be used as example how to create one. Since FTR config schema hasserverless
property, service can have 2 implementations of the same interface. This way test code remains "clean" keeping all the difference inside the service.As a required dependency,
SupertestWithoutAuthProvider
forSvlUserManagerProvider
service was move to the same package in #189613To simplify new FTR configs creation for serverless and stateful context 2 functions were added: