Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression: Users shouldn't be able to create encrypted rooms before setting up their E2E keys #33709

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ import type { ComponentProps, ReactElement } from 'react';
import React, { useEffect, useMemo } from 'react';
import { useForm, Controller } from 'react-hook-form';

import { E2EEState } from '../../../../app/e2e/client/E2EEState';
import UserAutoCompleteMultipleFederated from '../../../components/UserAutoCompleteMultiple/UserAutoCompleteMultipleFederated';
import { useHasLicenseModule } from '../../../hooks/useHasLicenseModule';
import { goToRoomById } from '../../../lib/utils/goToRoomById';
import { useE2EEState } from '../../../views/room/hooks/useE2EEState';
import { useEncryptedRoomDescription } from '../hooks/useEncryptedRoomDescription';

type CreateChannelModalProps = {
Expand Down Expand Up @@ -67,6 +69,7 @@ const CreateChannelModal = ({ teamId = '', mainRoom, onClose, reload }: CreateCh
const t = useTranslation();
const canSetReadOnly = usePermissionWithScopedRoles('set-readonly', ['owner']);
const e2eEnabled = useSetting('E2E_Enable');
const e2eeState = useE2EEState();
const namesValidation = useSetting('UTF8_Channel_Names_Validation');
const allowSpecialNames = useSetting('UI_Allow_room_names_with_special_chars');
const federationEnabled = useSetting<boolean>('Federation_Matrix_enabled') || false;
Expand All @@ -75,6 +78,7 @@ const CreateChannelModal = ({ teamId = '', mainRoom, onClose, reload }: CreateCh
const canCreateChannel = usePermission('create-c');
const canCreateGroup = usePermission('create-p');
const getEncryptedHint = useEncryptedRoomDescription('channel');
const isE2EEReady = e2eeState === E2EEState.READY || e2eeState === E2EEState.SAVE_PASSWORD;

const channelNameRegex = useMemo(() => new RegExp(`^${namesValidation}$`), [namesValidation]);
const federatedModule = useHasLicenseModule('federation');
Expand Down Expand Up @@ -190,8 +194,8 @@ const CreateChannelModal = ({ teamId = '', mainRoom, onClose, reload }: CreateCh
};

const e2eDisabled = useMemo<boolean>(
() => !isPrivate || broadcast || Boolean(!e2eEnabled) || Boolean(e2eEnabledForPrivateByDefault),
[e2eEnabled, e2eEnabledForPrivateByDefault, broadcast, isPrivate],
() => !isPrivate || broadcast || Boolean(!e2eEnabled) || Boolean(e2eEnabledForPrivateByDefault) || !isE2EEReady,
[e2eEnabled, e2eEnabledForPrivateByDefault, broadcast, isPrivate, isE2EEReady],
);

const createChannelFormId = useUniqueId();
Expand Down
24 changes: 24 additions & 0 deletions apps/meteor/tests/e2e/e2e-encryption.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,20 @@ test.describe.serial('e2e-encryption initial setup', () => {
await page.locator('role=button[name="Login"]').waitFor();

await injectInitialData();
});

test('expect encrypted room creation be disabled when E2EE is not setup', async ({ page }) => {
await restoreState(page, Users.admin);
await poAccountProfile.btnClose.click();

await poHomeChannel.sidenav.openNewByLabel('Channel');
await poHomeChannel.sidenav.inputChannelName.fill(faker.string.uuid());
await poHomeChannel.sidenav.advancedSettingsAccordion.click();

await expect(poHomeChannel.sidenav.checkboxEncryption).toBeDisabled();
});

test('expect user to enter a valid e2ee password', async ({ page }) => {
await restoreState(page, Users.admin);

await page.locator('role=banner >> text="Enter your E2E password"').click();
Expand All @@ -80,6 +93,17 @@ test.describe.serial('e2e-encryption initial setup', () => {
await storeState(page, Users.admin);
});

test('expect encrypted room creation be enabled when E2EE is setup', async ({ page }) => {
await restoreState(page, Users.admin);
await poAccountProfile.btnClose.click();

await poHomeChannel.sidenav.openNewByLabel('Channel');
await poHomeChannel.sidenav.inputChannelName.fill(faker.string.uuid());
await poHomeChannel.sidenav.advancedSettingsAccordion.click();

await expect(poHomeChannel.sidenav.checkboxEncryption).not.toBeDisabled();
});

test('expect change the e2ee password', async ({ page }) => {
// Change the password to a new one and test it
const newPassword = 'new password';
Expand Down
Loading