Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
115 lines
4.3 KiB
TypeScript
115 lines
4.3 KiB
TypeScript
import { faker } from '@faker-js/faker';
|
|
|
|
import { ADMIN_CREDENTIALS } from './config/constants';
|
|
import { Users } from './fixtures/userStates';
|
|
import { AccountSecurity } from './page-objects';
|
|
import { setSettingValueById, updateOwnUserPassword } from './utils';
|
|
import { test, expect } from './utils/test';
|
|
|
|
test.use({ storageState: Users.admin.state });
|
|
|
|
const RANDOM_PASSWORD = faker.helpers
|
|
.shuffle([
|
|
faker.string.alpha({ casing: 'upper' }),
|
|
faker.string.alpha({ casing: 'lower' }),
|
|
faker.string.numeric(),
|
|
faker.string.symbol(),
|
|
faker.string.alphanumeric(10),
|
|
])
|
|
.join('');
|
|
|
|
test.describe.serial('account-security', () => {
|
|
let poAccountSecurity: AccountSecurity;
|
|
|
|
test.beforeEach(async ({ page, api }) => {
|
|
poAccountSecurity = new AccountSecurity(page);
|
|
await poAccountSecurity.gotoExpecting(poAccountSecurity.securityHeader.or(poAccountSecurity.notAuthorizedMessage));
|
|
await setSettingValueById(api, 'Accounts_Password_Policy_Enabled', false);
|
|
});
|
|
|
|
test.afterAll(async ({ api }) =>
|
|
Promise.all([
|
|
setSettingValueById(api, 'Accounts_AllowPasswordChange', true),
|
|
setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', true),
|
|
setSettingValueById(api, 'E2E_Enable', false),
|
|
setSettingValueById(api, 'Accounts_Password_Policy_Enabled', true),
|
|
]),
|
|
);
|
|
|
|
test('should disable and enable email 2FA', async () => {
|
|
await poAccountSecurity.security2FASection.click();
|
|
await expect(poAccountSecurity.email2FASwitch).toBeVisible();
|
|
await poAccountSecurity.email2FASwitch.click();
|
|
await poAccountSecurity.toastMessage.waitForDisplay();
|
|
await poAccountSecurity.toastMessage.dismissToast();
|
|
|
|
await poAccountSecurity.email2FASwitch.click();
|
|
await poAccountSecurity.toastMessage.waitForDisplay();
|
|
});
|
|
|
|
test('should be able to change password', async ({ api }) => {
|
|
await test.step('change password', async () => {
|
|
await poAccountSecurity.changePassword(RANDOM_PASSWORD, RANDOM_PASSWORD, ADMIN_CREDENTIALS.password);
|
|
await expect(poAccountSecurity.inputNewPassword).toHaveValue('');
|
|
});
|
|
|
|
await test.step('change back to the original password', async () => {
|
|
expect(
|
|
(await updateOwnUserPassword(api, { newPassword: ADMIN_CREDENTIALS.password, currentPassword: RANDOM_PASSWORD })).status(),
|
|
).toBe(200);
|
|
});
|
|
});
|
|
|
|
test.describe('settings disabled', () => {
|
|
test.beforeAll(async ({ api }) => {
|
|
await Promise.all([
|
|
setSettingValueById(api, 'Accounts_AllowPasswordChange', false),
|
|
setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', false),
|
|
setSettingValueById(api, 'E2E_Enable', false),
|
|
]);
|
|
});
|
|
|
|
test('security tab is invisible when password change, 2FA and E2E are disabled', async () => {
|
|
await expect(poAccountSecurity.sidebar.linkSecurity).not.toBeVisible();
|
|
await expect(poAccountSecurity.notAuthorizedMessage).toBeVisible();
|
|
});
|
|
});
|
|
|
|
test.describe('account security sections', () => {
|
|
test.beforeAll(async ({ api }) => {
|
|
await Promise.all([
|
|
setSettingValueById(api, 'Accounts_AllowPasswordChange', true),
|
|
setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', false),
|
|
setSettingValueById(api, 'E2E_Enable', false),
|
|
]);
|
|
});
|
|
|
|
test.beforeEach(async () => {
|
|
await poAccountSecurity.securityHeader.waitFor({ state: 'visible' });
|
|
});
|
|
|
|
test('should display security tab and section when password change is enabled but 2FA and E2E are disabled', async () => {
|
|
await expect(poAccountSecurity.sidebar.linkSecurity).toBeVisible();
|
|
await expect(poAccountSecurity.securityPasswordSection).toBeVisible();
|
|
});
|
|
|
|
test('can access 2FA setting when enabled but password change and E2E are disabled', async ({ api }) => {
|
|
await Promise.all([
|
|
setSettingValueById(api, 'Accounts_AllowPasswordChange', false),
|
|
setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', true),
|
|
setSettingValueById(api, 'E2E_Enable', false),
|
|
]);
|
|
await expect(poAccountSecurity.security2FASection).toBeVisible();
|
|
});
|
|
|
|
test('can access E2E setting when enabled but password change and 2FA are disabled', async ({ api }) => {
|
|
await Promise.all([
|
|
setSettingValueById(api, 'Accounts_AllowPasswordChange', false),
|
|
setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', false),
|
|
setSettingValueById(api, 'E2E_Enable', true),
|
|
]);
|
|
await expect(poAccountSecurity.securityE2EEncryptionSection).toBeVisible();
|
|
});
|
|
});
|
|
});
|