snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
162
apps/meteor/tests/unit/app/utils/lib/getURL.tests.js
Normal file
162
apps/meteor/tests/unit/app/utils/lib/getURL.tests.js
Normal file
@@ -0,0 +1,162 @@
|
||||
import { expect } from 'chai';
|
||||
import proxyquire from 'proxyquire';
|
||||
|
||||
import { ltrim, rtrim } from '../../../../../lib/utils/stringUtils';
|
||||
|
||||
const { _getURL } = proxyquire.noCallThru().load('../../../../../app/utils/lib/getURL', {
|
||||
'meteor/meteor': {
|
||||
'Meteor': {
|
||||
absoluteUrl() {
|
||||
return 'http://localhost:3000/';
|
||||
},
|
||||
},
|
||||
'@global': true,
|
||||
},
|
||||
});
|
||||
|
||||
const testPaths = (o, _processPath) => {
|
||||
let processPath = _processPath;
|
||||
if (o._root_url_path_prefix !== '') {
|
||||
processPath = (path) => _processPath(o._root_url_path_prefix + path);
|
||||
}
|
||||
|
||||
const cloudDeepLinkUrl = 'https://go.rocket.chat';
|
||||
|
||||
expect(_getURL('', o, cloudDeepLinkUrl)).to.be.equal(processPath(''));
|
||||
expect(_getURL('/', o, cloudDeepLinkUrl)).to.be.equal(processPath(''));
|
||||
expect(_getURL('//', o, cloudDeepLinkUrl)).to.be.equal(processPath(''));
|
||||
expect(_getURL('///', o, cloudDeepLinkUrl)).to.be.equal(processPath(''));
|
||||
expect(_getURL('/channel', o, cloudDeepLinkUrl)).to.be.equal(processPath('/channel'));
|
||||
expect(_getURL('/channel/', o, cloudDeepLinkUrl)).to.be.equal(processPath('/channel'));
|
||||
expect(_getURL('/channel//', o, cloudDeepLinkUrl)).to.be.equal(processPath('/channel'));
|
||||
expect(_getURL('/channel/123', o, cloudDeepLinkUrl)).to.be.equal(processPath('/channel/123'));
|
||||
expect(_getURL('/channel/123/', o, cloudDeepLinkUrl)).to.be.equal(processPath('/channel/123'));
|
||||
expect(_getURL('/channel/123?id=456&name=test', o, cloudDeepLinkUrl)).to.be.equal(processPath('/channel/123?id=456&name=test'));
|
||||
expect(_getURL('/channel/123/?id=456&name=test', o, cloudDeepLinkUrl)).to.be.equal(processPath('/channel/123?id=456&name=test'));
|
||||
};
|
||||
|
||||
const getCloudUrl = (_site_url, path) => {
|
||||
path = ltrim(path, '/');
|
||||
const url = `https://go.rocket.chat/?host=${encodeURIComponent(_site_url.replace(/https?:\/\//, ''))}&path=${encodeURIComponent(path)}`;
|
||||
if (_site_url.includes('http://')) {
|
||||
return `${url}&secure=no`;
|
||||
}
|
||||
return url;
|
||||
};
|
||||
|
||||
const testCases = (options) => {
|
||||
const _site_url = rtrim(options._site_url, '/');
|
||||
|
||||
if (!options.cloud) {
|
||||
if (options._cdn_prefix === '') {
|
||||
if (options.full && !options.cdn) {
|
||||
it('should return with host if full: true', () => {
|
||||
testPaths(options, (path) => _site_url + path);
|
||||
});
|
||||
}
|
||||
|
||||
if (!options.full && options.cdn) {
|
||||
it('should return without cdn prefix if cdn: true', () => {
|
||||
testPaths(options, (path) => path);
|
||||
});
|
||||
}
|
||||
|
||||
if (!options.full && !options.cdn) {
|
||||
it('should return without host by default', () => {
|
||||
testPaths(options, (path) => path);
|
||||
});
|
||||
}
|
||||
|
||||
if (options.full && options.cdn) {
|
||||
it('should return with host if full: true and cdn: true', () => {
|
||||
testPaths(options, (path) => _site_url + path);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (options.full && !options.cdn) {
|
||||
it('should return with host if full: true', () => {
|
||||
testPaths(options, (path) => _site_url + path);
|
||||
});
|
||||
}
|
||||
|
||||
if (!options.full && options.cdn) {
|
||||
it('should return with cdn prefix if cdn: true', () => {
|
||||
testPaths(options, (path) => options._cdn_prefix + path);
|
||||
});
|
||||
}
|
||||
|
||||
if (!options.full && !options.cdn) {
|
||||
it('should return without host by default', () => {
|
||||
testPaths(options, (path) => path);
|
||||
});
|
||||
}
|
||||
|
||||
if (options.full && options.cdn) {
|
||||
it('should return with cdn prefix if full: true and cdn: true', () => {
|
||||
testPaths(options, (path) => options._cdn_prefix + path);
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (options._cdn_prefix === '') {
|
||||
if (!options.full && options.cdn) {
|
||||
it('should return with cloud host if cdn: true', () => {
|
||||
testPaths(options, (path) => getCloudUrl(_site_url, path));
|
||||
});
|
||||
}
|
||||
|
||||
if (!options.full && !options.cdn) {
|
||||
it('should return with cloud host if full: fase and cdn: false', () => {
|
||||
testPaths(options, (path) => getCloudUrl(_site_url, path));
|
||||
});
|
||||
}
|
||||
} else if (!options.full && !options.cdn) {
|
||||
it('should return with cloud host if full: fase and cdn: false', () => {
|
||||
testPaths(options, (path) => getCloudUrl(_site_url, path));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const testCasesForOptions = (description, options) => {
|
||||
describe(description, () => {
|
||||
testCases({ ...options, cdn: false, full: false, cloud: false });
|
||||
testCases({ ...options, cdn: true, full: false, cloud: false });
|
||||
testCases({ ...options, cdn: false, full: true, cloud: false });
|
||||
testCases({ ...options, cdn: false, full: false, cloud: true });
|
||||
testCases({ ...options, cdn: true, full: true, cloud: false });
|
||||
testCases({ ...options, cdn: false, full: true, cloud: true });
|
||||
testCases({ ...options, cdn: true, full: false, cloud: true });
|
||||
testCases({ ...options, cdn: true, full: true, cloud: true });
|
||||
});
|
||||
};
|
||||
|
||||
describe('getURL', () => {
|
||||
testCasesForOptions('getURL with no CDN, no PREFIX for http://localhost:3000/', {
|
||||
_cdn_prefix: '',
|
||||
_root_url_path_prefix: '',
|
||||
_site_url: 'http://localhost:3000/',
|
||||
});
|
||||
|
||||
testCasesForOptions('getURL with no CDN, no PREFIX for http://localhost:3000', {
|
||||
_cdn_prefix: '',
|
||||
_root_url_path_prefix: '',
|
||||
_site_url: 'http://localhost:3000',
|
||||
});
|
||||
|
||||
testCasesForOptions('getURL with CDN, no PREFIX for http://localhost:3000/', {
|
||||
_cdn_prefix: 'https://cdn.com',
|
||||
_root_url_path_prefix: '',
|
||||
_site_url: 'http://localhost:3000/',
|
||||
});
|
||||
|
||||
testCasesForOptions('getURL with CDN, PREFIX for http://localhost:3000/', {
|
||||
_cdn_prefix: 'https://cdn.com',
|
||||
_root_url_path_prefix: 'sub',
|
||||
_site_url: 'http://localhost:3000/',
|
||||
});
|
||||
|
||||
testCasesForOptions('getURL with CDN, PREFIX for https://localhost:3000/', {
|
||||
_cdn_prefix: 'https://cdn.com',
|
||||
_root_url_path_prefix: 'sub',
|
||||
_site_url: 'https://localhost:3000/',
|
||||
});
|
||||
});
|
||||
49
apps/meteor/tests/unit/app/utils/lib/restrictions.spec.ts
Normal file
49
apps/meteor/tests/unit/app/utils/lib/restrictions.spec.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { fileUploadIsValidContentTypeFromSettings } from '../../../../../app/utils/lib/restrictions';
|
||||
|
||||
describe('fileUploadIsValidContentTypeFromSettings', () => {
|
||||
it('should return true if type is not defined and whiteList is not defined', () => {
|
||||
expect(fileUploadIsValidContentTypeFromSettings(undefined, '', '')).to.be.true;
|
||||
});
|
||||
|
||||
it('should return false if type is not defined and whiteList is defined', () => {
|
||||
expect(fileUploadIsValidContentTypeFromSettings(undefined, 'image/jpeg', '')).to.be.false;
|
||||
});
|
||||
|
||||
it('should return true if type is defined and whiteList is not defined', () => {
|
||||
expect(fileUploadIsValidContentTypeFromSettings('image/jpeg', '', '')).to.be.true;
|
||||
});
|
||||
|
||||
it('should return true if type is defined and whiteList is defined and type is in whiteList', () => {
|
||||
expect(fileUploadIsValidContentTypeFromSettings('image/jpeg', 'image/jpeg', '')).to.be.true;
|
||||
});
|
||||
|
||||
it('should return false if type is defined and whiteList is defined and type is not in whiteList', () => {
|
||||
expect(fileUploadIsValidContentTypeFromSettings('image/png', 'image/jpeg', '')).to.be.false;
|
||||
});
|
||||
|
||||
it('should return false if type is defined and whiteList is not defined and type is in blackList', () => {
|
||||
expect(fileUploadIsValidContentTypeFromSettings('image/jpeg', '', 'image/jpeg')).to.be.false;
|
||||
});
|
||||
|
||||
it('should return true if type is defined and whiteList is not defined and type is not in blackList', () => {
|
||||
expect(fileUploadIsValidContentTypeFromSettings('image/png', '', 'image/jpeg')).to.be.true;
|
||||
});
|
||||
|
||||
it('should return true if type is defined and whiteList is defined and type is in whiteList with wildcard', () => {
|
||||
expect(fileUploadIsValidContentTypeFromSettings('image/jpeg', 'image/*', '')).to.be.true;
|
||||
});
|
||||
|
||||
it('should return false if type is defined and whiteList is defined and type is not in whiteList with wildcard', () => {
|
||||
expect(fileUploadIsValidContentTypeFromSettings('text/plain', 'image/*', '')).to.be.false;
|
||||
});
|
||||
|
||||
it('should return false if type is defined and whiteList is not defined and type is in blackList with wildcard', () => {
|
||||
expect(fileUploadIsValidContentTypeFromSettings('image/jpeg', '', 'image/*')).to.be.false;
|
||||
});
|
||||
|
||||
it('should return true if type is defined and whiteList is defined and type is not in blackList with wildcard', () => {
|
||||
expect(fileUploadIsValidContentTypeFromSettings('text/plain', '', 'image/*')).to.be.true;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user