-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Cloud Security] Fix serverless quality gate tests and introduce a solution for tests that are only run in MKI Serverless Quality Gates #202038
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
Merged
seanrathier
merged 12 commits into
elastic:main
from
seanrathier:11274-fix-the-serverless-quality-gate-tests-for-agentless
Dec 3, 2024
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
476af31
Changeing the agentless serverless tests
seanrathier 8477165
refatoring the MKI tests
seanrathier 3d2068c
Moved files and created MKI directory
seanrathier 75cb72a
Created mkiOnly config
seanrathier 6672ade
adding the AWS creds
seanrathier 48cbd04
removing agentles cloud from security
seanrathier 04a3e44
Fix lint error
seanrathier 32ba051
More changes
seanrathier 0c6b411
Fixed tests and the mki config
seanrathier d96cf75
change suite name of agentless MKI test
seanrathier de9e7ab
renamed index.mki_only.ts
seanrathier 6880dae
adding code owners
seanrathier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
34 changes: 0 additions & 34 deletions
34
...serverless/functional/test_suites/security/config.cloud_security_posture.agentless_api.ts
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
x-pack/test_serverless/functional/test_suites/security/config.mki_only.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * 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 { KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils'; | ||
| import { createTestConfig } from '../../config.base'; | ||
|
|
||
| export default createTestConfig({ | ||
| serverlessProject: 'security', | ||
| testFiles: [require.resolve('./index.mki_only.ts')], | ||
| junit: { | ||
| reportName: 'Serverless Security MKI Functional Tests', | ||
| }, | ||
| suiteTags: { exclude: ['skipSvlSec'] }, | ||
|
|
||
| // include settings from project controller | ||
| // https://github.com/elastic/project-controller/blob/main/internal/project/security/config/elasticsearch.yml | ||
| esServerArgs: ['xpack.ml.nlp.enabled=true'], | ||
| kbnServerArgs: [ | ||
| '--xpack.dataUsage.enabled=true', | ||
| '--xpack.dataUsage.enableExperimental=[]', | ||
| // dataUsage.autoops* config is set in kibana controller | ||
| '--xpack.dataUsage.autoops.enabled=true', | ||
| '--xpack.dataUsage.autoops.api.url=http://localhost:9000', | ||
| `--xpack.dataUsage.autoops.api.tls.certificate=${KBN_CERT_PATH}`, | ||
| `--xpack.dataUsage.autoops.api.tls.key=${KBN_KEY_PATH}`, | ||
| ], | ||
| }); |
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
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
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
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
File renamed without changes.
15 changes: 15 additions & 0 deletions
15
...s/functional/test_suites/security/ftr/cloud_security_posture/mki_only/README.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # MKI Serverless Quality Gates | ||
|
|
||
| This folder contains tests that **ONLY** run in the MKI Serverless Quality Gates. These tests are designed to ensure the security and functionality of the system in a serverless environment. | ||
|
|
||
| ## Contributing | ||
|
|
||
| Please prefix the tests in this folder with `mki_` so that is clear to the following developer that these tests run only in MKI and Serverless Quality Gates. | ||
|
|
||
| New MKI only test files should be loaded from the root index.ts file of the mki_only directory | ||
|
|
||
| ``` | ||
| x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/mki_only/index.ts | ||
| ``` | ||
|
|
||
| If you would like to contribute to these tests, please follow the contribution guidelines outlined in the main project repository. |
104 changes: 104 additions & 0 deletions
104
...al/test_suites/security/ftr/cloud_security_posture/mki_only/agentless/mki_create_agent.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /* | ||
| * 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 { CLOUD_CREDENTIALS_PACKAGE_VERSION } from '@kbn/cloud-security-posture-plugin/common/constants'; | ||
| import expect from '@kbn/expect'; | ||
| import type { FtrProviderContext } from '../../../../../../ftr_provider_context'; | ||
| export default function ({ getPageObjects, getService }: FtrProviderContext) { | ||
| const testSubjects = getService('testSubjects'); | ||
| const pageObjects = getPageObjects([ | ||
| 'svlCommonPage', | ||
| 'cspSecurity', | ||
| 'security', | ||
| 'header', | ||
| 'cisAddIntegration', | ||
| ]); | ||
|
|
||
| const CIS_AWS_OPTION_TEST_ID = 'cisAwsTestId'; | ||
|
|
||
| const AWS_SINGLE_ACCOUNT_TEST_ID = 'awsSingleTestId'; | ||
|
|
||
| // This test suite is only running in the Serverless Quality Gates environment | ||
| describe('Agentless API Serverless MKI only', function () { | ||
| this.tags(['cloud_security_posture_agentless']); | ||
| let cisIntegration: typeof pageObjects.cisAddIntegration; | ||
|
|
||
| before(async () => { | ||
| await pageObjects.svlCommonPage.loginAsAdmin(); | ||
| cisIntegration = pageObjects.cisAddIntegration; | ||
| }); | ||
|
|
||
| it(`should create agentless-agent`, async () => { | ||
| const integrationPolicyName = `cloud_security_posture-${new Date().toISOString()}`; | ||
| await cisIntegration.navigateToAddIntegrationCspmWithVersionPage( | ||
| CLOUD_CREDENTIALS_PACKAGE_VERSION | ||
| ); | ||
|
|
||
| await cisIntegration.clickOptionButton(CIS_AWS_OPTION_TEST_ID); | ||
| await cisIntegration.clickOptionButton(AWS_SINGLE_ACCOUNT_TEST_ID); | ||
|
|
||
| await cisIntegration.inputIntegrationName(integrationPolicyName); | ||
|
|
||
| await cisIntegration.selectSetupTechnology('agentless'); | ||
| await cisIntegration.selectAwsCredentials('direct'); | ||
|
|
||
| await pageObjects.header.waitUntilLoadingHasFinished(); | ||
|
|
||
| if (process.env.CSPM_AWS_ACCOUNT_ID && process.env.CSPM_AWS_SECRET_KEY) { | ||
| await cisIntegration.fillInTextField( | ||
| cisIntegration.testSubjectIds.DIRECT_ACCESS_KEY_ID_TEST_ID, | ||
| process.env.CSPM_AWS_ACCOUNT_ID | ||
| ); | ||
|
|
||
| await cisIntegration.fillInTextField( | ||
| cisIntegration.testSubjectIds.DIRECT_ACCESS_SECRET_KEY_TEST_ID, | ||
| process.env.CSPM_AWS_SECRET_KEY | ||
| ); | ||
| } | ||
|
|
||
| await cisIntegration.clickSaveButton(); | ||
| await pageObjects.header.waitUntilLoadingHasFinished(); | ||
|
|
||
| await cisIntegration.navigateToIntegrationCspList(); | ||
| await pageObjects.header.waitUntilLoadingHasFinished(); | ||
|
|
||
| expect(await cisIntegration.getFirstCspmIntegrationPageAgentlessIntegration()).to.be( | ||
| integrationPolicyName | ||
| ); | ||
|
|
||
| const agentStatusBadge = testSubjects.find('agentlessStatusBadge'); | ||
| // The status badge could be either "Pending", "Healthy", or "Unhealthy" so we are just checking that it exists | ||
| expect(agentStatusBadge).to.be.ok(); | ||
| }); | ||
|
|
||
| it(`should create default agent-based agent`, async () => { | ||
| const integrationPolicyName = `cloud_security_posture-${new Date().toISOString()}`; | ||
|
|
||
| await cisIntegration.navigateToAddIntegrationCspmWithVersionPage( | ||
| CLOUD_CREDENTIALS_PACKAGE_VERSION | ||
| ); | ||
|
|
||
| await cisIntegration.clickOptionButton(CIS_AWS_OPTION_TEST_ID); | ||
| await cisIntegration.clickOptionButton(AWS_SINGLE_ACCOUNT_TEST_ID); | ||
|
|
||
| await cisIntegration.inputIntegrationName(integrationPolicyName); | ||
|
|
||
| await cisIntegration.clickSaveButton(); | ||
| await pageObjects.header.waitUntilLoadingHasFinished(); | ||
|
|
||
| const agentPolicyName = await cisIntegration.getAgentBasedPolicyValue(); | ||
|
|
||
| await cisIntegration.navigateToIntegrationCspList(); | ||
| await pageObjects.header.waitUntilLoadingHasFinished(); | ||
|
|
||
| expect(await cisIntegration.getFirstCspmIntegrationPageIntegration()).to.be( | ||
| integrationPolicyName | ||
| ); | ||
| expect(await cisIntegration.getFirstCspmIntegrationPageAgent()).to.be(agentPolicyName); | ||
| }); | ||
| }); | ||
| } | ||
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
15 changes: 15 additions & 0 deletions
15
x-pack/test_serverless/functional/test_suites/security/index.mki_only.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| * 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('serverless security UI MKI only', function () { | ||
| this.tags(['security-mki-only ']); | ||
| loadTestFile(require.resolve('./ftr/cloud_security_posture/mki_only')); | ||
| }); | ||
| } |
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
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.
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 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.
It's a good compromise 👌