Skip to content

Commit 9bb496e

Browse files
[CSP] Fix agentless GCP CIS integration test - handle Cloud Connector credential selector (#271805)
## Summary Fixes the consistently failing `cis_integration_gcp.ts` agentless test (#262351). **Root cause:** When GCP Cloud Connectors are enabled (CSP package >= `3.3.0-preview03`), the agentless GCP form now defaults to the `cloud_connectors` credential type, which renders `LazyCloudConnectorSetup` instead of the Launch Cloud Shell button. The test was unconditionally asserting the Cloud Shell button, causing a consistent failure. **Fix:** Add `selectGcpCredentials` and `isGcpCredentialSelectorVisible` page object helpers, then conditionally switch to `credentials-json` before asserting the Cloud Shell button — mirroring the same pattern the AWS test uses with `selectAwsCredentials('direct')`. ## Changes - `add_cis_integration_form_page.ts`: Added `selectGcpCredentials` and `isGcpCredentialSelectorVisible` page object methods - `cis_integration_gcp.ts`: Un-skipped outer `describe.skip`, added conditional credential type selection before asserting Cloud Shell button Note: The inner `describe.skip('Serverless - Agentless CIS_GCP edit flow')` remains skipped (separate issue with `getFieldAttributeValue` returning `[object Object]`). ## Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/GUIDELINE.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/) was added for features that require explanation or tutorials - [ ] [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 - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ## Identify risks - Low. Only test code changed, no production code. - The fix degrades gracefully: `isGcpCredentialSelectorVisible()` returns false when GCP Cloud Connectors are not enabled (older package), so no credential switch is attempted and the existing assertion continues to work. Made with [Cursor](https://cursor.com) Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 5546a9b commit 9bb496e

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

x-pack/solutions/security/test/cloud_security_posture_functional/page_objects/add_cis_integration_form_page.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,23 @@ export function AddCisIntegrationFormPageProvider({
370370
await selectValue(AWS_CREDENTIAL_SELECTOR, credentialTypeValue);
371371
};
372372

373+
/**
374+
* Selects a GCP credential type from the credential type selector.
375+
* This selector only appears when GCP Cloud Connectors are enabled (package >= 3.3.0-preview03).
376+
* Use to switch away from the default 'cloud_connectors' type so that the Cloud Shell button is visible.
377+
*/
378+
const selectGcpCredentials = async (credentialType: 'credentials-json' | 'cloud_connectors') => {
379+
await selectValue('gcpCredentialTypeSelector', credentialType);
380+
};
381+
382+
/**
383+
* Returns true if the GCP credential type selector is present in the DOM.
384+
* It only appears when GCP Cloud Connectors are enabled (package >= 3.3.0-preview03).
385+
*/
386+
const isGcpCredentialSelectorVisible = async () => {
387+
return testSubjects.exists('gcpCredentialTypeSelector');
388+
};
389+
373390
const clickOptionButton = async (text: string) => {
374391
const optionToBeClicked = await findOptionInPage(text);
375392
await optionToBeClicked.scrollIntoView();
@@ -701,6 +718,8 @@ export function AddCisIntegrationFormPageProvider({
701718
findOptionInPage,
702719
clickOptionButton,
703720
selectAwsCredentials,
721+
selectGcpCredentials,
722+
isGcpCredentialSelectorVisible,
704723
selectSetupTechnology,
705724
getSetupTechnologyRadio,
706725
clickSaveButton,

x-pack/solutions/security/test/serverless/functional/test_suites/ftr/cloud_security_posture/agentless/cis_integration_gcp.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
1818

1919
const supertest = getService('supertest');
2020

21-
// Failing: See https://github.com/elastic/kibana/issues/262351
22-
describe.skip('Agentless CIS Integration Page', function () {
21+
describe('Agentless CIS Integration Page', function () {
2322
// TODO: we need to check if the tests are running on MKI. There is a suspicion that installing csp package via Kibana server args is not working on MKI.
2423
this.tags(['skipMKI', 'cloud_security_posture_cis_integration']);
2524
let cisIntegration: typeof pageObjects.cisAddIntegration;
@@ -54,6 +53,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
5453

5554
await cisIntegration.selectSetupTechnology('agentless');
5655

56+
// When GCP Cloud Connectors are enabled (package >= 3.3.0-preview03), the form defaults
57+
// to the cloud_connectors credential type. Switch to credentials-json to show the
58+
// Cloud Shell button — same pattern used by the AWS test with selectAwsCredentials('direct').
59+
if (await cisIntegration.isGcpCredentialSelectorVisible()) {
60+
await cisIntegration.selectGcpCredentials('credentials-json');
61+
}
62+
5763
await pageObjects.header.waitUntilLoadingHasFinished();
5864

5965
expect(await cisIntegrationGcp.showLaunchCloudShellAgentlessButton()).to.be(true);
@@ -67,6 +73,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
6773
await cisIntegration.clickOptionButton(GCP_PROVIDER_TEST_SUBJ);
6874
await cisIntegration.selectSetupTechnology('agentless');
6975

76+
// Same as above — switch away from cloud_connectors when the selector is visible.
77+
if (await cisIntegration.isGcpCredentialSelectorVisible()) {
78+
await cisIntegration.selectGcpCredentials('credentials-json');
79+
}
80+
7081
await pageObjects.header.waitUntilLoadingHasFinished();
7182

7283
expect(await cisIntegrationGcp.showLaunchCloudShellAgentlessButton()).to.be(true);

0 commit comments

Comments
 (0)