2018-08-07 15:58:58 +00:00
|
|
|
/*
|
|
|
|
Copyright 2018 New Vector Ltd
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
2018-08-14 10:53:16 +00:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2018-08-07 15:58:58 +00:00
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2018-08-23 08:04:06 +00:00
|
|
|
const {acceptDialogMaybe} = require('./tests/dialog');
|
2018-08-07 15:58:58 +00:00
|
|
|
const signup = require('./tests/signup');
|
|
|
|
const join = require('./tests/join');
|
2018-08-08 10:17:36 +00:00
|
|
|
const sendMessage = require('./tests/send-message');
|
2018-08-08 13:22:54 +00:00
|
|
|
const acceptInvite = require('./tests/accept-invite');
|
|
|
|
const invite = require('./tests/invite');
|
2018-08-08 10:17:36 +00:00
|
|
|
const receiveMessage = require('./tests/receive-message');
|
2018-08-07 15:58:58 +00:00
|
|
|
const createRoom = require('./tests/create-room');
|
2018-08-08 09:39:17 +00:00
|
|
|
const changeRoomSettings = require('./tests/room-settings');
|
2018-08-07 15:58:58 +00:00
|
|
|
const acceptServerNoticesInviteAndConsent = require('./tests/server-notices-consent');
|
2018-09-11 16:28:50 +00:00
|
|
|
const {enableLazyLoading, getE2EDeviceFromSettings} = require('./tests/settings');
|
2018-08-08 13:22:54 +00:00
|
|
|
const verifyDeviceForUser = require("./tests/verify-device");
|
2018-08-07 15:58:58 +00:00
|
|
|
|
2018-09-11 12:46:25 +00:00
|
|
|
module.exports = async function scenario(createSession, createRestSession) {
|
2018-08-14 10:53:16 +00:00
|
|
|
async function createUser(username) {
|
|
|
|
const session = await createSession(username);
|
2018-09-11 16:28:50 +00:00
|
|
|
await signup(session, session.username, 'testtest', session.hsUrl);
|
2018-08-14 10:53:16 +00:00
|
|
|
await acceptServerNoticesInviteAndConsent(session);
|
|
|
|
return session;
|
|
|
|
}
|
2018-08-07 15:58:58 +00:00
|
|
|
|
2018-08-14 10:53:16 +00:00
|
|
|
const alice = await createUser("alice");
|
|
|
|
const bob = await createUser("bob");
|
2018-08-08 10:35:50 +00:00
|
|
|
|
2018-08-14 10:53:16 +00:00
|
|
|
await createDirectoryRoomAndTalk(alice, bob);
|
|
|
|
await createE2ERoomAndTalk(alice, bob);
|
2018-08-08 10:35:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function createDirectoryRoomAndTalk(alice, bob) {
|
2018-08-14 10:53:16 +00:00
|
|
|
console.log(" creating a public room and join through directory:");
|
|
|
|
const room = 'test';
|
|
|
|
await createRoom(alice, room);
|
|
|
|
await changeRoomSettings(alice, {directory: true, visibility: "public_no_guests"});
|
|
|
|
await join(bob, room);
|
|
|
|
const bobMessage = "hi Alice!";
|
|
|
|
await sendMessage(bob, bobMessage);
|
|
|
|
await receiveMessage(alice, {sender: "bob", body: bobMessage});
|
|
|
|
const aliceMessage = "hi Bob, welcome!"
|
|
|
|
await sendMessage(alice, aliceMessage);
|
|
|
|
await receiveMessage(bob, {sender: "alice", body: aliceMessage});
|
2018-08-08 13:22:54 +00:00
|
|
|
}
|
2018-08-08 10:35:50 +00:00
|
|
|
|
2018-08-08 10:42:34 +00:00
|
|
|
async function createE2ERoomAndTalk(alice, bob) {
|
2018-08-14 10:53:16 +00:00
|
|
|
console.log(" creating an e2e encrypted room and join through invite:");
|
|
|
|
const room = "secrets";
|
|
|
|
await createRoom(bob, room);
|
|
|
|
await changeRoomSettings(bob, {encryption: true});
|
|
|
|
await invite(bob, "@alice:localhost");
|
|
|
|
await acceptInvite(alice, room);
|
|
|
|
const bobDevice = await getE2EDeviceFromSettings(bob);
|
|
|
|
// wait some time for the encryption warning dialog
|
|
|
|
// to appear after closing the settings
|
2018-08-22 22:27:30 +00:00
|
|
|
await bob.delay(1000);
|
2018-08-23 08:04:06 +00:00
|
|
|
await acceptDialogMaybe(bob, "encryption");
|
2018-08-14 10:53:16 +00:00
|
|
|
const aliceDevice = await getE2EDeviceFromSettings(alice);
|
|
|
|
// wait some time for the encryption warning dialog
|
|
|
|
// to appear after closing the settings
|
2018-08-22 22:27:30 +00:00
|
|
|
await alice.delay(1000);
|
2018-08-23 08:04:06 +00:00
|
|
|
await acceptDialogMaybe(alice, "encryption");
|
2018-08-14 10:53:16 +00:00
|
|
|
await verifyDeviceForUser(bob, "alice", aliceDevice);
|
|
|
|
await verifyDeviceForUser(alice, "bob", bobDevice);
|
|
|
|
const aliceMessage = "Guess what I just heard?!"
|
|
|
|
await sendMessage(alice, aliceMessage);
|
|
|
|
await receiveMessage(bob, {sender: "alice", body: aliceMessage, encrypted: true});
|
|
|
|
const bobMessage = "You've got to tell me!";
|
|
|
|
await sendMessage(bob, bobMessage);
|
|
|
|
await receiveMessage(alice, {sender: "bob", body: bobMessage, encrypted: true});
|
2018-08-08 13:22:54 +00:00
|
|
|
}
|
2018-09-11 16:28:50 +00:00
|
|
|
|
|
|
|
async function aLLtest(alice, bob) {
|
|
|
|
await enableLazyLoading(alice);
|
|
|
|
|
|
|
|
}
|