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

test: update playwright tests to support sha256 and sha512 algorithms… (port) #19835

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions bigbluebutton-tests/playwright/.env.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# meeting credentials
BBB_URL="" # https://DOMAIN_NAME/bigbluebutton/api
BBB_SECRET=""
CHECKSUM="" # (sha1 | sha256 | sha512) Force a specific checksum algorithm. Useful for when the secret length is not a sha algorithm length

TIMEOUT_MULTIPLIER=1 # (number / empty) Apply a multiplier on default timeouts - depending the server strength (not recommended to use greater values than 3)
26 changes: 22 additions & 4 deletions bigbluebutton-tests/playwright/core/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require('dotenv').config();
const sha1 = require('sha1');
const sha = require('sha.js');
const axios = require('axios');
const { test, expect } = require('@playwright/test');
const xml2js = require('xml2js');
Expand All @@ -11,6 +11,24 @@ const { format } = require('node:util');
const chalk = require('chalk');
const parameters = require('./parameters');

function getChecksum(text, secret) {
let algorithm = (process.env.CHECKSUM || '').toLowerCase();
if (!['sha1', 'sha256', 'sha512'].includes(algorithm)) {
switch (secret.length) {
case 128:
algorithm = 'sha512';
break;
case 64:
algorithm = 'sha256';
break;
case 40:
default:
algorithm = 'sha1'
}
}
return sha(algorithm).update(text).digest('hex');
}

function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
Expand All @@ -20,7 +38,7 @@ function getRandomInt(min, max) {
function apiCallUrl(name, callParams) {
const query = new URLSearchParams(callParams).toString();
const apiCall = `${name}${query}${parameters.secret}`;
const checksum = sha1(apiCall);
const checksum = getChecksum(apiCall, parameters.secret);
const url = `${parameters.server}/${name}?${query}&checksum=${checksum}`;
return url;
}
Expand All @@ -38,7 +56,7 @@ function createMeetingUrl(params, createParameter, customMeetingId) {
+ `&allowStartStopRecording=true&autoStartRecording=false&welcome=${params.welcome}`;
const query = createParameter !== undefined ? `${baseQuery}&${createParameter}` : baseQuery;
const apiCall = `create${query}${params.secret}`;
const checksum = sha1(apiCall);
const checksum = getChecksum(apiCall, parameters.secret);
const url = `${params.server}/create?${query}&checksum=${checksum}`;
return url;
}
Expand All @@ -61,7 +79,7 @@ function getJoinURL(meetingID, params, moderator, joinParameter) {
const baseQuery = `fullName=${params.fullName}&meetingID=${meetingID}&password=${pw}`;
const query = joinParameter !== undefined ? `${baseQuery}&${joinParameter}` : baseQuery;
const apiCall = `join${query}${params.secret}`;
const checksum = sha1(apiCall);
const checksum = getChecksum(apiCall, parameters.secret);
return `${params.server}/join?${query}&checksum=${checksum}`;
}

Expand Down
92 changes: 50 additions & 42 deletions bigbluebutton-tests/playwright/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bigbluebutton-tests/playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"deep-equal": "^2.2.1",
"dotenv": "^16.1.4",
"playwright": "^1.37.1",
"sha1": "^1.1.1",
"sha.js": "^2.4.11",
"xml2js": "^0.6.0"
}
}
}