Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(tests): Adds some jaas related checks.

damenchoc88891da5bd4
diff --git a/tests/helpers/Participant.ts b/tests/helpers/Participant.ts
index d0b7137e2f..ae00c3759f 100644
--- a/tests/helpers/Participant.ts
+++ b/tests/helpers/Participant.ts
@@ -24,7 +24,6 @@ import VideoQualityDialog from '../pageobjects/VideoQualityDialog';
import { LOG_PREFIX, logInfo } from './browserLogger';
import { IContext, IJoinOptions } from './types';
-import process from 'node:process';
export const P1_DISPLAY_NAME = 'p1';
export const P2_DISPLAY_NAME = 'p2';
@@ -233,8 +232,15 @@ export class Participant {
await this.driver.setTimeout({ 'pageLoad': 30000 });
+ let urlToLoad = url.startsWith('/') ? url.substring(1) : url;
+
+ if (options.forceGenerateToken && !ctx.iframeAPI && ctx.isJaasAvailable() && process.env.IFRAME_TENANT) {
+ // This to enables tests like invite, which can force using the jaas auth instead of the provided token
+ urlToLoad = `/${process.env.IFRAME_TENANT}/${urlToLoad}`;
+ }
+
// drop the leading '/' so we can use the tenant if any
- await this.driver.url(url.startsWith('/') ? url.substring(1) : url);
+ await this.driver.url(urlToLoad);
await this.waitForPageToLoad();
diff --git a/tests/helpers/participants.ts b/tests/helpers/participants.ts
index 80e0dc3358..5adc1a99f8 100644
--- a/tests/helpers/participants.ts
+++ b/tests/helpers/participants.ts
@@ -168,7 +168,8 @@ async function joinTheModeratorAsP1(ctx: IContext, options?: IJoinOptions) {
if (!options?.skipFirstModerator) {
// we prioritize the access token when iframe is not used and private key is set,
// otherwise if private key is not specified we use the access token if set
- if (process.env.JWT_ACCESS_TOKEN && (!ctx.jwtPrivateKeyPath || !ctx.iframeAPI)) {
+ if (process.env.JWT_ACCESS_TOKEN && (!ctx.jwtPrivateKeyPath || !ctx.iframeAPI)
+ && !options?.forceGenerateToken) {
token = process.env.JWT_ACCESS_TOKEN;
} else if (ctx.jwtPrivateKeyPath) {
token = getModeratorToken(p1DisplayName);
diff --git a/tests/helpers/types.ts b/tests/helpers/types.ts
index 1491648045..ddf8eb32f8 100644
--- a/tests/helpers/types.ts
+++ b/tests/helpers/types.ts
@@ -7,6 +7,7 @@ export type IContext = {
conferenceJid: string;
dialInPin: string;
iframeAPI: boolean;
+ isJaasAvailable: () => boolean;
jwtKid: string;
jwtPrivateKeyPath: string;
keepAlive: Array<any>;
@@ -33,6 +34,12 @@ export type IJoinOptions = {
*/
displayName?: string;
+ /**
+ * When joining the first participant and jwt singing material is available and a provided token
+ * is available, prefer generating a new token for the first participant.
+ */
+ forceGenerateToken?: boolean;
+
/**
* Whether to skip setting display name.
*/
diff --git a/tests/specs/3way/audioVideoModeration.spec.ts b/tests/specs/3way/audioVideoModeration.spec.ts
index efdf1106ce..618cf612b3 100644
--- a/tests/specs/3way/audioVideoModeration.spec.ts
+++ b/tests/specs/3way/audioVideoModeration.spec.ts
@@ -77,6 +77,11 @@ describe('AVModeration', () => {
});
it('hangup and change moderator', async () => {
+ // no moderator switching if jaas is available
+ if (ctx.isJaasAvailable()) {
+ return;
+ }
+
await Promise.all([ ctx.p2.hangup(), ctx.p3.hangup() ]);
await ensureThreeParticipants(ctx);
diff --git a/tests/specs/3way/lobby.spec.ts b/tests/specs/3way/lobby.spec.ts
index c3398d14ca..ad2d4e7e54 100644
--- a/tests/specs/3way/lobby.spec.ts
+++ b/tests/specs/3way/lobby.spec.ts
@@ -195,6 +195,10 @@ describe('Lobby', () => {
});
it('change of moderators in lobby', async () => {
+ // no moderator switching if jaas is available
+ if (ctx.isJaasAvailable()) {
+ return;
+ }
await hangupAllParticipants();
await ensureTwoParticipants(ctx);
@@ -222,11 +226,11 @@ describe('Lobby', () => {
// here the important check is whether the moderator sees the knocking participant
await enterLobby(p2, false);
-
- await hangupAllParticipants();
});
it('shared password', async () => {
+ await hangupAllParticipants();
+
await ensureTwoParticipants(ctx);
const { p1 } = ctx;
@@ -240,7 +244,7 @@ describe('Lobby', () => {
expect(await p1SecurityDialog.isLocked()).toBe(false);
- const roomPasscode = String(Math.random() * 1_000);
+ const roomPasscode = String(Math.trunc(Math.random() * 1_000_000));
await p1SecurityDialog.addPassword(roomPasscode);
@@ -283,6 +287,10 @@ describe('Lobby', () => {
});
it('moderator leaves while lobby enabled', async () => {
+ // no moderator switching if jaas is available
+ if (ctx.isJaasAvailable()) {
+ return;
+ }
const { p1, p2, p3 } = ctx;
await p3.hangup();
@@ -302,7 +310,7 @@ describe('Lobby', () => {
});
it('reject and approve in pre-join', async () => {
- await ctx.p2.hangup();
+ await hangupAllParticipants();
await ensureTwoParticipants(ctx);
await enableLobby();
diff --git a/tests/specs/alone/invite.spec.ts b/tests/specs/alone/invite.spec.ts
index 285bf4ee65..a70e17e376 100644
--- a/tests/specs/alone/invite.spec.ts
+++ b/tests/specs/alone/invite.spec.ts
@@ -2,7 +2,7 @@ import { ensureOneParticipant } from '../../helpers/participants';
import { isDialInEnabled } from '../helpers/DialIn';
describe('Invite', () => {
- it('join participant', () => ensureOneParticipant(ctx));
+ it('join participant', () => ensureOneParticipant(ctx, { forceGenerateToken: true }));
it('url displayed', async () => {
const { p1 } = ctx;
diff --git a/tests/wdio.conf.ts b/tests/wdio.conf.ts
index 26018e2ef8..4c844a1244 100644
--- a/tests/wdio.conf.ts
+++ b/tests/wdio.conf.ts
@@ -214,6 +214,7 @@ export const config: WebdriverIO.MultiremoteConfig = {
globalAny.ctx.jwtPrivateKeyPath = process.env.JWT_PRIVATE_KEY_PATH;
globalAny.ctx.jwtKid = process.env.JWT_KID;
+ globalAny.ctx.isJaasAvailable = () => globalAny.ctx.jwtKid?.startsWith('vpaas-magic-cookie-');
},
after() {