snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
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 1s

This commit is contained in:
upstream-mirror
2026-09-16 01:21:02 +05:00
commit 30810eecd7
10161 changed files with 987110 additions and 0 deletions

View File

@@ -0,0 +1,407 @@
import { faker } from '@faker-js/faker';
import { DEFAULT_USER_CREDENTIALS } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { HomeChannel } from '../page-objects';
import { ToastMessages } from '../page-objects/fragments';
import { CreateE2EEChannel } from '../page-objects/fragments/e2ee';
import { deletePrivateRoomsByName } from '../utils';
import { preserveSettings } from '../utils/preserveSettings';
import { test, expect } from '../utils/test';
const settingsList = [
'E2E_Enable',
'E2E_Allow_Unencrypted_Messages',
'E2E_Enabled_Default_DirectRooms',
'E2E_Enabled_Default_PrivateRooms',
];
preserveSettings(settingsList);
test.describe('E2EE Encrypted Channels', () => {
const createdChannels: string[] = [];
let poHomeChannel: HomeChannel;
let toastMessages: ToastMessages;
let createE2EEChannel: CreateE2EEChannel;
test.use({ storageState: Users.userE2EE.state });
test.beforeAll(async ({ api }) => {
await api.post('/settings/E2E_Enable', { value: true });
await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: true });
await api.post('/settings/E2E_Enabled_Default_DirectRooms', { value: false });
await api.post('/settings/E2E_Enabled_Default_PrivateRooms', { value: false });
await api.post('/im.delete', { username: 'user2' });
});
test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);
createE2EEChannel = new CreateE2EEChannel(page);
await poHomeChannel.goto();
});
test.afterAll(async () => {
await deletePrivateRoomsByName(
{ username: Users.userE2EE.data.username, password: DEFAULT_USER_CREDENTIALS.password },
createdChannels,
);
});
test('expect create a private channel encrypted and send an encrypted message', async ({ page }) => {
toastMessages = new ToastMessages(page);
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();
await poHomeChannel.content.sendMessage('hello world');
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText('hello world');
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
await toastMessages.dismissToast();
await poHomeChannel.roomToolbar.openMoreOptions();
await poHomeChannel.roomToolbar.menuItemDisableE2EEncryption.click();
await expect(page.getByRole('dialog', { name: 'Disable encryption' })).toBeVisible();
await page.getByRole('button', { name: 'Disable encryption' }).click();
await poHomeChannel.toastMessage.dismissToast();
await page.waitForTimeout(1000);
await poHomeChannel.content.sendMessage('hello world not encrypted');
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText('hello world not encrypted');
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).not.toBeVisible();
await poHomeChannel.roomToolbar.openMoreOptions();
await expect(poHomeChannel.roomToolbar.menuItemEnableE2EEncryption).toBeVisible();
await poHomeChannel.roomToolbar.menuItemEnableE2EEncryption.click();
await expect(page.getByRole('dialog', { name: 'Enable encryption' })).toBeVisible();
await page.getByRole('button', { name: 'Enable encryption' }).click();
await poHomeChannel.toastMessage.dismissToast();
await page.waitForTimeout(1000);
await poHomeChannel.content.sendMessage('hello world encrypted again');
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText('hello world encrypted again');
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
});
test('expect create a private encrypted channel and send a encrypted thread message', async ({ page }) => {
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();
await poHomeChannel.content.sendMessage('This is the thread main message.');
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText('This is the thread main message.');
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
await poHomeChannel.content.openReplyInThread();
await expect(page).toHaveURL(/.*thread/);
await expect(poHomeChannel.content.mainThreadMessageText).toContainText('This is the thread main message.');
await expect(poHomeChannel.content.mainThreadMessageText.locator('.rcx-icon--name-key')).toBeVisible();
await poHomeChannel.content.toggleAlsoSendThreadToChannel(true);
await page.getByRole('dialog').locator('[name="msg"]').last().fill('This is an encrypted thread message also sent in channel');
await page.keyboard.press('Enter');
await expect(poHomeChannel.content.lastUserThreadMessage).toContainText('This is an encrypted thread message also sent in channel');
await expect(poHomeChannel.content.lastUserThreadMessage.locator('.rcx-icon--name-key')).toBeVisible();
await expect(poHomeChannel.content.lastThreadMessagePreview).toContainText('This is an encrypted thread message also sent in channel');
await expect(poHomeChannel.content.mainThreadMessageText).toContainText('This is the thread main message.');
await expect(poHomeChannel.content.mainThreadMessageText.locator('.rcx-icon--name-key')).toBeVisible();
});
test('expect create a private encrypted channel and check disabled message menu actions on an encrypted message', async ({ page }) => {
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();
await poHomeChannel.content.sendMessage('This is an encrypted message.');
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText('This is an encrypted message.');
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
await poHomeChannel.content.lastUserMessage.hover();
await expect(page.locator('role=button[name="Forward message not available on encrypted content"]')).toBeDisabled();
await poHomeChannel.content.openLastMessageMenu();
await expect(page.locator('role=menuitem[name="Reply in direct message"]')).toHaveClass(/disabled/);
await expect(page.locator('role=menuitem[name="Copy link"]')).toHaveClass(/disabled/);
});
test('expect create a private channel, encrypt it and send an encrypted message', async ({ page }) => {
const channelName = faker.string.uuid();
await poHomeChannel.navbar.createNew('Channel', channelName);
createE2EEChannel.store(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await poHomeChannel.toastMessage.waitForDisplay();
await poHomeChannel.toastMessage.dismissToast();
await poHomeChannel.roomToolbar.openMoreOptions();
// TODO(@jessicaschelly/@dougfabris): fix this flaky behavior
if (!(await poHomeChannel.roomToolbar.menuItemEnableE2EEncryption.isVisible())) {
await poHomeChannel.roomToolbar.openMoreOptions();
}
await poHomeChannel.roomToolbar.menuItemEnableE2EEncryption.click();
await expect(page.getByRole('dialog', { name: 'Enable encryption' })).toBeVisible();
await page.getByRole('button', { name: 'Enable encryption' }).click();
await page.waitForTimeout(1000);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();
await poHomeChannel.content.sendMessage('hello world');
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText('hello world');
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
});
test('expect create a encrypted private channel and mention user', async ({ page }) => {
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();
await poHomeChannel.content.sendMessage('hello @user1');
const userMention = page.getByRole('button', {
name: 'user1',
});
await expect(userMention).toBeVisible();
});
test('expect create a encrypted private channel, mention a channel and navigate to it', async ({ page }) => {
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();
await poHomeChannel.content.sendMessage('Are you in the #general channel?');
const channelMention = page.getByRole('button', {
name: 'general',
});
await expect(channelMention).toBeVisible();
await channelMention.click();
await expect(page).toHaveURL(`/channel/general`);
});
test('expect create a encrypted private channel, mention a channel and user', async ({ page }) => {
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();
await poHomeChannel.content.sendMessage('Are you in the #general channel, @user1 ?');
const channelMention = page.getByRole('button', {
name: 'general',
});
const userMention = page.getByRole('button', {
name: 'user1',
});
await expect(userMention).toBeVisible();
await expect(channelMention).toBeVisible();
});
test('expect create a private channel, send unecrypted messages, encrypt the channel and delete the last message and check the last message in the sidebar', async ({
page,
}) => {
const channelName = faker.string.uuid();
// Enable Sidebar Extended display mode
await poHomeChannel.navbar.setDisplayMode('Extended');
// Create private channel
await poHomeChannel.navbar.createNew('Channel', channelName, { private: true });
createE2EEChannel.store(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await poHomeChannel.toastMessage.waitForDisplay();
await poHomeChannel.toastMessage.dismissToast();
// Send Unencrypted Messages
await poHomeChannel.content.sendMessage('first unencrypted message');
await poHomeChannel.content.sendMessage('second unencrypted message');
// Encrypt channel
await poHomeChannel.roomToolbar.openMoreOptions();
await expect(poHomeChannel.roomToolbar.menuItemEnableE2EEncryption).toBeVisible();
await poHomeChannel.roomToolbar.menuItemEnableE2EEncryption.click();
await expect(page.getByRole('dialog', { name: 'Enable encryption' })).toBeVisible();
await page.getByRole('button', { name: 'Enable encryption' }).click();
await page.waitForTimeout(1000);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();
// Send Encrypted Messages
const encriptedMessage1 = 'first ENCRYPTED message';
const encriptedMessage2 = 'second ENCRYPTED message';
await poHomeChannel.content.sendMessage(encriptedMessage1);
await poHomeChannel.content.sendMessage(encriptedMessage2);
// Delete last message
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText(encriptedMessage2);
await poHomeChannel.content.openLastMessageMenu();
// TODO(@jessicaschelly/@dougfabris): fix this flaky behavior
if (!(await page.locator('role=menuitem[name="Delete"]').isVisible())) {
await poHomeChannel.content.openLastMessageMenu();
}
await page.locator('role=menuitem[name="Delete"]').click();
await page.locator('#modal-root .rcx-button-group--align-end .rcx-button--danger').click();
// Check last message in the sidebar
const sidebarChannel = poHomeChannel.sidebar.getSidebarItemByName(channelName);
await expect(sidebarChannel).toBeVisible();
await expect(sidebarChannel.getByText(`You: ${encriptedMessage2}`, { exact: true })).not.toBeVisible();
await expect(sidebarChannel.getByText(`You: ${encriptedMessage1}`, { exact: true })).toBeVisible();
});
test('expect create a private encrypted channel and pin/star an encrypted message', async ({ page }) => {
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();
await poHomeChannel.content.sendMessage('This message should be pinned and stared.');
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText('This message should be pinned and stared.');
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
await poHomeChannel.content.openLastMessageMenu();
await page.locator('role=menuitem[name="Star"]').click();
await poHomeChannel.toastMessage.waitForDisplay();
await poHomeChannel.toastMessage.dismissToast();
await poHomeChannel.content.openLastMessageMenu();
await page.locator('role=menuitem[name="Pin"]').click();
await page.locator('#modal-root >> button:has-text("Yes, pin message")').click();
await poHomeChannel.toastMessage.waitForDisplay();
await poHomeChannel.toastMessage.dismissToast();
await poHomeChannel.roomToolbar.openMoreOptions();
await poHomeChannel.roomToolbar.menuItemPinnedMessages.click();
await expect(page.getByRole('dialog', { name: 'Pinned Messages' })).toBeVisible();
const lastPinnedMessage = page
.getByRole('dialog', { name: 'Pinned Messages' })
.locator('[role="listitem"][aria-roledescription="message"]')
.last();
await expect(lastPinnedMessage).toContainText('This message should be pinned and stared.');
await lastPinnedMessage.hover();
await lastPinnedMessage.locator('role=button[name="More"]').waitFor();
await lastPinnedMessage.locator('role=button[name="More"]').click();
await expect(page.locator('role=menuitem[name="Copy link"]')).toHaveClass(/disabled/);
await poHomeChannel.btnContextualbarClose.click();
await poHomeChannel.roomToolbar.openMoreOptions();
await poHomeChannel.roomToolbar.menuItemStarredMessages.click();
const lastStarredMessage = page
.getByRole('dialog', { name: 'Starred Messages' })
.locator('[role="listitem"][aria-roledescription="message"]')
.last();
await expect(page.getByRole('dialog', { name: 'Starred Messages' })).toBeVisible();
await expect(lastStarredMessage).toContainText('This message should be pinned and stared.');
await lastStarredMessage.hover();
await lastStarredMessage.locator('role=button[name="More"]').waitFor();
await lastStarredMessage.locator('role=button[name="More"]').click();
await expect(page.locator('role=menuitem[name="Copy link"]')).toHaveClass(/disabled/);
});
test('expect to edit encrypted message', async ({ page }) => {
const channelName = faker.string.uuid();
const originalMessage = 'This is the original encrypted message';
const editedMessage = 'This is the edited encrypted message';
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();
await poHomeChannel.content.sendMessage(originalMessage);
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText(originalMessage);
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
await poHomeChannel.content.openLastMessageMenu();
await poHomeChannel.content.btnOptionEditMessage.click();
await poHomeChannel.composer.inputMessage.fill(editedMessage);
await page.keyboard.press('Enter');
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText(editedMessage);
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
});
test('expect to edit encrypted message to include mention', async ({ page }) => {
const channelName = faker.string.uuid();
const originalMessage = 'This is the original encrypted message';
const editedMessage = 'This is the edited encrypted message with a mention to @user1 and #general';
const displayedMessage = 'This is the edited encrypted message with a mention to user1 and general';
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();
await poHomeChannel.content.sendMessage(originalMessage);
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText(originalMessage);
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
await poHomeChannel.content.openLastMessageMenu();
await poHomeChannel.content.btnOptionEditMessage.click();
await poHomeChannel.composer.inputMessage.fill(editedMessage);
await poHomeChannel.composer.btnSend.click();
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText(displayedMessage);
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
const userMention = page.getByRole('button', {
name: 'user1',
});
await expect(userMention).toBeVisible();
const channelMention = page.getByRole('button', {
name: 'general',
});
await expect(channelMention).toBeVisible();
});
});

View File

@@ -0,0 +1,217 @@
import { faker } from '@faker-js/faker';
import { resetOwnE2EKey } from './resetOwnE2EKey';
import { setupE2EEPassword } from './setupE2EEPassword';
import { ADMIN_CREDENTIALS, BASE_URL } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { EncryptedRoomPage } from '../page-objects/encrypted-room';
import { Navbar } from '../page-objects/fragments';
import { CreateE2EEChannel } from '../page-objects/fragments/e2ee';
import { FileUploadModal } from '../page-objects/fragments/modals';
import { LoginPage } from '../page-objects/login';
import { createTargetGroupAndReturnFullRoom, deletePrivateRoomsByName, deleteRoom } from '../utils';
import { preserveSettings } from '../utils/preserveSettings';
import { sendMessageFromUser } from '../utils/sendMessage';
import { test, expect } from '../utils/test';
const settingsList = ['E2E_Enable', 'E2E_Allow_Unencrypted_Messages'];
preserveSettings(settingsList);
test.describe('E2EE Encryption and Decryption - Basic Features', () => {
const createdChannels: string[] = [];
let loginPage: LoginPage;
let navbar: Navbar;
let encryptedRoomPage: EncryptedRoomPage;
let createE2EEChannel: CreateE2EEChannel;
test.use({ storageState: Users.admin.state });
test.beforeAll(async ({ api }) => {
await api.post('/settings/E2E_Enable', { value: true });
await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: true });
});
test.beforeEach(async ({ page }) => {
loginPage = new LoginPage(page);
navbar = new Navbar(page);
encryptedRoomPage = new EncryptedRoomPage(page);
createE2EEChannel = new CreateE2EEChannel(page);
await expect(await resetOwnE2EKey(ADMIN_CREDENTIALS)).toBeOK();
await loginPage.goto();
await loginPage.loginByUserState(Users.admin);
});
test.afterAll(async () => {
await deletePrivateRoomsByName(ADMIN_CREDENTIALS, createdChannels);
});
test('expect placeholder text in place of encrypted message', async ({ page }) => {
const channelName = faker.string.uuid();
const messageText = 'This is an encrypted message.';
await setupE2EEPassword(page);
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await encryptedRoomPage.waitForChannel();
await expect(encryptedRoomPage.encryptedTitle).toBeVisible();
await expect(encryptedRoomPage.encryptionNotReadyIndicator).not.toBeVisible();
await encryptedRoomPage.sendMessage(messageText);
await expect(encryptedRoomPage.lastMessage.encryptedIcon).toBeVisible();
await expect(encryptedRoomPage.lastMessage.body).toHaveText(messageText);
// Log out
await navbar.logout();
// Login again
await loginPage.loginByUserState(Users.admin);
// Navigate to the encrypted channel WITHOUT entering the password
await navbar.openChat(channelName);
await expect(encryptedRoomPage.encryptedTitle).toBeVisible();
await expect(encryptedRoomPage.encryptionNotReadyIndicator).toBeVisible();
await expect(encryptedRoomPage.lastMessage.encryptedIcon).toBeVisible();
await expect(encryptedRoomPage.lastMessage.body).toHaveText(
'This message is end-to-end encrypted. To view it, you must enter your encryption key in your account settings.',
);
});
test('expect placeholder text in place of encrypted file upload description', async ({ page }) => {
const fileUploadModal = new FileUploadModal(page);
const channelName = faker.string.uuid();
const fileName = faker.system.commonFileName('txt');
const fileDescription = faker.lorem.sentence();
await setupE2EEPassword(page);
// Create an encrypted channel
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(encryptedRoomPage.encryptedTitle).toBeVisible();
await expect(encryptedRoomPage.encryptionNotReadyIndicator).not.toBeVisible();
await test.step('upload the file with encryption', async () => {
// Upload a file
await encryptedRoomPage.dragAndDropTxtFile();
// Update file name and send
await encryptedRoomPage.composer.getFileByName('any_file.txt').click();
await fileUploadModal.setName(fileName);
await fileUploadModal.update();
await expect(encryptedRoomPage.composer.getFileByName(fileName)).toBeVisible();
await encryptedRoomPage.composer.inputMessage.fill(fileDescription);
await encryptedRoomPage.composer.btnSend.click();
await expect(encryptedRoomPage.lastMessage.encryptedIcon).toBeVisible();
await expect(encryptedRoomPage.lastMessage.getFileUploadByName(fileName)).toContainText(fileName);
await expect(encryptedRoomPage.lastMessage.body).toHaveText(fileDescription);
});
await test.step('disable encryption in the room', async () => {
await encryptedRoomPage.disableEncryption();
await expect(encryptedRoomPage.encryptedTitle).not.toBeVisible();
});
await test.step('upload the file without encryption', async () => {
await encryptedRoomPage.dragAndDropTxtFile();
// Update file name and send
await encryptedRoomPage.composer.getFileByName('any_file.txt').click();
await fileUploadModal.setName(fileName);
await fileUploadModal.update();
await expect(encryptedRoomPage.composer.getFileByName(fileName)).toBeVisible();
await encryptedRoomPage.composer.inputMessage.fill(fileDescription);
await encryptedRoomPage.composer.btnSend.click();
await expect(encryptedRoomPage.lastMessage.encryptedIcon).not.toBeVisible();
await expect(encryptedRoomPage.lastMessage.getFileUploadByName(fileName)).toContainText(fileName);
await expect(encryptedRoomPage.lastMessage.body).toHaveText(fileDescription);
});
await test.step('enable encryption in the room', async () => {
await encryptedRoomPage.enableEncryption();
await expect(encryptedRoomPage.encryptedTitle).toBeVisible();
});
// Log out
await navbar.logout();
// Login again
await loginPage.loginByUserState(Users.admin);
await expect(navbar.btnCreateNew).toBeVisible();
await navbar.openChat(channelName);
await expect(encryptedRoomPage.encryptedTitle).toBeVisible();
await expect(encryptedRoomPage.lastNthMessage(1).body).toHaveText(
'This message is end-to-end encrypted. To view it, you must enter your encryption key in your account settings.',
);
await expect(encryptedRoomPage.lastNthMessage(1).encryptedIcon).toBeVisible();
await expect(encryptedRoomPage.lastMessage.encryptedIcon).not.toBeVisible();
await expect(encryptedRoomPage.lastMessage.getFileUploadByName(fileName)).toContainText(fileName);
await expect(encryptedRoomPage.lastMessage.body).toHaveText(fileDescription);
});
test.describe('E2EE Quotes', () => {
let targetRoomId: string;
let targetChannelName: string;
test.afterAll(async ({ api }) => {
await deleteRoom(api, targetRoomId);
});
test('expect to not crash and not show quote message for a message_link which is not accessible to the user', async ({
page,
request,
api,
}) => {
const encryptedRoomPage = new EncryptedRoomPage(page);
targetChannelName = faker.string.uuid();
await createE2EEChannel.createAndStore(targetChannelName, createdChannels);
await expect(page).toHaveURL(`/group/${targetChannelName}`);
await expect(encryptedRoomPage.encryptedTitle).toBeVisible();
await expect(encryptedRoomPage.encryptionNotReadyIndicator).not.toBeVisible();
await encryptedRoomPage.sendMessage('First encrypted message.');
await expect(encryptedRoomPage.lastMessage.encryptedIcon).toBeVisible();
await expect(encryptedRoomPage.lastMessage.body).toHaveText('First encrypted message.');
// create a private group for user2
const { group: user1Channel } = await createTargetGroupAndReturnFullRoom(api, {
excludeSelf: true,
members: [Users.user2.data._id],
});
targetRoomId = user1Channel._id;
// send a message to the private group, which is not accessible to the main user
const sentMessage = (await sendMessageFromUser(request, Users.user2, targetRoomId, 'This is a test message.')).message;
const messageLink = `${BASE_URL}/group/${user1Channel.name}?msg=${sentMessage._id}`;
await encryptedRoomPage.sendMessage(`This is a message with message link - ${messageLink}`);
await expect(encryptedRoomPage.lastMessage.encryptedIcon).toBeVisible();
await expect(encryptedRoomPage.lastMessage.body).toContainText(`This is a message with message link - ${messageLink}`);
await expect(encryptedRoomPage.lastNthMessage(1).body).toContainText('First encrypted message.');
await page.reload();
await expect(encryptedRoomPage.lastMessage.encryptedIcon).toBeVisible();
await expect(encryptedRoomPage.lastMessage.body).toContainText(`This is a message with message link - ${messageLink}`);
await expect(encryptedRoomPage.lastNthMessage(1).body).toContainText('First encrypted message.');
});
});
});

View File

@@ -0,0 +1,216 @@
import { Users } from '../fixtures/userStates';
import { HomeChannel } from '../page-objects';
import { createTargetGroupAndReturnFullRoom } from '../utils';
import { preserveSettings } from '../utils/preserveSettings';
import { test, expect } from '../utils/test';
const settingsList = [
'E2E_Enable',
'E2E_Allow_Unencrypted_Messages',
'E2E_Enable_Encrypt_Files',
'E2E_Enabled_Default_DirectRooms',
'E2E_Enabled_Default_PrivateRooms',
];
const originalSettings = preserveSettings(settingsList);
const TEST_FILE_TXT = 'any_file.txt';
test.use({ storageState: Users.userE2EE.state });
test.describe('E2EE File Encryption', () => {
let poHomeChannel: HomeChannel;
let encryptedRoomId: string;
test.beforeAll(async ({ api }) => {
await api.post('/settings/E2E_Enable', { value: true });
await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: true });
await api.post('/settings/E2E_Enabled_Default_DirectRooms', { value: false });
await api.post('/settings/E2E_Enabled_Default_PrivateRooms', { value: false });
await api.post('/im.delete', { username: 'user2' });
});
test.afterAll(async ({ api }) => {
await api.post('/settings/FileUpload_MediaTypeWhiteList', { value: '' });
await api.post('/settings/FileUpload_MediaTypeBlackList', { value: 'image/svg+xml' });
});
test.beforeEach(async ({ api, page }) => {
poHomeChannel = new HomeChannel(page);
const { group } = await createTargetGroupAndReturnFullRoom(api, {
extraData: {
broadcast: false,
encrypted: true,
},
members: [Users.userE2EE.data._id],
});
encryptedRoomId = group._id;
await poHomeChannel.gotoGroup(group.name as string);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();
await expect
.poll(
() =>
page.evaluate(async (rid) => {
// eslint-disable-next-line import-x/no-absolute-path
const { e2e } = require('/client/lib/e2ee/rocketchat.e2e.ts') as typeof import('../../../client/lib/e2ee/rocketchat.e2e');
const room = await e2e.getInstanceByRoomId(rid);
return room?.getState();
}, group._id),
{ message: 'expect room encryption key to be ready before sending messages' },
)
.toBe('READY');
});
test.afterEach(async ({ api }) => {
expect((await api.post('/groups.delete', { roomId: encryptedRoomId })).status()).toBe(200);
});
test('should edit encrypted message with file', async ({ page }) => {
const updatedFileName = `edited_${TEST_FILE_TXT}`;
await test.step('send a file in channel and edit it', async () => {
await poHomeChannel.content.dragAndDropTxtFile();
await poHomeChannel.composer.getFileByName(TEST_FILE_TXT).click();
await poHomeChannel.content.inputFileUploadName.fill(updatedFileName);
await poHomeChannel.content.btnUpdateFileUpload.click();
await expect(poHomeChannel.composer.getFileByName(updatedFileName)).toBeVisible();
await poHomeChannel.composer.inputMessage.fill('any_description');
await poHomeChannel.composer.btnSend.click();
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
await expect(poHomeChannel.content.getFileDescription).toHaveText('any_description');
await expect(poHomeChannel.content.getLastMessageByFileName(updatedFileName)).toContainText(updatedFileName);
});
await test.step('edit the description', async () => {
await poHomeChannel.content.openLastMessageMenu();
await poHomeChannel.content.btnOptionEditMessage.click();
await expect(poHomeChannel.composer.inputMessage).toHaveValue('any_description');
await poHomeChannel.composer.inputMessage.fill('edited any_description');
await page.keyboard.press('Enter');
await expect(poHomeChannel.content.getFileDescription).toHaveText('edited any_description');
await expect(poHomeChannel.content.lastUserMessage.getByRole('link').getByText(updatedFileName)).toBeVisible();
});
await test.step('delete the file from files list', async () => {
await poHomeChannel.roomToolbar.openMoreOptions();
await poHomeChannel.roomToolbar.menuItemFiles.click();
await poHomeChannel.tabs.files.deleteFile(updatedFileName);
await expect(poHomeChannel.tabs.files.getFileByName(updatedFileName)).toHaveCount(0);
await expect(poHomeChannel.content.lastUserMessage.getByRole('link').getByText(updatedFileName)).not.toBeVisible();
});
});
test('File with Unicode filename uploads and downloads correctly', async ({ page }) => {
const UNICODE_FILE_NAME = 'Новый текстовый документ.txt';
await test.step('upload file with Unicode filename', async () => {
await poHomeChannel.content.sendFileMessage(TEST_FILE_TXT);
await poHomeChannel.composer.getFileByName(TEST_FILE_TXT).click();
await poHomeChannel.content.inputFileUploadName.fill(UNICODE_FILE_NAME);
await poHomeChannel.content.btnUpdateFileUpload.click();
await poHomeChannel.composer.btnSend.click();
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
await expect(poHomeChannel.content.getLastMessageByFileName(UNICODE_FILE_NAME)).toBeVisible();
});
await test.step('download the file and verify the Unicode filename is preserved', async () => {
await poHomeChannel.roomToolbar.openMoreOptions();
await poHomeChannel.roomToolbar.menuItemFiles.click();
await expect(poHomeChannel.tabs.files.getFileByName(UNICODE_FILE_NAME)).toBeVisible();
const [download] = await Promise.all([
page.waitForEvent('download'),
poHomeChannel.tabs.files.getFileByName(UNICODE_FILE_NAME).click(),
]);
expect(download.suggestedFilename()).toBe(UNICODE_FILE_NAME);
});
});
test('File encryption with whitelisted and blacklisted media types', async ({ api }) => {
await test.step('send a text file in channel', async () => {
const updatedFileName = `edited_${TEST_FILE_TXT}`;
await poHomeChannel.content.dragAndDropTxtFile();
await poHomeChannel.composer.getFileByName(TEST_FILE_TXT).click();
await poHomeChannel.content.inputFileUploadName.fill(updatedFileName);
await poHomeChannel.content.btnUpdateFileUpload.click();
await poHomeChannel.composer.btnSend.click();
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
await expect(poHomeChannel.content.getFileDescription).not.toBeVisible();
await expect(poHomeChannel.content.getLastMessageByFileName(updatedFileName)).toContainText(updatedFileName);
});
await test.step('set whitelisted media type setting', async () => {
await api.post('/settings/FileUpload_MediaTypeWhiteList', { value: 'text/plain' });
});
await test.step('send text file again with whitelist setting set', async () => {
await poHomeChannel.content.dragAndDropTxtFile();
await poHomeChannel.composer.inputMessage.fill('message 2');
await poHomeChannel.composer.getFileByName(TEST_FILE_TXT).click();
await poHomeChannel.content.inputFileUploadName.fill('any_file2.txt');
await poHomeChannel.content.btnUpdateFileUpload.click();
await poHomeChannel.composer.btnSend.click();
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
await expect(poHomeChannel.content.getFileDescription).toHaveText('message 2');
await expect(poHomeChannel.content.getLastMessageByFileName('any_file2.txt')).toBeVisible();
});
await test.step('set blacklisted media type setting to not accept application/octet-stream media type', async () => {
await api.post('/settings/FileUpload_MediaTypeBlackList', { value: 'application/octet-stream' });
});
await test.step('send text file again with blacklisted setting set, file upload should fail', async () => {
await poHomeChannel.content.dragAndDropTxtFile();
const composerFiles = await poHomeChannel.composer.getFileByName(TEST_FILE_TXT).all();
await Promise.all(composerFiles.map((file) => expect(file).toHaveAttribute('readonly')));
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
});
});
test.describe('File encryption setting disabled', () => {
test.beforeAll(async ({ api }) => {
await api.post('/settings/E2E_Enable_Encrypt_Files', { value: false });
await api.post('/settings/FileUpload_MediaTypeBlackList', { value: 'application/octet-stream' });
});
test.afterAll(async ({ api }) => {
await api.post('/settings/E2E_Enable_Encrypt_Files', { value: originalSettings.E2E_Enable_Encrypt_Files });
await api.post('/settings/FileUpload_MediaTypeBlackList', { value: 'image/svg+xml' });
});
test('Upload file without encryption in e2ee room', async () => {
await test.step('send a test encrypted message to check e2ee is working', async () => {
await poHomeChannel.content.sendMessage('This is an encrypted message.');
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText('This is an encrypted message.');
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
});
await test.step('send a text file in channel, file should not be encrypted', async () => {
await poHomeChannel.content.dragAndDropTxtFile();
await poHomeChannel.composer.inputMessage.fill('any_description');
await poHomeChannel.composer.getFileByName(TEST_FILE_TXT).click();
await poHomeChannel.content.inputFileUploadName.fill('any_file1.txt');
await poHomeChannel.content.btnUpdateFileUpload.click();
await poHomeChannel.composer.btnSend.click();
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).not.toBeVisible();
await expect(poHomeChannel.content.getFileDescription).toHaveText('any_description');
await expect(poHomeChannel.content.getLastMessageByFileName('any_file1.txt')).toContainText('any_file1.txt');
});
});
});
});

View File

@@ -0,0 +1,53 @@
import type { Page } from '@playwright/test';
import { createAuxContext } from '../fixtures/createAuxContext';
import injectInitialData from '../fixtures/inject-initial-data';
import { Users } from '../fixtures/userStates';
import { AccountSecurity, HomeChannel } from '../page-objects';
import { preserveSettings } from '../utils/preserveSettings';
import { test, expect } from '../utils/test';
const settingsList = [
'E2E_Enable',
'E2E_Allow_Unencrypted_Messages',
'E2E_Enabled_Default_DirectRooms',
'E2E_Enabled_Default_PrivateRooms',
];
preserveSettings(settingsList);
test.describe('E2EE Key Reset', () => {
let anotherClientPage: Page;
test.use({ storageState: Users.userE2EE.state });
test.beforeAll(async ({ api }) => {
await api.post('/settings/E2E_Enable', { value: true });
await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: true });
await api.post('/settings/E2E_Enabled_Default_DirectRooms', { value: false });
await api.post('/settings/E2E_Enabled_Default_PrivateRooms', { value: false });
await api.post('/im.delete', { username: 'user2' });
});
test.beforeEach(async ({ browser, page }) => {
anotherClientPage = (await createAuxContext(browser, Users.userE2EE)).page;
const poHomeChannel = new HomeChannel(page);
await poHomeChannel.goto();
});
test.afterEach(async () => {
await anotherClientPage.close();
await injectInitialData();
});
test('expect force logout on e2e keys reset', async ({ page }) => {
const poAccountSecurity = new AccountSecurity(page);
await poAccountSecurity.goto();
await poAccountSecurity.securityE2EEncryptionSection.click();
await poAccountSecurity.securityE2EEncryptionResetKeyButton.click();
await expect(page.locator('role=button[name="Login"]')).toBeVisible();
await expect(anotherClientPage.locator('role=button[name="Login"]')).toBeVisible();
});
});

View File

@@ -0,0 +1,100 @@
import { faker } from '@faker-js/faker';
import type { APIRequestContext } from '@playwright/test';
import { BASE_API_URL, DEFAULT_USER_CREDENTIALS } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { HomeChannel } from '../page-objects';
import { CreateE2EEChannel } from '../page-objects/fragments/e2ee';
import { deletePrivateRoomsByName } from '../utils';
import { preserveSettings } from '../utils/preserveSettings';
import { test, expect } from '../utils/test';
const settingsList = [
'E2E_Enable',
'E2E_Allow_Unencrypted_Messages',
'E2E_Enabled_Default_DirectRooms',
'E2E_Enabled_Default_PrivateRooms',
];
preserveSettings(settingsList);
const sendEncryptedMessage = async (request: APIRequestContext, rid: string, encryptedMsg: string) => {
return request.post(`${BASE_API_URL}/chat.sendMessage`, {
headers: {
'X-Auth-Token': Users.userE2EE.data.loginToken,
'X-User-Id': Users.userE2EE.data._id,
},
data: {
message: {
rid,
msg: encryptedMsg,
t: 'e2e',
},
},
});
};
test.describe('E2EE Legacy Format', () => {
const createdChannels: string[] = [];
let poHomeChannel: HomeChannel;
let createE2EEChannel: CreateE2EEChannel;
test.use({ storageState: Users.userE2EE.state });
test.beforeAll(async ({ api }) => {
await api.post('/settings/E2E_Enable', { value: true });
await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: true });
await api.post('/settings/E2E_Enabled_Default_DirectRooms', { value: false });
await api.post('/settings/E2E_Enabled_Default_PrivateRooms', { value: false });
await api.post('/im.delete', { username: 'user2' });
});
test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);
createE2EEChannel = new CreateE2EEChannel(page);
await poHomeChannel.goto();
});
test.afterAll(async () => {
await deletePrivateRoomsByName(
{ username: Users.userE2EE.data.username, password: DEFAULT_USER_CREDENTIALS.password },
createdChannels,
);
});
test('legacy expect create a private channel encrypted and send an encrypted message', async ({ page, request }) => {
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(page.getByTitle('Encrypted')).toBeVisible();
// TODO: Fix this flakiness
await expect(page.getByRole('button', { name: 'Send' })).toBeVisible();
const rid = (await page.locator('[data-qa-rc-room]').getAttribute('data-qa-rc-room')) || '';
expect(rid).toBeTruthy();
const kid = '32c9e7917b78';
const encryptedKey =
'ibtLAKG9zcQ/NTp+86nVelUjewPbPNW+EC+eagVPVVlbxvWNXkgltrBQB4gDao1Fp6fHUibQB3dirJ4rzy7CViww0o4QjAwPPQMIxZ9DLJhjKnu6bkkOp6Z0/a9g/8Wf/cvP9/bp7tUt7Et4XMmJwIe5iyJZ35lsyduLc8V+YyK8sJiGf4BRagJoBr8xEBgqBWqg6Vwn3qtbbiTs65PqErbaUmSM3Hn6tfkcS6ukLG/DbptW1B9U66IX3fQesj50zWZiJyvxOoxDeHRH9UEStyv9SP8nrFjEKM3TDiakBeDxja6LoN8l3CjP9K/5eg25YqANZAQjlwaCaeTTHndTgQ==';
const encryptedMessage =
'3JpM8aOVludqIRzx+DOqjEU9Mj3NUWb+/GLRl7sdkvTtCMChH1LBjMjJJvVJ6Rlw4dI8BYFftZWiCOiR7TPwriCoSPiZ7dY5C4H2q8MVSdR95ZiyG7eWQ5j5/rxzAYsSWDA9LkumW8JBb+WQ1hD9JMfQd4IXtlFMnaDgEhZhe/s=';
await page.evaluate(
async ({ rid, kid, encryptedKey }) => {
// eslint-disable-next-line import-x/no-absolute-path
const { e2e } = require('/client/lib/e2ee/rocketchat.e2e.ts') as typeof import('../../../client/lib/e2ee/rocketchat.e2e');
const room = await e2e.getInstanceByRoomId(rid);
await room?.importGroupKey(kid + encryptedKey);
},
{ rid, kid, encryptedKey },
);
await sendEncryptedMessage(request, rid, kid + encryptedMessage);
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText('world');
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
});
});

View File

@@ -0,0 +1,350 @@
import { faker } from '@faker-js/faker';
import { resetOwnE2EKey } from './resetOwnE2EKey';
import { ADMIN_CREDENTIALS } from '../config/constants';
import injectInitialData from '../fixtures/inject-initial-data';
import { Users, storeState, restoreState } from '../fixtures/userStates';
import { AccountSecurity, HomeChannel } from '../page-objects';
import { setupE2EEPassword } from './setupE2EEPassword';
import { Authenticated } from '../page-objects/auth';
import { Navbar } from '../page-objects/fragments';
import { CreateE2EEChannel, E2EEKeyDecodeFailureBanner, EnterE2EEPasswordBanner } from '../page-objects/fragments/e2ee';
import { EnterE2EEPasswordModal, ResetE2EEPasswordModal } from '../page-objects/fragments/modals';
import { LoginPage } from '../page-objects/login';
import { deletePrivateRoomsByName } from '../utils';
import { preserveSettings } from '../utils/preserveSettings';
import { test, expect } from '../utils/test';
const settingsList = [
'E2E_Enable',
'E2E_Allow_Unencrypted_Messages',
'E2E_Enabled_Default_DirectRooms',
'E2E_Enabled_Default_PrivateRooms',
];
const originalSettings = preserveSettings(settingsList);
test.describe('E2EE Passphrase Management - Initial Setup', () => {
test.use({ storageState: Users.admin.state });
test.beforeAll(async ({ api }) => {
await api.post('/settings/E2E_Enable', { value: true });
await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: true });
await api.post('/settings/E2E_Enabled_Default_DirectRooms', { value: false });
await api.post('/settings/E2E_Enabled_Default_PrivateRooms', { value: false });
});
test.afterAll(async ({ api }) => {
await api.post('/settings/E2E_Enable', { value: originalSettings.E2E_Enable });
await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: originalSettings.E2E_Allow_Unencrypted_Messages });
await api.post('/settings/E2E_Enabled_Default_DirectRooms', { value: originalSettings.E2E_Enabled_Default_DirectRooms });
await api.post('/settings/E2E_Enabled_Default_PrivateRooms', { value: originalSettings.E2E_Enabled_Default_PrivateRooms });
});
test.describe('Generate', () => {
test.beforeEach(async ({ page }) => {
const loginPage = new LoginPage(page);
await expect(await resetOwnE2EKey(ADMIN_CREDENTIALS)).toBeOK();
await loginPage.goto();
await loginPage.loginByUserState(Users.admin);
});
test('expect the randomly generated password to work', async ({ page }) => {
const loginPage = new LoginPage(page);
const enterE2EEPasswordBanner = new EnterE2EEPasswordBanner(page);
const enterE2EEPasswordModal = new EnterE2EEPasswordModal(page);
const e2EEKeyDecodeFailureBanner = new E2EEKeyDecodeFailureBanner(page);
const navbar = new Navbar(page);
const password = await setupE2EEPassword(page);
// Log out
await navbar.logout();
// Login again
await loginPage.loginByUserState(Users.admin);
// Enter the saved password
await enterE2EEPasswordBanner.click();
await enterE2EEPasswordModal.enterPassword(password);
// No error banner
await e2EEKeyDecodeFailureBanner.expectToNotBeVisible();
});
test('expect to manually reset the password', async ({ page }) => {
const accountSecurityPage = new AccountSecurity(page);
const loginPage = new LoginPage(page);
// Reset the E2EE key to start the flow from the beginning
await accountSecurityPage.goto();
await accountSecurityPage.resetE2EEPassword();
await loginPage.loginByUserState(Users.admin);
});
test('should reset e2e password from the modal', async ({ page }) => {
const navbar = new Navbar(page);
const loginPage = new LoginPage(page);
const enterE2EEPasswordBanner = new EnterE2EEPasswordBanner(page);
const enterE2EEPasswordModal = new EnterE2EEPasswordModal(page);
const resetE2EEPasswordModal = new ResetE2EEPasswordModal(page);
await setupE2EEPassword(page);
// Logout
await navbar.logout();
// Login again
await loginPage.loginByUserState(Users.admin);
// Reset E2EE password
await enterE2EEPasswordBanner.click();
await enterE2EEPasswordModal.forgotPassword();
await resetE2EEPasswordModal.confirmReset();
// restore login
await loginPage.loginByUserState(Users.admin);
});
test('expect to manually set a new password', async ({ page }) => {
const accountSecurityPage = new AccountSecurity(page);
const loginPage = new LoginPage(page);
const enterE2EEPasswordBanner = new EnterE2EEPasswordBanner(page);
const enterE2EEPasswordModal = new EnterE2EEPasswordModal(page);
const e2EEKeyDecodeFailureBanner = new E2EEKeyDecodeFailureBanner(page);
const navbar = new Navbar(page);
const newPassword = faker.internet.password({
length: 30,
prefix:
faker.string.alpha({ casing: 'lower' }) +
faker.string.alpha({ casing: 'upper' }) +
faker.string.numeric() +
faker.string.symbol(),
});
await setupE2EEPassword(page);
// Set a new password
await accountSecurityPage.goto();
await accountSecurityPage.setE2EEPassword(newPassword);
// Log out
await navbar.logout();
// Login again
await loginPage.loginByUserState(Users.admin);
// Enter the saved password
await enterE2EEPasswordBanner.click();
await enterE2EEPasswordModal.enterPassword(newPassword);
// No error banner
await e2EEKeyDecodeFailureBanner.expectToNotBeVisible();
});
});
test.describe('Recovery', () => {
test.use({ storageState: Users.userE2EE.state });
test('expect to recover the keys using the recovery key', async ({ page }) => {
await test.step('Recover the keys', async () => {
await page.goto('/home');
await injectInitialData();
await restoreState(page, Users.userE2EE);
const navbar = new Navbar(page);
await navbar.logout();
const loginPage = new LoginPage(page);
await loginPage.loginByUserState(Users.userE2EE, { except: ['private_key', 'public_key'] });
const enterE2EEPasswordBanner = new EnterE2EEPasswordBanner(page);
const enterE2EEPasswordModal = new EnterE2EEPasswordModal(page);
const e2EEKeyDecodeFailureBanner = new E2EEKeyDecodeFailureBanner(page);
await enterE2EEPasswordBanner.click();
await enterE2EEPasswordModal.enterPassword('minus mobile dexter forest elvis');
await e2EEKeyDecodeFailureBanner.expectToNotBeVisible();
});
});
});
});
test.use({ storageState: Users.admin.state });
const roomSetupSettingsList = ['E2E_Enable', 'E2E_Allow_Unencrypted_Messages'];
test.describe.serial('E2EE Passphrase Management - Room Setup States', () => {
const createdChannels: string[] = [];
let poAccountSecurity: AccountSecurity;
let poHomeChannel: HomeChannel;
let createE2EEChannel: CreateE2EEChannel;
let e2eePassword: string;
preserveSettings(roomSetupSettingsList);
test.beforeEach(async ({ page }) => {
poAccountSecurity = new AccountSecurity(page);
poHomeChannel = new HomeChannel(page);
createE2EEChannel = new CreateE2EEChannel(page);
});
test.beforeAll(async ({ api }) => {
await api.post('/settings/E2E_Enable', { value: true });
await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: false });
});
test.afterEach(async ({ api }) => {
await api.recreateContext();
});
test.afterAll(async () => {
await deletePrivateRoomsByName(ADMIN_CREDENTIALS, createdChannels);
});
test('expect save password state on encrypted room', async ({ page }) => {
await poAccountSecurity.goto();
await poAccountSecurity.securityE2EEncryptionSection.click();
await poAccountSecurity.securityE2EEncryptionResetKeyButton.click();
await page.locator('role=button[name="Login"]').waitFor();
await injectInitialData();
await restoreState(page, Users.admin);
await new Authenticated(page).goto();
await expect(poHomeChannel.bannerSaveEncryptionPassword).toBeVisible();
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon.first()).toBeVisible();
await expect(poHomeChannel.btnRoomSaveE2EEPassword).toBeVisible();
await poHomeChannel.roomToolbar.btnDisableE2EEncryption.waitFor();
await expect(poHomeChannel.roomToolbar.btnDisableE2EEncryption).toBeVisible();
await expect(poHomeChannel.roomToolbar.btnMembers).toBeVisible();
await expect(poHomeChannel.roomToolbar.btnRoomInfo).toBeVisible();
await expect(poHomeChannel.composer.inputMessage).not.toBeVisible();
await poHomeChannel.btnRoomSaveE2EEPassword.click();
e2eePassword = (await page.evaluate(() => localStorage.getItem('e2e.randomPassword'))) || 'undefined';
await expect(poHomeChannel.dialogSaveE2EEPassword).toBeVisible();
await expect(poHomeChannel.dialogSaveE2EEPassword).toContainText(e2eePassword);
await poHomeChannel.btnSavedMyPassword.click();
await poHomeChannel.composer.inputMessage.waitFor();
await poHomeChannel.content.sendMessage('hello world');
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText('hello world');
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
});
test('expect enter password state on encrypted room', async ({ page }) => {
const enterE2EEPasswordModal = new EnterE2EEPasswordModal(page);
await poHomeChannel.goto();
// Logout to remove e2ee keys
await poHomeChannel.navbar.logout();
await injectInitialData();
await restoreState(page, Users.admin, { except: ['private_key', 'public_key'] });
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon.first()).toBeVisible();
await poHomeChannel.btnRoomEnterE2EEPassword.waitFor();
await expect(poHomeChannel.btnRoomEnterE2EEPassword).toBeVisible();
await poHomeChannel.roomToolbar.btnDisableE2EEncryption.waitFor();
await expect(poHomeChannel.roomToolbar.btnDisableE2EEncryption).toBeVisible();
await expect(poHomeChannel.roomToolbar.btnMembers).toBeVisible();
await expect(poHomeChannel.roomToolbar.btnRoomInfo).toBeVisible();
await expect(poHomeChannel.composer.inputMessage).not.toBeVisible();
await poHomeChannel.btnRoomEnterE2EEPassword.click();
await enterE2EEPasswordModal.enterPassword(e2eePassword);
await expect(poHomeChannel.bannerEnterE2EEPassword).not.toBeVisible();
await poHomeChannel.composer.inputMessage.waitFor();
// For E2EE to complete init setup
await page.waitForTimeout(300);
await poHomeChannel.content.sendMessage('hello world');
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText('hello world');
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
await storeState(page, Users.admin);
});
test('expect waiting for room keys state', async ({ page }) => {
await poHomeChannel.goto();
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon.first()).toBeVisible();
await poHomeChannel.content.sendMessage('hello world');
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText('hello world');
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
await poHomeChannel.navbar.btnUserMenu.click();
await poHomeChannel.navbar.getUserProfileMenuOption('Profile').click();
await poAccountSecurity.sidebar.linkSecurity.click();
await poAccountSecurity.securityE2EEncryptionSection.click();
await poAccountSecurity.securityE2EEncryptionResetKeyButton.click();
await page.locator('role=button[name="Login"]').waitFor();
await page.reload();
await page.locator('role=button[name="Login"]').waitFor();
await injectInitialData();
await restoreState(page, Users.admin);
await poHomeChannel.navbar.typeSearch(channelName);
await poHomeChannel.navbar.getSearchRoomByName(channelName).click();
await poHomeChannel.btnRoomSaveE2EEPassword.click();
await poHomeChannel.btnSavedMyPassword.click();
await expect(poHomeChannel.composer.inputMessage).not.toBeVisible();
await expect(page.locator('.rcx-states__title')).toContainText('Check back later');
await poHomeChannel.roomToolbar.btnDisableE2EEncryption.waitFor();
await expect(poHomeChannel.roomToolbar.btnDisableE2EEncryption).toBeVisible();
await expect(poHomeChannel.roomToolbar.btnMembers).toBeVisible();
await expect(poHomeChannel.roomToolbar.btnRoomInfo).toBeVisible();
});
});

View File

@@ -0,0 +1,90 @@
import { faker } from '@faker-js/faker';
import { resetOwnE2EKey } from './resetOwnE2EKey';
import { ADMIN_CREDENTIALS } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { EncryptedRoomPage } from '../page-objects/encrypted-room';
import { CreateE2EEChannel } from '../page-objects/fragments/e2ee';
import { ExportMessagesFlexTab } from '../page-objects/fragments/flextabs';
import { LoginPage } from '../page-objects/login';
import { deletePrivateRoomsByName } from '../utils';
import { preserveSettings } from '../utils/preserveSettings';
import { test, expect } from '../utils/test';
const settingsList = [
'E2E_Enable',
'E2E_Allow_Unencrypted_Messages',
'E2E_Enabled_Default_DirectRooms',
'E2E_Enabled_Default_PrivateRooms',
];
preserveSettings(settingsList);
test.describe('E2EE PDF Export', () => {
const createdChannels: string[] = [];
let createE2EEChannel: CreateE2EEChannel;
test.use({ storageState: Users.admin.state });
test.beforeAll(async ({ api }) => {
await api.post('/settings/E2E_Enable', { value: true });
await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: true });
await api.post('/settings/E2E_Enabled_Default_DirectRooms', { value: false });
await api.post('/settings/E2E_Enabled_Default_PrivateRooms', { value: false });
// Note: Using admin user, so no need for userE2EE cleanup
});
test.beforeEach(async ({ page }) => {
const loginPage = new LoginPage(page);
await expect(await resetOwnE2EKey(ADMIN_CREDENTIALS)).toBeOK();
await loginPage.goto();
await loginPage.loginByUserState(Users.admin);
createE2EEChannel = new CreateE2EEChannel(page);
});
test.afterAll(async () => {
await deletePrivateRoomsByName(ADMIN_CREDENTIALS, createdChannels);
});
test('should display only the download file method when exporting messages in an e2ee room', async ({ page }) => {
const encryptedRoomPage = new EncryptedRoomPage(page);
const exportMessagesTab = new ExportMessagesFlexTab(page);
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(encryptedRoomPage.encryptedRoomHeaderIcon).toBeVisible();
await encryptedRoomPage.showExportMessagesTab();
await expect(exportMessagesTab.method).toContainClass('disabled'); // FIXME: looks like the component have an a11y issue
await expect(exportMessagesTab.method).toHaveAccessibleName('Download file Method');
});
test('should allow exporting messages as PDF in an encrypted room', async ({ page }) => {
const encryptedRoomPage = new EncryptedRoomPage(page);
const exportMessagesTab = new ExportMessagesFlexTab(page);
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(encryptedRoomPage.encryptedRoomHeaderIcon).toBeVisible();
await encryptedRoomPage.sendMessage('This is a message to export as PDF.');
await encryptedRoomPage.showExportMessagesTab();
await expect(exportMessagesTab.method).toHaveAccessibleName('Download file Method');
// Select Output format as PDF
await exportMessagesTab.setOutputFormat('PDF');
// select messages to be exported
await exportMessagesTab.selectAllMessages();
// Wait for download event and match format
const download = await exportMessagesTab.downloadMessages();
expect(download.suggestedFilename()).toMatch(/\.pdf$/);
});
});

View File

@@ -0,0 +1,111 @@
import { faker } from '@faker-js/faker';
import { DEFAULT_USER_CREDENTIALS, IS_EE } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { HomeChannel } from '../page-objects';
import { CreateE2EEChannel } from '../page-objects/fragments/e2ee';
import { deletePrivateRoomsByName } from '../utils';
import { preserveSettings } from '../utils/preserveSettings';
import { test, expect } from '../utils/test';
const settingsList = [
'E2E_Enable',
'E2E_Allow_Unencrypted_Messages',
'E2E_Enabled_Default_DirectRooms',
'E2E_Enabled_Default_PrivateRooms',
];
preserveSettings(settingsList);
test.describe('E2EE Server Settings', () => {
const createdChannels: string[] = [];
let poHomeChannel: HomeChannel;
let createE2EEChannel: CreateE2EEChannel;
test.use({ storageState: Users.userE2EE.state });
test.beforeAll(async ({ api }) => {
await api.post('/settings/E2E_Enable', { value: true });
await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: true });
await api.post('/settings/E2E_Enabled_Default_DirectRooms', { value: false });
await api.post('/settings/E2E_Enabled_Default_PrivateRooms', { value: false });
await api.post('/im.delete', { username: 'user2' });
});
test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);
createE2EEChannel = new CreateE2EEChannel(page);
await poHomeChannel.goto();
});
test.afterAll(async () => {
await deletePrivateRoomsByName(
{ username: Users.userE2EE.data.username, password: DEFAULT_USER_CREDENTIALS.password },
createdChannels,
);
});
test('expect slash commands to be enabled in an e2ee room', async ({ page }) => {
test.skip(!IS_EE, 'Premium Only');
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();
await poHomeChannel.content.sendMessage('This is an encrypted message.');
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText('This is an encrypted message.');
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
await page.locator('[name="msg"]').type('/');
await expect(page.locator('#popup-item-contextualbar')).not.toHaveClass(/disabled/);
await page.locator('[name="msg"]').clear();
await poHomeChannel.content.dispatchSlashCommand('/contextualbar');
await expect(poHomeChannel.btnContextualbarClose).toBeVisible();
await poHomeChannel.btnContextualbarClose.click();
await expect(poHomeChannel.btnContextualbarClose).toBeHidden();
});
test.describe('un-encrypted messages not allowed in e2ee rooms', () => {
test.skip(!IS_EE, 'Premium Only');
let poHomeChannel: HomeChannel;
let createE2EEChannel: CreateE2EEChannel;
test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);
createE2EEChannel = new CreateE2EEChannel(page);
await poHomeChannel.goto();
});
test.beforeAll(async ({ api }) => {
await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: false });
});
test.afterAll(async ({ api }) => {
await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: true });
});
test('expect slash commands to be disabled in an e2ee room', async ({ page }) => {
const channelName = faker.string.uuid();
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();
await poHomeChannel.content.sendMessage('This is an encrypted message.');
await expect(poHomeChannel.content.lastUserMessageBody).toHaveText('This is an encrypted message.');
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();
await page.locator('[name="msg"]').pressSequentially('/');
await expect(page.locator('#popup-item-contextualbar')).toHaveClass(/disabled/);
});
});
});

View File

@@ -0,0 +1,28 @@
import { request as baseRequest } from '@playwright/test';
import { BASE_API_URL } from '../config/constants';
type Credentials = {
password: string;
username?: string;
email?: string;
};
export const resetOwnE2EKey = async (credentials: Credentials) => {
const request = await baseRequest.newContext();
try {
const loginResponse = await request.post(`${BASE_API_URL}/login`, { data: credentials });
const { data } = await loginResponse.json();
return await request.post(`${BASE_API_URL}/users.resetE2EKey`, {
data: { userId: data.userId },
headers: {
'X-Auth-Token': data.authToken,
'X-User-Id': data.userId,
},
});
} finally {
await request.dispose();
}
};

View File

@@ -0,0 +1,19 @@
import type { Page } from '@playwright/test';
import { SaveE2EEPasswordBanner } from '../page-objects/fragments/e2ee';
import { SaveE2EEPasswordModal } from '../page-objects/fragments/modals';
/**
* Click the banner to open the dialog to save the generated password
*/
export const setupE2EEPassword = async (page: Page) => {
const saveE2EEPasswordBanner = new SaveE2EEPasswordBanner(page);
const saveE2EEPasswordModal = new SaveE2EEPasswordModal(page);
await saveE2EEPasswordBanner.click();
const password = await saveE2EEPasswordModal.getPassword();
await saveE2EEPasswordModal.confirm();
await saveE2EEPasswordBanner.waitForDisappearance();
return password;
};