2024-06-28 10:24:50 -04:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
*/
|
|
|
|
|
|
2025-01-06 11:40:32 -05:00
|
|
|
import { test } from '../../global-setup.js';
|
2024-08-28 11:54:58 -04:00
|
|
|
import { expect } from '@playwright/test';
|
2024-06-28 10:24:50 -04:00
|
|
|
import { customAlphabet } from 'nanoid';
|
2024-08-06 13:15:00 -04:00
|
|
|
|
2024-12-17 10:17:32 -05:00
|
|
|
import * as boundaryCli from '../../helpers/boundary-cli';
|
2024-11-12 11:21:37 -05:00
|
|
|
import { AliasesPage } from '../pages/aliases.js';
|
|
|
|
|
import { CredentialStoresPage } from '../pages/credential-stores.js';
|
|
|
|
|
import { OrgsPage } from '../pages/orgs.js';
|
|
|
|
|
import { ProjectsPage } from '../pages/projects.js';
|
2025-01-06 11:40:32 -05:00
|
|
|
import { SessionsPage } from '../pages/sessions.js';
|
2024-11-12 11:21:37 -05:00
|
|
|
import { TargetsPage } from '../pages/targets.js';
|
2024-06-28 10:24:50 -04:00
|
|
|
|
|
|
|
|
test.beforeAll(async () => {
|
2024-12-17 10:17:32 -05:00
|
|
|
await boundaryCli.checkBoundaryCli();
|
2024-06-28 10:24:50 -04:00
|
|
|
});
|
|
|
|
|
|
2025-02-12 12:39:16 -05:00
|
|
|
test.describe('Aliases (Enterprise)', () => {
|
2025-02-12 17:24:51 -05:00
|
|
|
test(
|
|
|
|
|
'Set up alias from target details page',
|
|
|
|
|
{ tag: ['@ent', '@aws', '@docker'] },
|
|
|
|
|
async ({
|
|
|
|
|
page,
|
2025-03-05 11:38:12 -05:00
|
|
|
controllerAddr,
|
2025-02-12 17:24:51 -05:00
|
|
|
adminAuthMethodId,
|
|
|
|
|
adminLoginName,
|
|
|
|
|
adminPassword,
|
|
|
|
|
sshUser,
|
|
|
|
|
sshKeyPath,
|
|
|
|
|
targetAddress,
|
|
|
|
|
targetPort,
|
|
|
|
|
}) => {
|
|
|
|
|
await page.goto('/');
|
|
|
|
|
let orgName;
|
|
|
|
|
let alias;
|
|
|
|
|
let connect;
|
|
|
|
|
const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz', 10);
|
|
|
|
|
try {
|
|
|
|
|
const orgsPage = new OrgsPage(page);
|
|
|
|
|
orgName = await orgsPage.createOrg();
|
|
|
|
|
const projectsPage = new ProjectsPage(page);
|
|
|
|
|
await projectsPage.createProject();
|
2024-08-06 13:15:00 -04:00
|
|
|
|
2025-02-12 17:24:51 -05:00
|
|
|
const targetsPage = new TargetsPage(page);
|
|
|
|
|
const targetName = await targetsPage.createSshTargetWithAddressEnt(
|
|
|
|
|
targetAddress,
|
|
|
|
|
targetPort,
|
|
|
|
|
);
|
|
|
|
|
const credentialStoresPage = new CredentialStoresPage(page);
|
|
|
|
|
await credentialStoresPage.createStaticCredentialStore();
|
|
|
|
|
const credentialName =
|
|
|
|
|
await credentialStoresPage.createStaticCredentialKeyPair(
|
|
|
|
|
sshUser,
|
|
|
|
|
sshKeyPath,
|
|
|
|
|
);
|
|
|
|
|
await targetsPage.addInjectedCredentialsToTarget(
|
|
|
|
|
targetName,
|
|
|
|
|
credentialName,
|
2024-11-12 18:11:00 -05:00
|
|
|
);
|
2024-06-28 10:24:50 -04:00
|
|
|
|
2025-02-12 17:24:51 -05:00
|
|
|
// Create alias for target
|
|
|
|
|
await page
|
|
|
|
|
.getByRole('navigation', { name: 'breadcrumbs' })
|
|
|
|
|
.getByText(targetName)
|
|
|
|
|
.click();
|
|
|
|
|
const aliasName = 'Alias ' + nanoid();
|
|
|
|
|
alias = 'example.alias.' + nanoid();
|
|
|
|
|
await page.getByRole('link', { name: 'Add an alias' }).click();
|
|
|
|
|
await page.getByLabel('Name').fill(aliasName);
|
|
|
|
|
await page.getByLabel('Description').fill('This is an automated test');
|
|
|
|
|
await page.getByLabel('Alias Value').fill(alias);
|
|
|
|
|
await page.getByRole('button', { name: 'Save' }).click();
|
|
|
|
|
await expect(
|
|
|
|
|
page.getByRole('alert').getByText('Success', { exact: true }),
|
|
|
|
|
).toBeVisible();
|
|
|
|
|
await page.getByRole('button', { name: 'Dismiss' }).click();
|
2024-06-28 10:24:50 -04:00
|
|
|
|
2025-02-12 17:24:51 -05:00
|
|
|
// Connect to target using alias
|
|
|
|
|
await boundaryCli.authenticateBoundary(
|
2025-03-05 11:38:12 -05:00
|
|
|
controllerAddr,
|
2025-02-12 17:24:51 -05:00
|
|
|
adminAuthMethodId,
|
|
|
|
|
adminLoginName,
|
|
|
|
|
adminPassword,
|
|
|
|
|
);
|
|
|
|
|
connect = await boundaryCli.connectSshToAlias(alias);
|
|
|
|
|
const sessionsPage = new SessionsPage(page);
|
|
|
|
|
await sessionsPage.waitForSessionToBeVisible(targetName);
|
2024-06-28 10:24:50 -04:00
|
|
|
|
2025-02-12 17:24:51 -05:00
|
|
|
// Clear destination from alias
|
|
|
|
|
await page
|
2025-04-14 14:27:02 -07:00
|
|
|
.getByRole('navigation', { name: 'Application local navigation' })
|
2025-02-12 17:24:51 -05:00
|
|
|
.getByRole('link', { name: 'Targets' })
|
|
|
|
|
.click();
|
|
|
|
|
await page.getByRole('link', { name: targetName }).click();
|
|
|
|
|
await page.getByRole('link', { name: alias }).click();
|
|
|
|
|
// Note: On the Target details page, there is a section with the header
|
|
|
|
|
// "Aliases". The extra check here is to ensure that we are on the Alias
|
|
|
|
|
// details page and not the Target details page.
|
|
|
|
|
await expect(
|
|
|
|
|
page.getByRole('heading', { name: 'Alias' }),
|
|
|
|
|
).not.toHaveText('Aliases');
|
|
|
|
|
await page.getByRole('button', { name: 'Manage' }).click();
|
|
|
|
|
await page.getByText('Clear', { exact: true }).click();
|
|
|
|
|
await page.getByText('OK', { exact: true }).click();
|
|
|
|
|
await expect(
|
|
|
|
|
page.getByRole('alert').getByText('Success', { exact: true }),
|
|
|
|
|
).toBeVisible();
|
|
|
|
|
await page.getByRole('button', { name: 'Dismiss' }).click();
|
|
|
|
|
} finally {
|
|
|
|
|
if (connect) {
|
|
|
|
|
connect.kill('SIGTERM');
|
2024-06-28 10:24:50 -04:00
|
|
|
}
|
2025-02-12 17:24:51 -05:00
|
|
|
await boundaryCli.authenticateBoundary(
|
2025-03-05 11:38:12 -05:00
|
|
|
controllerAddr,
|
2025-02-12 17:24:51 -05:00
|
|
|
adminAuthMethodId,
|
|
|
|
|
adminLoginName,
|
|
|
|
|
adminPassword,
|
2024-11-12 18:11:00 -05:00
|
|
|
);
|
2025-02-12 17:24:51 -05:00
|
|
|
if (orgName) {
|
|
|
|
|
const orgId = await boundaryCli.getOrgIdFromName(orgName);
|
|
|
|
|
if (orgId) {
|
|
|
|
|
await boundaryCli.deleteScope(orgId);
|
|
|
|
|
}
|
2024-06-28 10:24:50 -04:00
|
|
|
}
|
|
|
|
|
if (alias) {
|
2024-12-17 10:17:32 -05:00
|
|
|
await boundaryCli.deleteAlias(alias);
|
2024-06-28 10:24:50 -04:00
|
|
|
}
|
|
|
|
|
}
|
2025-02-12 17:24:51 -05:00
|
|
|
},
|
|
|
|
|
);
|
2024-06-28 10:24:50 -04:00
|
|
|
|
2025-02-12 17:24:51 -05:00
|
|
|
test(
|
|
|
|
|
'Set up alias from new target page',
|
|
|
|
|
{ tag: ['@ent', '@aws', '@docker'] },
|
|
|
|
|
async ({
|
|
|
|
|
page,
|
2025-03-05 11:38:12 -05:00
|
|
|
controllerAddr,
|
2025-02-12 17:24:51 -05:00
|
|
|
adminAuthMethodId,
|
|
|
|
|
adminLoginName,
|
|
|
|
|
adminPassword,
|
|
|
|
|
sshUser,
|
|
|
|
|
sshKeyPath,
|
|
|
|
|
targetAddress,
|
|
|
|
|
targetPort,
|
|
|
|
|
}) => {
|
|
|
|
|
await page.goto('/');
|
|
|
|
|
let orgName;
|
|
|
|
|
let alias;
|
|
|
|
|
let connect;
|
|
|
|
|
const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz', 10);
|
|
|
|
|
try {
|
|
|
|
|
const orgsPage = new OrgsPage(page);
|
|
|
|
|
orgName = await orgsPage.createOrg();
|
|
|
|
|
await boundaryCli.authenticateBoundary(
|
2025-03-05 11:38:12 -05:00
|
|
|
controllerAddr,
|
2025-02-12 17:24:51 -05:00
|
|
|
adminAuthMethodId,
|
|
|
|
|
adminLoginName,
|
|
|
|
|
adminPassword,
|
|
|
|
|
);
|
|
|
|
|
const projectsPage = new ProjectsPage(page);
|
|
|
|
|
await projectsPage.createProject();
|
|
|
|
|
alias = 'example.alias.' + nanoid();
|
|
|
|
|
const targetsPage = new TargetsPage(page);
|
|
|
|
|
const targetName = await targetsPage.createTargetWithAddressAndAlias(
|
|
|
|
|
targetAddress,
|
|
|
|
|
targetPort,
|
|
|
|
|
alias,
|
2025-09-10 07:14:55 -07:00
|
|
|
'ssh',
|
2025-02-12 17:24:51 -05:00
|
|
|
);
|
|
|
|
|
const credentialStoresPage = new CredentialStoresPage(page);
|
|
|
|
|
await credentialStoresPage.createStaticCredentialStore();
|
|
|
|
|
const credentialName =
|
|
|
|
|
await credentialStoresPage.createStaticCredentialKeyPair(
|
|
|
|
|
sshUser,
|
|
|
|
|
sshKeyPath,
|
|
|
|
|
);
|
|
|
|
|
await targetsPage.addInjectedCredentialsToTarget(
|
|
|
|
|
targetName,
|
|
|
|
|
credentialName,
|
2024-11-12 18:11:00 -05:00
|
|
|
);
|
2024-06-28 10:24:50 -04:00
|
|
|
|
2025-02-12 17:24:51 -05:00
|
|
|
// Connect to target using alias
|
|
|
|
|
connect = await boundaryCli.connectSshToAlias(alias);
|
|
|
|
|
const sessionsPage = new SessionsPage(page);
|
|
|
|
|
await sessionsPage.waitForSessionToBeVisible(targetName);
|
|
|
|
|
} finally {
|
|
|
|
|
if (connect) {
|
|
|
|
|
connect.kill('SIGTERM');
|
|
|
|
|
}
|
|
|
|
|
await boundaryCli.authenticateBoundary(
|
2025-03-05 11:38:12 -05:00
|
|
|
controllerAddr,
|
2025-02-12 17:24:51 -05:00
|
|
|
adminAuthMethodId,
|
|
|
|
|
adminLoginName,
|
|
|
|
|
adminPassword,
|
|
|
|
|
);
|
2024-06-28 10:24:50 -04:00
|
|
|
|
2025-02-12 17:24:51 -05:00
|
|
|
if (orgName) {
|
|
|
|
|
const orgId = await boundaryCli.getOrgIdFromName(orgName);
|
|
|
|
|
if (orgId) {
|
|
|
|
|
await boundaryCli.deleteScope(orgId);
|
|
|
|
|
}
|
|
|
|
|
if (alias) {
|
|
|
|
|
await boundaryCli.deleteAlias(alias);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-01-06 11:40:32 -05:00
|
|
|
}
|
2025-02-12 17:24:51 -05:00
|
|
|
},
|
|
|
|
|
);
|
2024-06-28 10:24:50 -04:00
|
|
|
|
2025-02-12 17:24:51 -05:00
|
|
|
test(
|
|
|
|
|
'Set up alias from aliases page',
|
|
|
|
|
{ tag: ['@ent', '@aws', '@docker'] },
|
|
|
|
|
async ({
|
|
|
|
|
page,
|
2025-03-05 11:38:12 -05:00
|
|
|
controllerAddr,
|
2025-02-12 17:24:51 -05:00
|
|
|
adminAuthMethodId,
|
|
|
|
|
adminLoginName,
|
|
|
|
|
adminPassword,
|
|
|
|
|
sshUser,
|
|
|
|
|
sshKeyPath,
|
|
|
|
|
targetAddress,
|
|
|
|
|
targetPort,
|
|
|
|
|
}) => {
|
|
|
|
|
await page.goto('/');
|
|
|
|
|
const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz', 10);
|
|
|
|
|
let orgId;
|
|
|
|
|
let alias;
|
|
|
|
|
let connect;
|
|
|
|
|
try {
|
|
|
|
|
const orgsPage = new OrgsPage(page);
|
|
|
|
|
const orgName = await orgsPage.createOrg();
|
|
|
|
|
const projectsPage = new ProjectsPage(page);
|
|
|
|
|
const projectName = await projectsPage.createProject();
|
|
|
|
|
const targetsPage = new TargetsPage(page);
|
|
|
|
|
const targetName = await targetsPage.createSshTargetWithAddressEnt(
|
|
|
|
|
targetAddress,
|
|
|
|
|
targetPort,
|
|
|
|
|
);
|
|
|
|
|
const credentialStoresPage = new CredentialStoresPage(page);
|
|
|
|
|
await credentialStoresPage.createStaticCredentialStore();
|
|
|
|
|
const credentialName =
|
|
|
|
|
await credentialStoresPage.createStaticCredentialKeyPair(
|
|
|
|
|
sshUser,
|
|
|
|
|
sshKeyPath,
|
|
|
|
|
);
|
|
|
|
|
await targetsPage.addInjectedCredentialsToTarget(
|
|
|
|
|
targetName,
|
|
|
|
|
credentialName,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Create new alias from scope page
|
|
|
|
|
await boundaryCli.authenticateBoundary(
|
2025-03-05 11:38:12 -05:00
|
|
|
controllerAddr,
|
2025-02-12 17:24:51 -05:00
|
|
|
adminAuthMethodId,
|
|
|
|
|
adminLoginName,
|
|
|
|
|
adminPassword,
|
|
|
|
|
);
|
|
|
|
|
orgId = await boundaryCli.getOrgIdFromName(orgName);
|
|
|
|
|
const projectId = await boundaryCli.getProjectIdFromName(
|
|
|
|
|
orgId,
|
|
|
|
|
projectName,
|
|
|
|
|
);
|
|
|
|
|
const targetId = await boundaryCli.getTargetIdFromName(
|
|
|
|
|
projectId,
|
|
|
|
|
targetName,
|
|
|
|
|
);
|
|
|
|
|
|
2025-09-03 11:28:33 -04:00
|
|
|
await page
|
|
|
|
|
.getByRole('link', { name: `Back to ${orgName}`, exact: true })
|
|
|
|
|
.click();
|
|
|
|
|
await page.getByRole('link', { name: 'Back to Global' }).click();
|
|
|
|
|
await page.getByRole('link', { name: 'Aliases' }).click();
|
|
|
|
|
await expect(
|
|
|
|
|
page
|
|
|
|
|
.getByRole('navigation', { name: 'breadcrumbs' })
|
|
|
|
|
.getByText('Aliases'),
|
|
|
|
|
).toBeVisible();
|
2025-02-12 17:24:51 -05:00
|
|
|
alias = 'example.alias.' + nanoid();
|
|
|
|
|
const aliasesPage = new AliasesPage(page);
|
2025-09-03 11:28:33 -04:00
|
|
|
await aliasesPage.createAliasForTarget(alias, targetId);
|
2025-02-12 17:24:51 -05:00
|
|
|
await page
|
2025-04-14 14:27:02 -07:00
|
|
|
.getByRole('navigation', { name: 'Application local navigation' })
|
2025-02-12 17:24:51 -05:00
|
|
|
.getByRole('link', { name: 'Orgs' })
|
|
|
|
|
.click();
|
|
|
|
|
await page.getByRole('link', { name: orgName }).click();
|
|
|
|
|
await page.getByRole('link', { name: projectName }).click();
|
2025-09-03 11:28:33 -04:00
|
|
|
|
|
|
|
|
connect = await boundaryCli.connectSshToAlias(alias);
|
2025-02-12 17:24:51 -05:00
|
|
|
const sessionsPage = new SessionsPage(page);
|
|
|
|
|
await sessionsPage.waitForSessionToBeVisible(targetName);
|
|
|
|
|
} finally {
|
|
|
|
|
if (connect) {
|
|
|
|
|
connect.kill('SIGTERM');
|
|
|
|
|
}
|
|
|
|
|
await boundaryCli.authenticateBoundary(
|
2025-03-05 11:38:12 -05:00
|
|
|
controllerAddr,
|
2025-02-12 17:24:51 -05:00
|
|
|
adminAuthMethodId,
|
|
|
|
|
adminLoginName,
|
|
|
|
|
adminPassword,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (orgId) {
|
|
|
|
|
await boundaryCli.deleteScope(orgId);
|
|
|
|
|
}
|
|
|
|
|
if (alias) {
|
|
|
|
|
await boundaryCli.deleteAlias(alias);
|
|
|
|
|
}
|
2024-06-28 10:24:50 -04:00
|
|
|
}
|
2025-02-12 17:24:51 -05:00
|
|
|
},
|
|
|
|
|
);
|
2024-06-28 10:24:50 -04:00
|
|
|
});
|