mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-05 12:26:34 +02:00
* VAULT-42427 - initial code updates for aws form * VAULT-42756 - implemented wif support for secret sync * VAULT-42756 - added acceptance and integration test cases for WIF support * refactor: streamline WIF credential handling and enhance destination details management * added changelog * fixed review comments * updated changelog * fixed failing tests * VAULT-42756 - add Playwright tests for sync destination WIF workflows * fixed copilot review comments * fixed review comments * fixed validation for Edit scenario * fixed region field to have no default value selected * Refactor: updated string literals with centralized enums and some other refactors * fixed review comments to remove redundant click actions * refactor sync destination form handling to separate function in tests * add mock responses for sync destinations in tests * added copyright header to mock file Co-authored-by: mohit-hashicorp <mohit.ojha@hashicorp.com>
101 lines
3.6 KiB
TypeScript
101 lines
3.6 KiB
TypeScript
/**
|
|
* Copyright IBM Corp. 2016, 2025
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { Page } from '@playwright/test';
|
|
import { findEngineDisplayName } from './configuration-settings';
|
|
|
|
export class BasePage {
|
|
constructor(protected page: Page) {}
|
|
// remove all flash messages by clicking the dismiss button until there are no more
|
|
// this is useful if many are rendered over top of a button preventing click in a test
|
|
async dismissFlashMessages() {
|
|
const locator = this.page.getByRole('button', { name: 'Dismiss' });
|
|
// use a while loop because clicking one might cause the next one to shift or re-render.
|
|
while ((await locator.count()) > 0) {
|
|
await locator.first().click();
|
|
}
|
|
}
|
|
|
|
async goToSecrets() {
|
|
await this.page.getByRole('link', { name: 'Secrets', exact: true }).click();
|
|
const skipButton = this.page.getByRole('button', { name: 'Skip' });
|
|
if (await skipButton.isVisible()) {
|
|
await skipButton.click();
|
|
}
|
|
}
|
|
|
|
async disableEngine(path: string) {
|
|
await this.page.goto('secrets-engines');
|
|
await this.page
|
|
.getByRole('row', { name: `Type of backend ${path}` })
|
|
.getByLabel('supported secrets engine menu')
|
|
.click();
|
|
await this.page.getByRole('button', { name: 'Delete' }).click();
|
|
await this.page.getByRole('button', { name: 'Confirm' }).click();
|
|
}
|
|
|
|
/**
|
|
* Enable a secrets engine with a dynamic path
|
|
* @param engineType - The type of engine to enable (e.g., 'KV', 'Transit', 'PKI Certificates')
|
|
* @param path - The mount path for the engine
|
|
* @param options - Optional configuration for the engine with variable key-value pairs
|
|
*/
|
|
async enableEngine(
|
|
engineType: string,
|
|
path: string,
|
|
options?: {
|
|
defaultLeaseTtl?: { unit: number; option: string };
|
|
maxLeaseTtl?: { unit: number; option: string };
|
|
external?: boolean;
|
|
pluginVersion?: string;
|
|
skipEnable?: boolean;
|
|
}
|
|
) {
|
|
await this.page.goto('dashboard');
|
|
await this.goToSecrets();
|
|
|
|
// Click "Enable new engine"
|
|
await this.page.getByRole('link', { name: 'Enable new engine' }).click();
|
|
await this.page.getByRole('heading', { name: findEngineDisplayName(engineType) }).click();
|
|
|
|
if (options?.external) {
|
|
// Prerequisite: mock plugin catalog endpoint in the test so the External plugin option is available.
|
|
await this.page.locator('label:nth-child(2) > .hds-form-radio-card__control-wrapper').click();
|
|
if (options.pluginVersion) {
|
|
await this.page.getByLabel('Plugin version Required').selectOption(options.pluginVersion);
|
|
}
|
|
}
|
|
|
|
if (options?.defaultLeaseTtl) {
|
|
await this.page.locator('label').filter({ hasText: 'Default Lease TTL Vault will' }).click();
|
|
await this.page
|
|
.getByLabel('TTL unit for Default Lease TTL')
|
|
.selectOption(options.defaultLeaseTtl.option as string);
|
|
await this.page
|
|
.getByRole('group', { name: 'Default Lease TTL Lease will' })
|
|
.getByLabel('Number of units')
|
|
.fill(options.defaultLeaseTtl.unit.toString());
|
|
}
|
|
|
|
if (options?.maxLeaseTtl) {
|
|
await this.page
|
|
.getByLabel('TTL unit for Max Lease TTL')
|
|
.selectOption(options.maxLeaseTtl.option as string);
|
|
await this.page
|
|
.getByRole('group', { name: 'Max Lease TTL Lease will' })
|
|
.getByLabel('Number of units')
|
|
.fill(options.maxLeaseTtl.unit.toString());
|
|
}
|
|
|
|
// Fill in the path
|
|
await this.page.getByRole('textbox', { name: 'Path' }).fill(path);
|
|
|
|
// Enable the engine
|
|
if (!options?.skipEnable) {
|
|
await this.page.getByRole('button', { name: 'Enable engine' }).click();
|
|
}
|
|
}
|
|
}
|