mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 13:01:56 +00:00
test(ui): add AWS provider E2E test for assume role using AWS SDK defaults
- Implemented a new test case to validate the addition of an AWS provider using assume role credentials sourced from the AWS SDK default chain. - Enhanced the ProvidersPage class with a method to select the authentication method, including AWS SDK Default. - Updated the providers markdown documentation to include detailed steps and expected results for the new test case. - Ensured that the test checks for proper environment variable configuration and verifies the scheduled scan status after provider addition.
This commit is contained in:
@@ -41,7 +41,8 @@ export interface GitHubProviderData {
|
||||
// AWS credential options
|
||||
export const AWS_CREDENTIAL_OPTIONS = {
|
||||
AWS_ROLE_ARN: "role",
|
||||
AWS_CREDENTIALS: "credentials"
|
||||
AWS_CREDENTIALS: "credentials",
|
||||
AWS_SDK_DEFAULT: "aws-sdk-default"
|
||||
} as const;
|
||||
|
||||
// AWS credential type
|
||||
@@ -53,6 +54,8 @@ export interface AWSProviderCredential {
|
||||
roleArn?: string;
|
||||
externalId?: string;
|
||||
accessKeyId?: string;
|
||||
sdkAccessKeyId?: string;
|
||||
sdkSecretAccessKey?: string;
|
||||
secretAccessKey?: string;
|
||||
}
|
||||
|
||||
@@ -1011,4 +1014,26 @@ export class ProvidersPage extends BasePage {
|
||||
const scansPage = new ScansPage(this.page);
|
||||
await scansPage.verifyPageLoaded();
|
||||
}
|
||||
|
||||
async selectAuthenticationMethod(method: AWSCredentialType): Promise<void> {
|
||||
// Select the authentication method
|
||||
|
||||
// Search botton that contains text AWS SDK Default or Prowler Cloud will assume or Access & Secret Key
|
||||
const button = this.page.locator('button').filter({ hasText: /AWS SDK Default|Prowler Cloud will assume|Access & Secret Key/i });
|
||||
await button.click();
|
||||
|
||||
if (method === AWS_CREDENTIAL_OPTIONS.AWS_ROLE_ARN) {
|
||||
|
||||
const modal = this.page.locator('[role="dialog"], .modal, [data-testid*="modal"]').first();
|
||||
await expect(modal).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Select the role credentials
|
||||
this.page.getByRole('option', { name: 'Access & Secret Key' }).click({ force: true });
|
||||
} else if (method === AWS_CREDENTIAL_OPTIONS.AWS_SDK_DEFAULT) {
|
||||
// Select the AWS SDK Default
|
||||
this.page.getByRole('option', { name: 'AWS SDK Default' }).click({ force: true });
|
||||
} else {
|
||||
throw new Error(`Invalid authentication method: ${method}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +118,65 @@
|
||||
|
||||
---
|
||||
|
||||
## Test Case: `PROVIDER-E2E-011` - Add AWS Provider with Assume Role via AWS SDK Defaults
|
||||
|
||||
**Priority:** `critical`
|
||||
|
||||
**Tags:**
|
||||
|
||||
- type → @e2e, @serial
|
||||
- feature → @providers
|
||||
- provider → @aws
|
||||
|
||||
**Description/Objective:** Validates adding an AWS provider assuming a role while sourcing credentials from the AWS SDK default chain (e.g., `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`) instead of manually entered keys.
|
||||
|
||||
**Preconditions:**
|
||||
|
||||
- Admin user authentication required (admin.auth.setup setup)
|
||||
- Environment variables configured: E2E_AWS_PROVIDER_ACCOUNT_ID, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, E2E_AWS_PROVIDER_ROLE_ARN
|
||||
- Remove any existing provider with the same Account ID before starting the test
|
||||
- This test must be run serially and never in parallel with other tests, as it requires the Account ID not to be already registered beforehand
|
||||
|
||||
### Flow Steps:
|
||||
|
||||
1. Navigate to providers page
|
||||
2. Click "Add Provider" button
|
||||
3. Select AWS provider type
|
||||
4. Fill provider details (account ID and alias)
|
||||
5. Select "role" authentication type
|
||||
6. Switch authentication method to "Use AWS SDK default credentials"
|
||||
7. Fill role ARN using AWS SDK credential inputs
|
||||
8. Launch initial scan
|
||||
9. Verify redirect to Scans page
|
||||
10. Verify scheduled scan status in Scans table (provider exists and scan name is "scheduled scan")
|
||||
|
||||
### Expected Result:
|
||||
|
||||
- AWS provider successfully added using AWS SDK default credentials to assume the role
|
||||
- Initial scan launched successfully
|
||||
- User redirected to Scans page
|
||||
- Scheduled scan appears in Scans table with correct provider and scan name
|
||||
|
||||
### Key verification points:
|
||||
|
||||
- Provider page loads correctly
|
||||
- Connect account page displays AWS option
|
||||
- Credentials form exposes AWS SDK default authentication method
|
||||
- Role ARN field accepts provided value when SDK method is selected
|
||||
- Launch scan page appears
|
||||
- Successful redirect to Scans page after scan launch
|
||||
- Provider exists in Scans table (verified by account ID)
|
||||
- Scan name field contains "scheduled scan"
|
||||
|
||||
### Notes:
|
||||
|
||||
- Test leverages AWS SDK default credential chain (environment-configured keys) for Access Key and Secret Key
|
||||
- Environment variable `E2E_AWS_PROVIDER_ROLE_ARN` must reference a valid assumable role
|
||||
- Provider cleanup performed before each test to ensure clean state
|
||||
- Requires valid AWS account with permissions to assume the target role
|
||||
|
||||
---
|
||||
|
||||
## Test Case: `PROVIDER-E2E-003` - Add Azure Provider with Static Credentials
|
||||
|
||||
**Priority:** `critical`
|
||||
|
||||
@@ -193,7 +193,89 @@ test.describe("Add Provider", () => {
|
||||
await scansPage.verifyScheduledScanStatus(accountId);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
"should add a new AWS provider with assume role credentials using AWS SDK",
|
||||
{
|
||||
tag: [
|
||||
"@critical",
|
||||
"@e2e",
|
||||
"@providers",
|
||||
"@aws",
|
||||
"@serial",
|
||||
"@PROVIDER-E2E-011",
|
||||
],
|
||||
},
|
||||
async ({ page }) => {
|
||||
// Validate required environment variables from environment variables
|
||||
const awsAccessKeyId = process.env.AWS_ACCESS_KEY_ID;
|
||||
const awsSecretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
|
||||
|
||||
// Validate required environment variables
|
||||
if (!accountId || !awsAccessKeyId || !awsSecretAccessKey || !roleArn) {
|
||||
throw new Error(
|
||||
"E2E_AWS_PROVIDER_ACCOUNT_ID, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and E2E_AWS_PROVIDER_ROLE_ARN environment variables are not set",
|
||||
);
|
||||
}
|
||||
|
||||
// Prepare test data for AWS provider
|
||||
const awsProviderData: AWSProviderData = {
|
||||
accountId: accountId,
|
||||
alias: "Test E2E AWS Account - Credentials",
|
||||
};
|
||||
|
||||
// Prepare role-based credentials
|
||||
const roleCredentials: AWSProviderCredential = {
|
||||
type: AWS_CREDENTIAL_OPTIONS.AWS_ROLE_ARN,
|
||||
sdkAccessKeyId: accessKey,
|
||||
sdkSecretAccessKey: secretKey,
|
||||
roleArn: roleArn,
|
||||
};
|
||||
|
||||
// Navigate to providers page
|
||||
await providersPage.goto();
|
||||
await providersPage.verifyPageLoaded();
|
||||
|
||||
// Start adding new provider
|
||||
await providersPage.clickAddProvider();
|
||||
await providersPage.verifyConnectAccountPageLoaded();
|
||||
|
||||
// Select AWS provider
|
||||
await providersPage.selectAWSProvider();
|
||||
|
||||
// Fill provider details
|
||||
await providersPage.fillAWSProviderDetails(awsProviderData);
|
||||
await providersPage.clickNext();
|
||||
|
||||
// Select role credentials type
|
||||
await providersPage.selectCredentialsType(
|
||||
AWS_CREDENTIAL_OPTIONS.AWS_ROLE_ARN,
|
||||
);
|
||||
await providersPage.verifyCredentialsPageLoaded();
|
||||
|
||||
// Select Authentication Method
|
||||
await providersPage.selectAuthenticationMethod(
|
||||
AWS_CREDENTIAL_OPTIONS.AWS_SDK_DEFAULT,
|
||||
);
|
||||
|
||||
// Fill role credentials
|
||||
await providersPage.fillRoleCredentials(roleCredentials);
|
||||
await providersPage.clickNext();
|
||||
|
||||
// Launch scan
|
||||
await providersPage.verifyLaunchScanPageLoaded();
|
||||
await providersPage.clickNext();
|
||||
|
||||
// Wait for redirect to provider page
|
||||
scansPage = new ScansPage(page);
|
||||
await scansPage.verifyPageLoaded();
|
||||
|
||||
// Verify scan status is "Scheduled scan"
|
||||
await scansPage.verifyScheduledScanStatus(accountId);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
test.describe.serial("Add AZURE Provider", () => {
|
||||
// Providers page object
|
||||
|
||||
Reference in New Issue
Block a user