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
218 lines
8.7 KiB
TypeScript
218 lines
8.7 KiB
TypeScript
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.');
|
|
});
|
|
});
|
|
});
|