diff --git a/e2e-tests/admin/pages/targets.js b/e2e-tests/admin/pages/targets.js index ac70416af..ba77a7a29 100644 --- a/e2e-tests/admin/pages/targets.js +++ b/e2e-tests/admin/pages/targets.js @@ -236,6 +236,112 @@ export class TargetsPage extends BaseResourcePage { return targetName; } + /** + * Creates a new RDP target. + * Assumes you have selected the desired project. + * @param {string} port Port of the target + * @returns Name of the target + */ + async createRdpTargetEnt(port) { + const targetName = 'Target ' + nanoid(); + await this.page + .getByRole('navigation', { name: 'Application local navigation' }) + .getByRole('link', { name: 'Targets' }) + .click(); + await this.page.getByRole('link', { name: 'New', exact: true }).click(); + await this.page.getByLabel('Name').fill(targetName); + await this.page.getByLabel('Description').fill('This is an automated test'); + await this.page + .getByRole('group', { name: 'Type' }) + .getByLabel('RDP') + .click(); + await this.page.getByLabel('Default Port').fill(port); + await this.page.getByRole('button', { name: 'Save' }).click(); + await this.dismissSuccessAlert(); + await expect( + this.page + .getByRole('navigation', { name: 'breadcrumbs' }) + .getByText(targetName), + ).toBeVisible(); + + return targetName; + } + + /** + * Creates a new RDP target with address in boundary-enterprise + * Assumes you have selected the desired project. + * @param {string} address Address of the target + * @param {string} port Port of the target + * @returns Name of the target + */ + async createRDPTargetWithAddressEnt(address, port) { + const targetName = 'Target ' + nanoid(); + await this.page + .getByRole('navigation', { name: 'Application local navigation' }) + .getByRole('link', { name: 'Targets' }) + .click(); + await this.page.getByRole('link', { name: 'New', exact: true }).click(); + await this.page.getByLabel('Name').fill(targetName); + await this.page.getByLabel('Description').fill('This is an automated test'); + await this.page + .getByRole('group', { name: 'Type' }) + .getByLabel('RDP') + .click(); + await this.page.getByLabel('Target Address').fill(address); + await this.page.getByLabel('Default Port').fill(port); + await this.page.getByRole('button', { name: 'Save' }).click(); + await this.dismissSuccessAlert(); + await expect( + this.page + .getByRole('navigation', { name: 'breadcrumbs' }) + .getByText(targetName), + ).toBeVisible(); + + return targetName; + } + + /** + * Creates a new RDP target with address and alias. + * Assumes you have selected the desired project. + * @param {string} address Address of the target + * @param {string} port Port of the target + * @param {string} alias alias used for the target + * @returns Name of the target + */ + + async createRdpTargetWithAddressAndAlias(address, port, alias) { + const targetName = 'Target ' + nanoid(); + await this.page + .getByRole('navigation', { name: 'Application local navigation' }) + .getByRole('link', { name: 'Targets' }) + .click(); + await this.page.getByRole('link', { name: 'New', exact: true }).click(); + await this.page.getByLabel('Name').fill(targetName); + await this.page.getByLabel('Description').fill('This is an automated test'); + await this.page + .getByRole('group', { name: 'Type' }) + .getByLabel('RDP') + .click(); + await this.page.getByLabel('Target Address').fill(address); + await this.page.getByLabel('Default Port').fill(port); + await this.page + .getByRole('group', { name: 'Aliases' }) + .getByLabel('value') + .last() + .fill(alias); + await this.page.getByRole('button', { name: 'Add' }).click(); + + await this.page.getByRole('button', { name: 'Save' }).click(); + await this.dismissSuccessAlert(); + await expect( + this.page + .getByRole('navigation', { name: 'breadcrumbs' }) + .getByText(targetName), + ).toBeVisible(); + + return targetName; + } + /** * Adds a host source to a target. Assume you have selected the desired target. * @param {string} hostSourceName Name of host source that will be attached to the target diff --git a/e2e-tests/admin/tests/target-ent.spec.js b/e2e-tests/admin/tests/target-ent.spec.js index 93a072241..faf8fc21c 100644 --- a/e2e-tests/admin/tests/target-ent.spec.js +++ b/e2e-tests/admin/tests/target-ent.spec.js @@ -259,3 +259,87 @@ test( } }, ); + +test( + 'Verify RDP target creation', + { tag: ['@ent', '@aws', '@docker'] }, + async ({ + page, + controllerAddr, + adminAuthMethodId, + adminLoginName, + adminPassword, + sshUser, + targetAddress, + targetPort, + }) => { + await page.goto('/'); + let orgId; + try { + const orgsPage = new OrgsPage(page); + const orgName = await orgsPage.createOrg(); + const projectsPage = new ProjectsPage(page); + await projectsPage.createProject(); + + // Create host set + const hostCatalogsPage = new HostCatalogsPage(page); + const hostCatalogName = await hostCatalogsPage.createHostCatalog(); + const hostSetName = await hostCatalogsPage.createHostSet(); + await hostCatalogsPage.createHostInHostSet(targetAddress); + + // Create another host set + await page.getByRole('link', { name: hostCatalogName }).click(); + const hostSetName2 = await hostCatalogsPage.createHostSet(); + + // Create target + const targetsPage = new TargetsPage(page); + const targetName = await targetsPage.createRdpTargetEnt(targetPort); + await targetsPage.addHostSourceToTarget(hostSetName); + + // Add/Remove another host source + await targetsPage.addHostSourceToTarget(hostSetName2); + await page + .getByRole('link', { name: hostSetName2 }) + .locator('..') + .locator('..') + .getByRole('button', { name: 'Manage' }) + .click(); + await page.getByRole('button', { name: 'Remove' }).click(); + await page.getByRole('button', { name: 'OK', exact: true }).click(); + await expect( + page.getByRole('alert').getByText('Success', { exact: true }), + ).toBeVisible(); + await page.getByRole('button', { name: 'Dismiss' }).click(); + + // Create credentials and attach to target + const credentialStoresPage = new CredentialStoresPage(page); + await credentialStoresPage.createStaticCredentialStore(); + const credentialName = + await credentialStoresPage.createStaticCredentialUsernamePassword( + sshUser, + 'testPassword', + ); + await targetsPage.addInjectedCredentialsToTarget( + targetName, + credentialName, + ); + + // Verify that an RDP target is created + await boundaryCli.authenticateBoundary( + controllerAddr, + adminAuthMethodId, + adminLoginName, + adminPassword, + ); + orgId = await boundaryCli.getOrgIdFromName(orgName); + + // TODO: Connection will be tested later when we have the Proxy in place. + // For now, we just check if we can see the target in the UI + await expect(page.getByRole('link', { name: targetName })).toBeVisible(); + } finally { + if (orgId) { + await boundaryCli.deleteScope(orgId); + } + } + }, +);