diff --git a/ui/admin/tests/e2e/helpers/boundary-ui.js b/ui/admin/tests/e2e/helpers/boundary-ui.js index 0ffad625a..538957025 100644 --- a/ui/admin/tests/e2e/helpers/boundary-ui.js +++ b/ui/admin/tests/e2e/helpers/boundary-ui.js @@ -796,19 +796,24 @@ exports.createUser = async (page) => { }; /** - * Uses the UI to add the first available account to a user. + * Uses the UI to add an account to a user * Assumes you have selected the desired user. * Assumes you have created new account. * @param {Page} page Playwright page object + * @param {string} loginName Login name of the account */ -exports.addAccountToUser = async (page) => { +exports.addAccountToUser = async (page, loginName) => { await page.getByRole('link', { name: 'Accounts', exact: true }).click(); await page .getByRole('article') .getByRole('link', { name: 'Add Accounts', exact: true }) .click(); + await page + .getByRole('cell', { name: loginName }) + .locator('..') + .getByRole('checkbox') + .click({ force: true }); - await page.getByRole('checkbox').click(); await page.getByRole('button', { name: 'Add Accounts', exact: true }).click(); await expect( page.getByRole('alert').getByText('Success', { exact: true }), diff --git a/ui/admin/tests/e2e/tests/auth-method-ldap.spec.js b/ui/admin/tests/e2e/tests/auth-method-ldap.spec.js index 939f73ef5..c9a839e58 100644 --- a/ui/admin/tests/e2e/tests/auth-method-ldap.spec.js +++ b/ui/admin/tests/e2e/tests/auth-method-ldap.spec.js @@ -6,7 +6,7 @@ /* eslint-disable no-undef */ const { test, expect } = require('@playwright/test'); const { execSync } = require('child_process'); -const { checkEnv, authenticatedState } = require('../helpers/general'); +const { checkEnv } = require('../helpers/general'); const { nanoid } = require('nanoid'); const { @@ -15,13 +15,14 @@ const { deleteOrgCli, } = require('../helpers/boundary-cli'); const { + addAccountToUser, + createPasswordAuthMethod, createOrg, createRole, + createUser, addPrincipalToRole, } = require('../helpers/boundary-ui'); -test.use({ storageState: authenticatedState }); - test.beforeAll(async () => { await checkEnv([ 'E2E_LDAP_ADDR', @@ -39,8 +40,25 @@ test.beforeAll(async () => { test('Set up LDAP auth method @ce @ent @docker', async ({ page }) => { await page.goto('/'); let orgName; - let connect; try { + // Log in + await page + .getByLabel('Login Name') + .fill(process.env.E2E_PASSWORD_ADMIN_LOGIN_NAME); + await page + .getByLabel('Password', { exact: true }) + .fill(process.env.E2E_PASSWORD_ADMIN_PASSWORD); + await page.getByRole('button', { name: 'Sign In' }).click(); + await expect( + page.getByRole('navigation', { name: 'General' }), + ).toBeVisible(); + await expect( + page.getByText(process.env.E2E_PASSWORD_ADMIN_LOGIN_NAME), + ).toBeEnabled(); + await expect( + page.getByRole('navigation', { name: 'breadcrumbs' }).getByText('Orgs'), + ).toBeVisible(); + // Create an LDAP auth method orgName = await createOrg(page); await page @@ -50,7 +68,6 @@ test('Set up LDAP auth method @ce @ent @docker', async ({ page }) => { await page.getByRole('button', { name: 'New' }).click(); await page.getByRole('link', { name: 'LDAP' }).click(); - // Fill out the form const ldapAuthMethodName = 'LDAP ' + nanoid(); await page.getByLabel('Name').fill(ldapAuthMethodName); await page.getByLabel('Description').fill('LDAP Auth Method'); @@ -124,6 +141,38 @@ test('Set up LDAP auth method @ce @ent @docker', async ({ page }) => { // Create a role and add LDAP managed group to role await createRole(page); await addPrincipalToRole(page, ldapManagedGroupName); + + // Create a user and attach LDAP account to it + await createUser(page); + await addAccountToUser(page, process.env.E2E_LDAP_USER_NAME); + + // Create a second auth method so that there's multiple auth methods on the + // login screen + await createPasswordAuthMethod(page); + + // Log out + await page.getByText(process.env.E2E_PASSWORD_ADMIN_LOGIN_NAME).click(); + await page.getByRole('button', { name: 'Sign Out' }).click(); + await expect(page.getByRole('button', { name: 'Sign In' })).toBeVisible(); + + // Log in using ldap account + await page.getByText('Choose a different scope').click(); + await page.getByRole('link', { name: orgName }).click(); + await page.getByRole('link', { name: ldapAuthMethodName }).click(); + await page.getByLabel('Login Name').fill(process.env.E2E_LDAP_USER_NAME); + await page + .getByLabel('Password', { exact: true }) + .fill(process.env.E2E_LDAP_USER_PASSWORD); + await page.getByRole('button', { name: 'Sign In' }).click(); + await expect( + page.getByRole('navigation', { name: 'General' }), + ).toBeVisible(); + await expect(page.getByText(process.env.E2E_LDAP_USER_NAME)).toBeEnabled(); + await expect( + page + .getByRole('navigation', { name: 'breadcrumbs' }) + .getByText('Projects'), + ).toBeVisible(); } finally { await authenticateBoundaryCli( process.env.BOUNDARY_ADDR, @@ -136,9 +185,5 @@ test('Set up LDAP auth method @ce @ent @docker', async ({ page }) => { if (org) { await deleteOrgCli(org.id); } - // End `boundary connect` process - if (connect) { - connect.kill('SIGTERM'); - } } }); diff --git a/ui/admin/tests/e2e/tests/auth-method-password.spec.js b/ui/admin/tests/e2e/tests/auth-method-password.spec.js index b02cebb5f..17e150761 100644 --- a/ui/admin/tests/e2e/tests/auth-method-password.spec.js +++ b/ui/admin/tests/e2e/tests/auth-method-password.spec.js @@ -57,7 +57,7 @@ test('Verify new auth-method can be created and assigned to users @ce @ent @aws await createPasswordAccount(page, username, password); await makeAuthMethodPrimary(page); await createUser(page); - await addAccountToUser(page); + await addAccountToUser(page, username); // Log out await page.getByText(process.env.E2E_PASSWORD_ADMIN_LOGIN_NAME).click();