[FIX] E2EE password hiding automatically (#2972)

* [FIX] E2EE password hiding automatically

* add e2e test

* fixed hiding banner

* move e2e tests to 01-e2eencryption

* remove console.log

* Fix tests

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Gung Wah 2021-04-02 03:27:46 +08:00 committed by GitHub
parent 632751898c
commit 704e071275
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 106 additions and 13 deletions

View File

@ -69,7 +69,8 @@ const handleEncryptionInit = function* handleEncryptionInit() {
storedPublicKey = EJSON.parse(storedPublicKey);
}
if (storedPublicKey && storedPrivateKey) {
if (storedPublicKey && storedPrivateKey && !storedRandomPassword) {
// Persist these keys
yield Encryption.persistKeys(server, storedPublicKey, storedPrivateKey);
yield put(encryptionSet(true));

View File

@ -1,9 +1,9 @@
const random = require('./helpers/random');
const value = random(20);
const data = {
server: 'https://mobile.rocket.chat',
adminUser: 'e2e_admin',
adminPassword: 'p7mFh4yLwCRXSnMvG',
server: 'http://localhost:3000',
adminUser: 'admin',
adminPassword: 'password',
alternateServer: 'https://stable.rocket.chat',
users: {
regular: {
@ -47,6 +47,16 @@ const data = {
password: `password${ value }`,
email: `mobile+registering${ value }@rocket.chat`
},
registeringUser2: {
username: `newusertwo${ value }`,
password: `passwordtwo${ value }`,
email: `mobile+registeringtwo${ value }@rocket.chat`
},
registeringUser3: {
username: `newuserthree${ value }`,
password: `passwordthree${ value }`,
email: `mobile+registeringthree${ value }@rocket.chat`
},
random: value
}
module.exports = data;

View File

@ -47,6 +47,16 @@ const data = {
password: `password${ value }`,
email: `mobile+registering${ value }@rocket.chat`
},
registeringUser2: {
username: `newusertwo${ value }`,
password: `passwordtwo${ value }`,
email: `mobile+registeringtwo${ value }@rocket.chat`
},
registeringUser3: {
username: `newuserthree${ value }`,
password: `passwordthree${ value }`,
email: `mobile+registeringthree${ value }@rocket.chat`
},
random: value
}
module.exports = data;

View File

@ -47,6 +47,16 @@ const data = {
password: `password${ value }`,
email: `mobile+registering${ value }@rocket.chat`
},
registeringUser2: {
username: `newusertwo${ value }`,
password: `passwordtwo${ value }`,
email: `mobile+registeringtwo${ value }@rocket.chat`
},
registeringUser3: {
username: `newuserthree${ value }`,
password: `passwordthree${ value }`,
email: `mobile+registeringthree${ value }@rocket.chat`
},
random: value
}
module.exports = data;

View File

@ -8,6 +8,18 @@ const data = require('../../data');
const testuser = data.users.regular
const otheruser = data.users.alternate
const checkServer = async(server) => {
const label = `Connected to ${ server }`;
await element(by.id('rooms-list-view-sidebar')).tap();
await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
await waitFor(element(by.label(label))).toBeVisible().withTimeout(60000);
await element(by.id('sidebar-close-drawer')).tap();
}
const checkBanner = async() => {
await waitFor(element(by.id('listheader-encryption').withDescendant(by.label('Save Your Encryption Password')))).toBeVisible().withTimeout(10000);
}
async function navigateToRoom(roomName) {
await searchRoom(`${ roomName }`);
await waitFor(element(by.id(`rooms-list-view-item-${ roomName }`))).toExist().withTimeout(60000);
@ -43,7 +55,7 @@ describe('E2E Encryption', () => {
describe('Banner', async() => {
describe('Render', async () => {
it('should have encryption badge', async () => {
await waitFor(element(by.id('listheader-encryption').withDescendant(by.label('Save Your Encryption Password')))).toBeVisible().withTimeout(10000);
await checkBanner();
});
});
@ -195,4 +207,54 @@ describe('E2E Encryption', () => {
})
});
});
describe('Persist Banner', () => {
it('check save banner', async() => {
await checkServer(data.server);
await checkBanner();
})
it('should add server and create new user', async() => {
await sleep(5000);
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);
await element(by.id('rooms-list-header-server-add')).tap();
// TODO: refactor
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
await element(by.id('new-server-view-input')).replaceText(data.alternateServer);
await element(by.id('new-server-view-button')).tap();
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);
await element(by.id('workspace-view-register')).tap();
await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
// Register new user
await element(by.id('register-view-name')).replaceText(data.registeringUser.username);
await element(by.id('register-view-username')).replaceText(data.registeringUser.username);
await element(by.id('register-view-email')).replaceText(data.registeringUser.email);
await element(by.id('register-view-password')).replaceText(data.registeringUser.password);
await element(by.id('register-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);
await checkServer(data.alternateServer);
});
it('should change back', async() => {
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);
await element(by.id(`rooms-list-header-server-${ data.server }`)).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
await checkServer(data.server);
await checkBanner();
});
it('should reopen the app and have banner', async() => {
await device.launchApp({
permissions: { notifications: 'YES' },
newInstance: true
});
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
await checkBanner();
});
});
});

View File

@ -39,10 +39,10 @@ describe('Change server', () => {
await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
// Register new user
await element(by.id('register-view-name')).replaceText(data.registeringUser.username);
await element(by.id('register-view-username')).replaceText(data.registeringUser.username);
await element(by.id('register-view-email')).replaceText(data.registeringUser.email);
await element(by.id('register-view-password')).replaceText(data.registeringUser.password);
await element(by.id('register-view-name')).replaceText(data.registeringUser2.username);
await element(by.id('register-view-username')).replaceText(data.registeringUser2.username);
await element(by.id('register-view-email')).replaceText(data.registeringUser2.email);
await element(by.id('register-view-password')).replaceText(data.registeringUser2.password);
await element(by.id('register-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);

View File

@ -29,10 +29,10 @@ describe('Delete server', () => {
await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
// Register new user
await element(by.id('register-view-name')).replaceText(data.registeringUser.username);
await element(by.id('register-view-username')).replaceText(data.registeringUser.username);
await element(by.id('register-view-email')).replaceText(data.registeringUser.email);
await element(by.id('register-view-password')).replaceText(data.registeringUser.password);
await element(by.id('register-view-name')).replaceText(data.registeringUser3.username);
await element(by.id('register-view-username')).replaceText(data.registeringUser3.username);
await element(by.id('register-view-email')).replaceText(data.registeringUser3.email);
await element(by.id('register-view-password')).replaceText(data.registeringUser3.password);
await element(by.id('register-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);