test: 💍 refactor e2e
This commit is contained in:
1 parent
33cb7e0a50
commit
b49e55d400
5 files changed
+85
-122
No files matched your search
@@ -46,9 +46,7 @@ test(
|
||||
targetPort,
|
||||
);
|
||||
const credentialStoresPage = new CredentialStoresPage(page);
|
||||
const credentialStoreName =
|
||||
await credentialStoresPage.createStaticCredentialStore();
|
||||
|
||||
await credentialStoresPage.createStaticCredentialStore();
|
||||
const credentialName =
|
||||
await credentialStoresPage.createStaticCredentialKeyPair(
|
||||
sshUser,
|
||||
@@ -60,32 +58,6 @@ test(
|
||||
'testPassword',
|
||||
);
|
||||
|
||||
const credentialName3 =
|
||||
await credentialStoresPage.createStaticCredentialUsernamePasswordDomain(
|
||||
sshUser,
|
||||
'testPassword',
|
||||
'testDomain',
|
||||
);
|
||||
|
||||
// TODO: we can test the target association after RDP target is implemented, for now we test if the credential is visible in the UI
|
||||
await page
|
||||
.getByRole('navigation', { name: 'Application local navigation' })
|
||||
.getByRole('link', { name: 'Credential Stores' })
|
||||
.click();
|
||||
await expect(
|
||||
page.getByRole('link', { name: credentialStoreName }),
|
||||
).toBeVisible();
|
||||
|
||||
// Navigate to the Credential Store
|
||||
await page.getByRole('link', { name: credentialStoreName }).click();
|
||||
|
||||
// click on the Credentials tab
|
||||
await page.getByRole('link', { name: 'Credentials' }).click();
|
||||
|
||||
await expect(
|
||||
page.getByRole('link').getByText(credentialName3),
|
||||
).toBeVisible();
|
||||
|
||||
await targetsPage.addBrokeredCredentialsToTarget(
|
||||
targetName,
|
||||
credentialName,
|
||||
|
||||
@@ -22,7 +22,6 @@ test.beforeAll(async () => {
|
||||
let orgName;
|
||||
let projectName;
|
||||
let targetName;
|
||||
let credentialStoreName;
|
||||
|
||||
test.beforeEach(async ({ page, targetAddress, targetPort }) => {
|
||||
await page.goto('/');
|
||||
@@ -37,8 +36,7 @@ test.beforeEach(async ({ page, targetAddress, targetPort }) => {
|
||||
targetPort,
|
||||
);
|
||||
const credentialStoresPage = new CredentialStoresPage(page);
|
||||
credentialStoreName =
|
||||
await credentialStoresPage.createStaticCredentialStore();
|
||||
await credentialStoresPage.createStaticCredentialStore();
|
||||
});
|
||||
|
||||
test(
|
||||
@@ -282,7 +280,6 @@ test(
|
||||
}) => {
|
||||
try {
|
||||
const credentialStoresPage = new CredentialStoresPage(page);
|
||||
|
||||
const credentialName =
|
||||
await credentialStoresPage.createStaticCredentialKeyPair(
|
||||
sshUser,
|
||||
@@ -294,33 +291,6 @@ test(
|
||||
'testPassword',
|
||||
);
|
||||
|
||||
const credentialName3 =
|
||||
await credentialStoresPage.createStaticCredentialUsernamePasswordDomain(
|
||||
sshUser,
|
||||
'testPassword',
|
||||
'testDomain',
|
||||
);
|
||||
|
||||
// TODO: Handle target association later when we work on RDP targets and modify the existing target association
|
||||
// for now we simply test if the credential is visible in the UI
|
||||
await page
|
||||
.getByRole('navigation', { name: 'Application local navigation' })
|
||||
.getByRole('link', { name: 'Credential Stores' })
|
||||
.click();
|
||||
await expect(
|
||||
page.getByRole('link', { name: credentialStoreName }),
|
||||
).toBeVisible();
|
||||
|
||||
// Navigate to the Credential Store
|
||||
await page.getByRole('link', { name: credentialStoreName }).click();
|
||||
|
||||
// click on the Credentials tab
|
||||
await page.getByRole('link', { name: 'Credentials' }).click();
|
||||
|
||||
await expect(
|
||||
page.getByRole('link').getByText(credentialName3),
|
||||
).toBeVisible();
|
||||
|
||||
const targetsPage = new TargetsPage(page);
|
||||
await targetsPage.addBrokeredCredentialsToTarget(
|
||||
targetName,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { test } from '../../global-setup.js';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import * as boundaryHttp from '../../helpers/boundary-http.js';
|
||||
import * as boundaryCli from '../../helpers/boundary-cli';
|
||||
import { CredentialStoresPage } from '../pages/credential-stores.js';
|
||||
import { HostCatalogsPage } from '../pages/host-catalogs.js';
|
||||
@@ -263,82 +263,45 @@ test(
|
||||
test(
|
||||
'Verify RDP target creation',
|
||||
{ tag: ['@ent', '@aws', '@docker'] },
|
||||
async ({
|
||||
page,
|
||||
controllerAddr,
|
||||
adminAuthMethodId,
|
||||
adminLoginName,
|
||||
adminPassword,
|
||||
sshUser,
|
||||
targetAddress,
|
||||
targetPort,
|
||||
}) => {
|
||||
async ({ request, page, sshUser, targetAddress, targetPort }) => {
|
||||
await page.goto('/');
|
||||
let orgId;
|
||||
let org;
|
||||
try {
|
||||
const orgsPage = new OrgsPage(page);
|
||||
const orgName = await orgsPage.createOrg();
|
||||
const projectsPage = new ProjectsPage(page);
|
||||
await projectsPage.createProject();
|
||||
org = await boundaryHttp.createOrg(request);
|
||||
const project = await boundaryHttp.createProject(request, org.id);
|
||||
|
||||
// Create host set
|
||||
const hostCatalogsPage = new HostCatalogsPage(page);
|
||||
const hostCatalogName = await hostCatalogsPage.createHostCatalog();
|
||||
const hostSetName = await hostCatalogsPage.createHostSet();
|
||||
await hostCatalogsPage.createHostInHostSet(targetAddress);
|
||||
// go to the credential store page
|
||||
|
||||
// Create another host set
|
||||
await page.getByRole('link', { name: hostCatalogName }).click();
|
||||
const hostSetName2 = await hostCatalogsPage.createHostSet();
|
||||
await page.goto(`/scopes/${project.id}/credential-stores`);
|
||||
|
||||
// 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();
|
||||
// Create UPD credential
|
||||
const credentialStore = new CredentialStoresPage(page);
|
||||
await credentialStore.createStaticCredentialStore();
|
||||
const credentialName =
|
||||
await credentialStoresPage.createStaticCredentialUsernamePassword(
|
||||
await credentialStore.createStaticCredentialUsernamePasswordDomain(
|
||||
sshUser,
|
||||
'testPassword',
|
||||
'testDomain',
|
||||
);
|
||||
|
||||
const targetsPage = new TargetsPage(page);
|
||||
const rdpTarget = await targetsPage.createRDPTargetWithAddressEnt(
|
||||
targetAddress,
|
||||
targetPort,
|
||||
);
|
||||
await targetsPage.addBrokeredCredentialsToTarget(
|
||||
rdpTarget,
|
||||
credentialName,
|
||||
);
|
||||
await targetsPage.addInjectedCredentialsToTarget(
|
||||
targetName,
|
||||
rdpTarget,
|
||||
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);
|
||||
if (org) {
|
||||
await boundaryHttp.deleteOrg(request, org.id);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -13,6 +13,8 @@ let targetWithHost;
|
||||
let targetWithTwoHosts;
|
||||
let sshTarget;
|
||||
let credential;
|
||||
let updCredential;
|
||||
let rdpTarget;
|
||||
|
||||
test.beforeEach(
|
||||
async ({ request, targetAddress, targetPort, sshUser, sshKeyPath }) => {
|
||||
@@ -64,6 +66,13 @@ test.beforeEach(
|
||||
username: sshUser,
|
||||
sshKeyPath,
|
||||
});
|
||||
updCredential =
|
||||
await boundaryHttp.createStaticCredentialUsernamePasswordDomain(request, {
|
||||
credentialStoreId: credentialStore.id,
|
||||
username: sshUser,
|
||||
password: 'password',
|
||||
domain: 'domain',
|
||||
});
|
||||
|
||||
// Create tcp target with host set and 1 host
|
||||
targetWithHost = await boundaryHttp.createTarget(request, {
|
||||
@@ -106,6 +115,26 @@ test.beforeEach(
|
||||
target: sshTarget,
|
||||
credentialIds: [credential.id],
|
||||
});
|
||||
|
||||
// Create an RDP target and add host source and credential sources
|
||||
// TODO: A test for RDP target connection will be added later when the Proxy is in place.
|
||||
rdpTarget = await boundaryHttp.createTarget(request, {
|
||||
scopeId: project.id,
|
||||
type: 'rdp',
|
||||
port: 3389,
|
||||
});
|
||||
rdpTarget = await boundaryHttp.addHostSource(request, {
|
||||
target: rdpTarget,
|
||||
hostSourceIds: [hostSet.id],
|
||||
});
|
||||
rdpTarget = await boundaryHttp.addBrokeredCredentials(request, {
|
||||
target: rdpTarget,
|
||||
credentialIds: [updCredential.id],
|
||||
});
|
||||
rdpTarget = await boundaryHttp.addInjectedCredentials(request, {
|
||||
target: rdpTarget,
|
||||
credentialIds: [updCredential.id],
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -62,3 +62,32 @@ export async function createStaticCredentialJson(
|
||||
|
||||
return checkResponse(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new username password domain credential
|
||||
* @param {import('@playwright/test').APIRequestContext} request
|
||||
* @param {string} credentialStoreId ID of the credential store where the credential will be created
|
||||
* @param {string} username Username of the user credential
|
||||
* @param {string} password Password of the user credential
|
||||
* @param {string} domain Domain of the user credential
|
||||
* @returns {Promise<Serializable>}
|
||||
*/
|
||||
export async function createStaticCredentialUsernamePasswordDomain(
|
||||
request,
|
||||
{ credentialStoreId, username, password, domain },
|
||||
) {
|
||||
const response = await request.post(`/v1/credentials`, {
|
||||
data: {
|
||||
name: `static-credential-store-${nanoid()}`,
|
||||
credential_store_id: credentialStoreId,
|
||||
type: 'username_password_domain',
|
||||
attributes: {
|
||||
username,
|
||||
password,
|
||||
domain,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return checkResponse(response);
|
||||
}
|
||||
Reference in new issue
Block a user