Files
threshold-ui/e2e-tests/desktop/tests/authentication.spec.js
T

84 lines
2.5 KiB
JavaScript
Raw Normal View History

2024-08-02 13:28:50 -04:00
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
2024-11-12 18:11:00 -05:00
import { expect, test } from '../fixtures/baseTest.js';
import LoginPage from '../pages/loginPage.js';
2024-08-02 13:28:50 -04:00
test.describe('user/password authentication tests', () => {
2024-08-02 13:28:50 -04:00
test('Authenticates and signs out', async ({
electronPage,
clusterUrl,
username,
password,
}) => {
const loginPage = new LoginPage(electronPage);
await loginPage.setClusterUrl(clusterUrl);
await loginPage.logInWithPassword(username, password);
await expect(electronPage).toHaveURL(
/.*\/scopes\/global\/projects\/targets$/,
);
await electronPage
.locator('details')
.filter({ hasText: 'Sign Out' })
.click();
await electronPage.getByRole('button', { name: 'Sign Out' }).click();
await expect(electronPage).toHaveURL(/.*\/scopes\/global\/authenticate\//);
});
test('Fails to authenticate with wrong password', async ({
electronPage,
clusterUrl,
username,
}) => {
const loginPage = new LoginPage(electronPage);
await loginPage.setClusterUrl(clusterUrl);
await loginPage.logInWithPassword(username, 'wrong password!!');
await expect(electronPage).toHaveURL(/.*\/scopes\/global\/authenticate\//);
await expect(electronPage.getByText('Authentication Failed')).toBeVisible();
});
});
2024-12-03 18:51:22 -05:00
// Setup an LDAP server for these tests
test.fixme('LDAP authentication tests', async () => {
2024-08-02 13:28:50 -04:00
test('Authenticates and signs out', async ({
electronPage,
clusterUrl,
username,
password,
}) => {
const loginPage = new LoginPage(electronPage);
await loginPage.setClusterUrl(clusterUrl);
await loginPage.logInWithLDAP(username, password);
await expect(electronPage).toHaveURL(
/.*\/scopes\/global\/projects\/targets$/,
);
await electronPage
.locator('details')
.filter({ hasText: 'Sign Out' })
.click();
await electronPage.getByRole('button', { name: 'Sign Out' }).click();
await expect(electronPage).toHaveURL(/.*\/scopes\/global\/authenticate\//);
});
test('Fails to authenticate with wrong password', async ({
electronPage,
clusterUrl,
username,
}) => {
const loginPage = new LoginPage(electronPage);
await loginPage.setClusterUrl(clusterUrl);
await loginPage.logInWithLDAP(username, 'wrong password!!');
await expect(electronPage).toHaveURL(/.*\/scopes\/global\/authenticate\//);
await expect(electronPage.getByText('Authentication Failed')).toBeVisible();
});
});