Skip to content

Commit

Permalink
[Cloud Security][FTR] FTRs for GCP Single account (#168773)
Browse files Browse the repository at this point in the history
## Summary

This PR is for GCP Single Account related FTRs

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
animehart and kibanamachine authored Oct 14, 2023
1 parent 14a6e89 commit fe7afbb
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,14 @@ const credentialOptionsList = [
defaultMessage: 'Credentials File',
}),
value: 'credentials-file',
'data-test-subj': 'credentials_file_option_test_id',
},
{
text: i18n.translate('xpack.csp.gcpIntegration.credentialsJsonOption', {
defaultMessage: 'Credentials JSON',
}),
value: 'credentials-json',
'data-test-subj': 'credentials_json_option_test_id',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,23 @@ export function AddCisIntegrationFormPageProvider({
},

fillInTextField: async (selector: string, text: string) => {
const test = await testSubjects.find(selector);
await test.type(text);
const textField = await testSubjects.find(selector);
await textField.type(text);
},

chooseDropDown: async (selector: string, text: string) => {
const credentialTypeBox = await testSubjects.find(selector);
const chosenOption = await testSubjects.find(text);
await credentialTypeBox.click();
await chosenOption.click();
},

getFieldValueInEditPage: async (field: string) => {
/* Newly added/edited integration always shows up on top by default as such we can just always click the most top if we want to check for the latest one */
const integrationList = await testSubjects.findAll('integrationNameLink');
await integrationList[0].click();
const fieldValue = await (await testSubjects.find(field)).getAttribute('value');
return fieldValue;
},
};

Expand All @@ -75,8 +90,16 @@ export function AddCisIntegrationFormPageProvider({
);
};

const navigateToIntegrationCspList = async () => {
await PageObjects.common.navigateToActualUrl(
'integrations', // Defined in Security Solution plugin
'/detail/cloud_security_posture/policies'
);
};

return {
cisGcp,
navigateToAddIntegrationCspmPage,
navigateToIntegrationCspList,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const GCP_MANUAL_TEST_ID = 'gcpManualOptionTestId';
const PRJ_ID_TEST_ID = 'project_id_test_id';
const ORG_ID_TEST_ID = 'organization_id_test_id';
const CREDENTIALS_TYPE_TEST_ID = 'credentials_type_test_id';
const CREDENTIALS_FILE_TEST_ID = 'credentials_file_test_id';
const CREDENTIALS_JSON_TEST_ID = 'credentials_json_test_id';

// eslint-disable-next-line import/no-default-export
export default function (providerContext: FtrProviderContext) {
Expand Down Expand Up @@ -103,5 +105,75 @@ export default function (providerContext: FtrProviderContext) {
);
});
});

describe('CIS_GCP Single', () => {
it('Post Installation Google Cloud Shell modal pops up after user clicks on Save button when adding integration, when there are no Project ID, it should use default value', async () => {
await cisIntegrationGcp.clickOptionButton(CIS_GCP_OPTION_TEST_ID);
await cisIntegrationGcp.clickOptionButton(GCP_SINGLE_ACCOUNT_TEST_ID);
await cisIntegrationGcp.clickOptionButton(GCP_CLOUD_SHELL_TEST_ID);
await cisIntegrationGcp.clickSaveButton();
pageObjects.header.waitUntilLoadingHasFinished();
expect((await cisIntegrationGcp.isPostInstallGoogleCloudShellModal(false)) === true).to.be(
true
);
});

it('Post Installation Google Cloud Shell modal pops up after user clicks on Save button when adding integration, when there are Project ID, it should use that value', async () => {
const projectName = 'PRJ_NAME_TEST';
await cisIntegrationGcp.clickOptionButton(CIS_GCP_OPTION_TEST_ID);
await cisIntegrationGcp.clickOptionButton(GCP_SINGLE_ACCOUNT_TEST_ID);
await cisIntegrationGcp.clickOptionButton(GCP_CLOUD_SHELL_TEST_ID);
await cisIntegrationGcp.fillInTextField('project_id_test_id', projectName);

await cisIntegrationGcp.clickSaveButton();
pageObjects.header.waitUntilLoadingHasFinished();
expect(
(await cisIntegrationGcp.isPostInstallGoogleCloudShellModal(false, '', projectName)) ===
true
).to.be(true);
});

it('Users are able to add CIS_GCP Integration with Manual settings using Credentials File', async () => {
const projectName = 'PRJ_NAME_TEST';
const credentialFileName = 'CRED_FILE_TEST_NAME';
await cisIntegrationGcp.clickOptionButton(CIS_GCP_OPTION_TEST_ID);
await cisIntegrationGcp.clickOptionButton(GCP_SINGLE_ACCOUNT_TEST_ID);
await cisIntegrationGcp.clickOptionButton(GCP_MANUAL_TEST_ID);
await cisIntegrationGcp.fillInTextField(PRJ_ID_TEST_ID, projectName);
await cisIntegrationGcp.fillInTextField(CREDENTIALS_FILE_TEST_ID, credentialFileName);

await cisIntegrationGcp.clickSaveButton();
pageObjects.header.waitUntilLoadingHasFinished();
expect((await cisIntegrationGcp.getPostInstallModal()) !== undefined).to.be(true);
await cisIntegration.navigateToIntegrationCspList();
expect(
(await cisIntegrationGcp.getFieldValueInEditPage(CREDENTIALS_FILE_TEST_ID)) ===
credentialFileName
).to.be(true);
});

it('Users are able to add CIS_GCP Integration with Manual settings using Credentials JSON', async () => {
const projectName = 'PRJ_NAME_TEST';
const credentialJsonName = 'CRED_JSON_TEST_NAME';
await cisIntegrationGcp.clickOptionButton(CIS_GCP_OPTION_TEST_ID);
await cisIntegrationGcp.clickOptionButton(GCP_SINGLE_ACCOUNT_TEST_ID);
await cisIntegrationGcp.clickOptionButton(GCP_MANUAL_TEST_ID);
await cisIntegrationGcp.fillInTextField(PRJ_ID_TEST_ID, projectName);
await cisIntegrationGcp.chooseDropDown(
CREDENTIALS_TYPE_TEST_ID,
'credentials_json_option_test_id'
);
await cisIntegrationGcp.fillInTextField(CREDENTIALS_JSON_TEST_ID, credentialJsonName);

await cisIntegrationGcp.clickSaveButton();
pageObjects.header.waitUntilLoadingHasFinished();
expect((await cisIntegrationGcp.getPostInstallModal()) !== undefined).to.be(true);
await cisIntegration.navigateToIntegrationCspList();
expect(
(await cisIntegrationGcp.getFieldValueInEditPage(CREDENTIALS_JSON_TEST_ID)) ===
credentialJsonName
).to.be(true);
});
});
});
}

0 comments on commit fe7afbb

Please sign in to comment.