Skip to content

Commit 03cabfe

Browse files
authored
Merge pull request #174 from tchapgouv/111-disable-encrypted-switch
111 - disable encryption and guest users button switch
2 parents f7f6104 + f70e3eb commit 03cabfe

File tree

3 files changed

+92
-74
lines changed

3 files changed

+92
-74
lines changed

cypress/e2e/room-access-settings/room-access-settings.spec.ts

Lines changed: 52 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
/// <reference types="cypress" />
22

33
import RoomUtils from "../utils/room-utils";
4-
import Chainable = Cypress.Chainable;
5-
6-
74

85
describe("Check room access settings", () => {
96
const homeserverUrl = Cypress.env('E2E_TEST_USER_HOMESERVER_URL');
107
const email = Cypress.env('E2E_TEST_USER_EMAIL');
118
const password = Cypress.env('E2E_TEST_USER_PASSWORD');
12-
const homeserverShortname = Cypress.env('E2E_TEST_USER_HOMESERVER_SHORT');
139
const today = new Date().toISOString().slice(0, 10).replace(/-/g, '');
1410

1511
beforeEach(() => {
@@ -21,48 +17,73 @@ describe("Check room access settings", () => {
2117
});
2218

2319
it("creates a public room and check access settings", () => {
24-
const roomName = "test/"+today+"/public_room_check_access_settings";
20+
const roomName = "test/"+today+"/public_room_check_access_settings";
21+
22+
RoomUtils.createPublicRoom(roomName)
23+
.then((roomId) => {
24+
RoomUtils.openRoomAccessSettings(roomName);
25+
26+
//assert
27+
cy.get('#joinRule-invite-description').should('not.exist');
28+
cy.get('#joinRule-restricted-description').should('not.exist');
29+
cy.get('#joinRule-public-description').should('exist');
2530

26-
RoomUtils.createPublicRoom(roomName);
31+
//encryption switch should be off and disabled
32+
cy.contains(".mx_SettingsFlag", /^Chiffré$/).within(() => {
33+
cy.get('.mx_AccessibleButton').should('have.attr', 'aria-checked', 'false');
34+
cy.get('.mx_AccessibleButton').should('have.attr', 'aria-disabled', 'true');
35+
});
2736

28-
openRoomAccessSettings();
37+
//should not show more settings, nor invite guests
38+
cy.contains('.mx_SettingsTab_section', /^Afficher les paramètres avancés$/).should('not.exist');
39+
cy.contains('.mx_SettingsFlag', /^Activer laccès visiteur$/).should('not.exist');
2940

30-
//assert
31-
cy.get('#joinRule-invite-description').should('not.exist');
32-
cy.get('#joinRule-restricted-description').should('not.exist');
33-
cy.get('#joinRule-public-description').should('exist');
41+
cy.leaveRoom(roomId);
42+
});
3443
});
3544

3645
it("creates a private room and check access settings", () => {
37-
const roomName = "test/"+today+"/private_room_check_access_settings";
46+
const roomName = "test/"+today+"/private_room_check_access_settings";
3847

39-
RoomUtils.createPrivateRoom(roomName);
48+
RoomUtils.createPrivateRoom(roomName)
49+
.then((roomId) => {
50+
RoomUtils.openRoomAccessSettings(roomName);
4051

41-
openRoomAccessSettings();
52+
//assert
53+
cy.get('#joinRule-invite-description').should('exist');
54+
cy.get('#joinRule-restricted-description').should('not.exist');
55+
cy.get('#joinRule-public-description').should('not.exist');
4256

43-
//assert
44-
cy.get('#joinRule-invite-description').should('exist');
45-
cy.get('#joinRule-restricted-description').should('not.exist');
46-
cy.get('#joinRule-public-description').should('not.exist');
57+
//encryption switch should be on
58+
cy.contains(".mx_SettingsFlag", /^Chiffré$/).within(() => {
59+
cy.get('.mx_AccessibleButton').should('have.attr', 'aria-checked', 'true');
60+
cy.get('.mx_AccessibleButton').should('have.attr', 'aria-disabled', 'true');
61+
});
62+
63+
cy.leaveRoom(roomId);
64+
});
4765
});
4866

4967
it("creates a private room with external and check access settings", () => {
50-
const roomName = "test/"+today+"/private_room_check_access_settings";
68+
const roomName = "test/"+today+"/external_room_check_access_settings";
69+
70+
RoomUtils.createPrivateWithExternalRoom(roomName)
71+
.then((roomId) => {
72+
RoomUtils.openRoomAccessSettings(roomName);
5173

52-
RoomUtils.createPrivateRoomWithExternal(roomName);
74+
//assert
75+
cy.get('#joinRule-invite-description').should('exist');
76+
cy.get('#joinRule-restricted-description').should('not.exist');
77+
cy.get('#joinRule-public-description').should('not.exist');
5378

54-
openRoomAccessSettings();
79+
//encryption switch should be on
80+
cy.contains(".mx_SettingsFlag", /^Chiffré$/).within(() => {
81+
cy.get('.mx_AccessibleButton').should('have.attr', 'aria-checked', 'true');
82+
cy.get('.mx_AccessibleButton').should('have.attr', 'aria-disabled', 'true');
83+
});
5584

56-
//assert
57-
cy.get('#joinRule-invite-description').should('exist');
58-
cy.get('#joinRule-restricted-description').should('not.exist');
59-
cy.get('#joinRule-public-description').should('not.exist');
85+
cy.leaveRoom(roomId);
86+
});
6087
});
6188
});
6289

63-
64-
function openRoomAccessSettings(){
65-
cy.get('.mx_RoomHeader_chevron').click();
66-
cy.get('[aria-label="Paramètres"] > .mx_IconizedContextMenu_label').click();
67-
cy.get('[data-testid="settings-tab-ROOM_SECURITY_TAB"] > .mx_TabbedView_tabLabel_text').click();
68-
}

cypress/e2e/utils/room-utils.ts

Lines changed: 14 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,22 @@
11
import Chainable = Cypress.Chainable;
2-
2+
import TchapCreateRoom from '../../../src/lib/createTchapRoom';
3+
import { TchapRoomType } from '../../../src/@types/tchap';
34
export default class RoomUtils {
4-
5-
static openCreateRoomDialog(): Chainable<JQuery<HTMLElement>> {
6-
const addRoomLabel = "Ajouter un salon";
7-
const newRoomLabel = "Nouveau salon";
8-
cy.get(`[aria-label="${addRoomLabel}"]`).click();
9-
cy.get(`.mx_ContextualMenu [aria-label="${newRoomLabel}"]`).click();
10-
return cy.get(".mx_Dialog");
5+
static createPublicRoom(roomName: string): Chainable<string> {
6+
return cy.createRoom(TchapCreateRoom.roomCreateOptions(roomName, TchapRoomType.Forum, false).createOpts);
117
}
12-
13-
14-
static createPrivateRoom(roomName: string) {
15-
RoomUtils.openCreateRoomDialog().within(() => {
16-
// Fill name
17-
const nameLabel = "Nom";
18-
cy.get(`[label="${nameLabel}"]`).type(roomName);
19-
// Submit
20-
cy.startMeasuring("from-submit-to-room");
21-
cy.get(".mx_Dialog_primary").click();
22-
});
8+
static createPrivateRoom(roomName: string): Chainable<string> {
9+
return cy.createRoom(TchapCreateRoom.roomCreateOptions(roomName, TchapRoomType.Private, false).createOpts);
2310
}
24-
25-
static createPublicRoom(roomName: string) {
26-
RoomUtils.openCreateRoomDialog().within(() => {
27-
// Fill name
28-
const nameLabel = "Nom";
29-
cy.get(`[label="${nameLabel}"]`).type(roomName);
30-
// Change room to public
31-
cy.get(".tc_TchapRoomTypeSelector_forum").click();
32-
// Submit
33-
cy.startMeasuring("from-submit-to-room");
34-
cy.get(".mx_Dialog_primary").click();
35-
});
11+
static createPrivateWithExternalRoom(roomName: string): Chainable<string> {
12+
return cy.createRoom(TchapCreateRoom.roomCreateOptions(roomName, TchapRoomType.External, false).createOpts);
3613
}
37-
38-
static createPrivateRoomWithExternal(roomName: string) {
39-
RoomUtils.openCreateRoomDialog().within(() => {
40-
// Fill name
41-
const nameLabel = "Nom";
42-
cy.get(`[label="${nameLabel}"]`).type(roomName);
43-
// Change room to public
44-
cy.get(".tc_TchapRoomTypeSelector_external").click();
45-
// Submit
46-
cy.startMeasuring("from-submit-to-room");
47-
cy.get(".mx_Dialog_primary").click();
48-
});
14+
static openRoomAccessSettings(roomName: string) {
15+
//open room
16+
cy.get('[aria-label="'+roomName+'"]').click();
17+
cy.get('.mx_RoomHeader_chevron').click();
18+
cy.get('[aria-label="Paramètres"] > .mx_IconizedContextMenu_label').click();
19+
cy.get('[data-testid="settings-tab-ROOM_SECURITY_TAB"] > .mx_TabbedView_tabLabel_text').click();
4920
}
5021
}
5122

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git a/node_modules/matrix-react-sdk/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx b/node_modules/matrix-react-sdk/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx
2+
index 361b82b..d533369 100644
3+
--- a/node_modules/matrix-react-sdk/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx
4+
+++ b/node_modules/matrix-react-sdk/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx
5+
@@ -375,7 +375,9 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
6+
const room = client.getRoom(this.props.roomId);
7+
const isEncrypted = this.state.encrypted;
8+
const hasEncryptionPermission = room.currentState.mayClientSendStateEvent(EventType.RoomEncryption, client);
9+
- const canEnableEncryption = !isEncrypted && hasEncryptionPermission;
10+
+ // :TCHAP: does not allow to change encryption
11+
+ // const canEnableEncryption = !isEncrypted && hasEncryptionPermission;
12+
+ const canEnableEncryption = false;
13+
14+
let encryptionSettings = null;
15+
if (isEncrypted && SettingsStore.isEnabled("blacklistUnverifiedDevices")) {
16+
@@ -390,7 +392,9 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
17+
const historySection = this.renderHistory();
18+
19+
let advanced;
20+
- if (room.getJoinRule() === JoinRule.Public) {
21+
+ // :TCHAP: does not show any advanced options for public room (guest access switch)
22+
+ // if (room.getJoinRule() === JoinRule.Public) {
23+
+ if (false) {
24+
advanced = (
25+
<div className="mx_SettingsTab_section">
26+
<AccessibleButton

0 commit comments

Comments
 (0)