Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const FACTORY_TEST_CONSTANTS: {
TS_GIT_PERSONAL_ACCESS_TOKEN: string;
TS_SELENIUM_SSH_PRIVATE_KEY: string;
TS_SELENIUM_SSH_PUBLIC_KEY: string;
TS_SELENIUM_SSH_KEY_PASSPHRASE: string;
TS_SELENIUM_FACTORY_URL(): string;
} = {
/**
Expand Down Expand Up @@ -90,15 +91,20 @@ export const FACTORY_TEST_CONSTANTS: {
TS_GIT_PERSONAL_ACCESS_TOKEN: process.env.TS_GIT_PERSONAL_ACCESS_TOKEN || '',

/**
* sSH private key as string (from environment variable)
* ssh private key as string (from environment variable)
*/
TS_SELENIUM_SSH_PRIVATE_KEY: process.env.TS_SELENIUM_SSH_PRIVATE_KEY || '',

/**
* sSH public key as string (from environment variable)
* ssh public key as string (from environment variable)
*/
TS_SELENIUM_SSH_PUBLIC_KEY: process.env.TS_SELENIUM_SSH_PUBLIC_KEY || '',

/**
* ssh key passphrase as string (from environment variable)
*/
TS_SELENIUM_SSH_KEY_PASSPHRASE: process.env.TS_SELENIUM_SSH_KEY_PASSPHRASE || '',

/**
* full factory URL
*/
Expand Down
9 changes: 8 additions & 1 deletion tests/e2e/pageobjects/dashboard/UserPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class UserPreferences {
private static readonly ADD_SSH_KEYS_POPUP: By = By.xpath('//span[text()="Add SSH Keys"]');
private static readonly PASTE_PRIVATE_SSH_KEY_FIELD: By = By.css('textarea[name="ssh-private-key"]');
private static readonly PASTE_PUBLIC_SSH_KEY_FIELD: By = By.css('textarea[name="ssh-public-key"]');
private static readonly PASTE_SSH_KEY_PASSPHRASE_FIELD: By = By.xpath('//input[@placeholder="Enter passphrase (optional)"]');
private static readonly ADD_SSH_KEYS_BUTTON: By = By.css('.pf-c-button.pf-m-primary');
private static readonly GIT_SSH_KEY_NAME: By = By.css('[data-testid="title"]');
private static readonly GIT_SSH_KEY_ACTIONS_BUTTON: By = By.css('section[id*="SshKeys-user-preferences"] button[aria-label="Actions"]');
Expand Down Expand Up @@ -184,7 +185,7 @@ export class UserPreferences {
Logger.info('SSH keys have been added');
}

async addSshKeysFromStrings(privateSshKey: string, publicSshKey: string): Promise<void> {
async addSshKeysFromStrings(privateSshKey: string, publicSshKey: string, passphrase?: string): Promise<void> {
Logger.debug();

if (!privateSshKey || privateSshKey === '') {
Expand All @@ -206,6 +207,12 @@ export class UserPreferences {
await this.driverHelper.waitAndClick(UserPreferences.PASTE_PUBLIC_SSH_KEY_FIELD);
await this.driverHelper.getAction().sendKeys(publicSshKey).perform();

if (passphrase) {
Logger.info('Pasting SSH key passphrase');
await this.driverHelper.waitAndClick(UserPreferences.PASTE_SSH_KEY_PASSPHRASE_FIELD);
await this.driverHelper.getAction().sendKeys(passphrase).perform();
}

await this.driverHelper.waitAndClick(UserPreferences.ADD_SSH_KEYS_BUTTON);
await this.driverHelper.waitVisibility(UserPreferences.GIT_SSH_KEY_NAME);
Logger.info('SSH keys have been added');
Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/specs/factory/SshUrlNoOauthPatFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ suite(`The SshUrlNoOauthPatFactory userstory ${BASE_TEST_CONSTANTS.TEST_ENVIRONM
'ssh://[email protected]/~admin/private-bb-repo.git';
const privateSshKey: string = FACTORY_TEST_CONSTANTS.TS_SELENIUM_SSH_PRIVATE_KEY;
const publicSshKey: string = FACTORY_TEST_CONSTANTS.TS_SELENIUM_SSH_PUBLIC_KEY;
const sshPassphrase: string = FACTORY_TEST_CONSTANTS.TS_SELENIUM_SSH_KEY_PASSPHRASE;
const privateSshKeyPath: string = FACTORY_TEST_CONSTANTS.TS_SELENIUM_SSH_PRIVATE_KEY_PATH;
const publicSshKeyPath: string = FACTORY_TEST_CONSTANTS.TS_SELENIUM_SSH_PUBLIC_KEY_PATH;
let projectSection: ViewSection;
Expand All @@ -62,7 +63,7 @@ suite(`The SshUrlNoOauthPatFactory userstory ${BASE_TEST_CONSTANTS.TEST_ENVIRONM
// use environment variables if available, otherwise fall back to file paths
if (privateSshKey && publicSshKey) {
Logger.info('Using SSH keys from environment variables');
await userPreferences.addSshKeysFromStrings(privateSshKey, publicSshKey);
await userPreferences.addSshKeysFromStrings(privateSshKey, publicSshKey, sshPassphrase);
} else {
Logger.info('Using SSH keys from file paths');
await userPreferences.addSshKeysFromFiles(privateSshKeyPath, publicSshKeyPath);
Expand Down Expand Up @@ -99,7 +100,7 @@ suite(`The SshUrlNoOauthPatFactory userstory ${BASE_TEST_CONSTANTS.TEST_ENVIRONM
await dashboard.openDashboard();
await deleteSshKeys();
});
suiteTeardown('Stop and delete the workspace by APII', async function (): Promise<void> {
suiteTeardown('Stop and delete the workspace by API', async function (): Promise<void> {
await browserTabsUtil.closeAllTabsExceptCurrent();
await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName());
});
Expand Down