From d24105d31342e0def89af8bd5745266d09803be1 Mon Sep 17 00:00:00 2001 From: Lola Date: Thu, 15 Aug 2024 11:46:31 -0400 Subject: [PATCH] [Cloud Security] fix creation flow pop-ups in ess and use accordian for cloud credentials (#190471) ## Summary Summarize your PR. If it involves visual changes include a screenshot or gif. `isAgentlessPackagePolicy` is checks for agentless integration for Serverless. Agnostic check that tells is integration is agentless so for now we use `isAgentlessAgentPolicy` which checks if integration is agentless for both ESS and Serverless. Also, my last PR was missing the added accordian fix and test case to ensure Popup is disabled for Agentless and enabled for Agent-based policy. ### Checklist Delete any items that are not applicable to this PR. - [X] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --- .../aws_credentials_form_agentless.tsx | 14 +++++++-- .../gcp_credentials_form_agentless.tsx | 30 ++++++++++++++----- .../single_page_layout/hooks/form.tsx | 5 +++- .../agentless/create_agent.ts | 8 ++++- .../add_cis_integration_form_page.ts | 3 ++ 5 files changed, 48 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/aws_credentials_form_agentless.tsx b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/aws_credentials_form_agentless.tsx index 4e849197854ba..c730153a96254 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/aws_credentials_form_agentless.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/aws_credentials_form_agentless.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { EuiButton, EuiCallOut, EuiLink, EuiSpacer, EuiText } from '@elastic/eui'; +import { EuiAccordion, EuiButton, EuiCallOut, EuiLink, EuiSpacer, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import semverCompare from 'semver/functions/compare'; import semverValid from 'semver/functions/valid'; @@ -68,7 +68,7 @@ Utilize AWS CloudFormation (a built-in AWS tool) or a series of manual steps to ), }} /> - +
    {isOrganization ? ( @@ -251,8 +251,16 @@ export const AwsCredentialsFormAgentless = ({ {awsCredentialsType === DEFAULT_AGENTLESS_AWS_CREDENTIALS_TYPE && showCloudCredentialsButton && ( <> - + Steps to Generate AWS Account Credentials} + paddingSize="l" + > + + + - +
    1. @@ -102,7 +110,7 @@ const GoogleCloudShellCredentialsGuide = (props: {
    2. Launch Google Cloud Shell, }} @@ -206,11 +214,19 @@ export const GcpCredentialsFormAgentless = ({ )} {showCloudCredentialsButton && ( <> - + Steps to Generate GCP Account Credentials} + paddingSize="l" + > + + + 0) && - !isAgentlessPackagePolicy(data!.item) && + !isAgentlessConfigured && hasFleetAddAgentsPrivileges; if (promptForAgentEnrollment && hasAzureArmTemplate) { diff --git a/x-pack/test/cloud_security_posture_functional/agentless/create_agent.ts b/x-pack/test/cloud_security_posture_functional/agentless/create_agent.ts index b4a72d355c68d..1b1497140875e 100644 --- a/x-pack/test/cloud_security_posture_functional/agentless/create_agent.ts +++ b/x-pack/test/cloud_security_posture_functional/agentless/create_agent.ts @@ -27,11 +27,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('Agentless cloud', function () { let cisIntegration: typeof pageObjects.cisAddIntegration; + let cisIntegrationAws: typeof pageObjects.cisAddIntegration.cisAws; let mockApiServer: http.Server; before(async () => { cisIntegration = pageObjects.cisAddIntegration; - mockApiServer = mockAgentlessApiService.listen(8089); // Start the usage api mock server on port 8089 + cisIntegrationAws = pageObjects.cisAddIntegration.cisAws; + mockApiServer = await mockAgentlessApiService.listen(8089); // Start the usage api mock server on port 8081 }); after(async () => { @@ -58,6 +60,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await cisIntegration.clickSaveButton(); await pageObjects.header.waitUntilLoadingHasFinished(); + expect(await cisIntegrationAws.showPostInstallCloudFormationModal()).to.be(false); + await cisIntegration.navigateToIntegrationCspList(); await pageObjects.header.waitUntilLoadingHasFinished(); @@ -84,6 +88,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await cisIntegration.clickSaveButton(); await pageObjects.header.waitUntilLoadingHasFinished(); + expect(await cisIntegrationAws.showPostInstallCloudFormationModal()).to.be(true); + const agentPolicyName = await cisIntegration.getAgentBasedPolicyValue(); await cisIntegration.navigateToIntegrationCspList(); diff --git a/x-pack/test/cloud_security_posture_functional/page_objects/add_cis_integration_form_page.ts b/x-pack/test/cloud_security_posture_functional/page_objects/add_cis_integration_form_page.ts index 37b93d0864c2c..5337e23d985ae 100644 --- a/x-pack/test/cloud_security_posture_functional/page_objects/add_cis_integration_form_page.ts +++ b/x-pack/test/cloud_security_posture_functional/page_objects/add_cis_integration_form_page.ts @@ -54,6 +54,9 @@ export function AddCisIntegrationFormPageProvider({ getPostInstallCloudFormationModal: async () => { return await testSubjects.find('postInstallCloudFormationModal'); }, + showPostInstallCloudFormationModal: async () => { + return await testSubjects.exists('postInstallCloudFormationModal'); + }, showLaunchCloudFormationAgentlessButton: async () => { return await testSubjects.exists('launchCloudFormationAgentlessButton'); },