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:
@@ -0,0 +1,126 @@
|
||||
import type { IMarketplaceInfo } from '@rocket.chat/apps/dist/server/marketplace/IMarketplaceInfo';
|
||||
import { AppInstallationSource, type IAppStorageItem } from '@rocket.chat/apps/dist/server/storage/IAppStorageItem';
|
||||
import { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
|
||||
import type { Apps } from '@rocket.chat/core-services';
|
||||
import type { LicenseImp } from '@rocket.chat/license';
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { _canEnableApp } from '../../../../../server/lib/license/canEnableApp';
|
||||
|
||||
const getDefaultApp = (): IAppStorageItem => ({
|
||||
_id: '6706d9258e0ca97c2f0cc885',
|
||||
id: '2e14ff6e-b4d5-4c4c-b12b-b1b1d15ec630',
|
||||
info: {
|
||||
id: '2e14ff6e-b4d5-4c4c-b12b-b1b1d15ec630',
|
||||
version: '0.0.1',
|
||||
requiredApiVersion: '^1.19.0',
|
||||
iconFile: 'icon.png',
|
||||
author: { name: 'a', homepage: 'a', support: 'a' },
|
||||
name: 'Add-on test',
|
||||
nameSlug: 'add-on-test',
|
||||
classFile: 'AddOnTestApp.js',
|
||||
description: 'a',
|
||||
implements: [],
|
||||
iconFileContent: '',
|
||||
},
|
||||
status: AppStatus.UNKNOWN,
|
||||
settings: {},
|
||||
implemented: {},
|
||||
installationSource: AppInstallationSource.PRIVATE,
|
||||
languageContent: {},
|
||||
sourcePath: 'GridFS:/6706d9258e0ca97c2f0cc880',
|
||||
signature: '',
|
||||
createdAt: new Date('2024-10-09T19:27:33.923Z'),
|
||||
updatedAt: new Date('2024-10-09T19:27:33.923Z'),
|
||||
});
|
||||
|
||||
describe('canEnableApp', () => {
|
||||
it('should throw the message "apps-engine-not-initialized" when appropriate', () => {
|
||||
const AppsMock = {
|
||||
isInitialized() {
|
||||
return false;
|
||||
},
|
||||
} as unknown as typeof Apps;
|
||||
|
||||
const LicenseMock = {} as unknown as LicenseImp;
|
||||
|
||||
const deps = { Apps: AppsMock, License: LicenseMock };
|
||||
|
||||
return expect(_canEnableApp(deps, getDefaultApp())).to.eventually.be.rejectedWith('apps-engine-not-initialized');
|
||||
});
|
||||
|
||||
const AppsMock = {
|
||||
isInitialized() {
|
||||
return true;
|
||||
},
|
||||
} as unknown as typeof Apps;
|
||||
|
||||
const LicenseMock = {
|
||||
hasModule() {
|
||||
return false;
|
||||
},
|
||||
shouldPreventAction() {
|
||||
return true;
|
||||
},
|
||||
hasValidLicense() {
|
||||
return false;
|
||||
},
|
||||
} as unknown as LicenseImp;
|
||||
|
||||
const deps = { Apps: AppsMock, License: LicenseMock };
|
||||
|
||||
it('should throw the message "app-addon-not-valid" when appropriate', () => {
|
||||
const app = getDefaultApp();
|
||||
app.info.addon = 'chat.rocket.test-addon';
|
||||
|
||||
return expect(_canEnableApp(deps, app)).to.eventually.be.rejectedWith('app-addon-not-valid');
|
||||
});
|
||||
|
||||
it('should throw the message "license-prevented" when appropriate', () => {
|
||||
const privateApp = getDefaultApp();
|
||||
const marketplaceApp = getDefaultApp();
|
||||
marketplaceApp.installationSource = AppInstallationSource.MARKETPLACE;
|
||||
|
||||
return Promise.all([
|
||||
expect(_canEnableApp(deps, privateApp)).to.eventually.be.rejectedWith('license-prevented'),
|
||||
expect(_canEnableApp(deps, marketplaceApp)).to.eventually.be.rejectedWith('license-prevented'),
|
||||
]);
|
||||
});
|
||||
|
||||
it('should throw the message "invalid-license" when appropriate', () => {
|
||||
const License = { ...LicenseMock, shouldPreventAction: () => false } as unknown as LicenseImp;
|
||||
|
||||
const app = getDefaultApp();
|
||||
app.installationSource = AppInstallationSource.MARKETPLACE;
|
||||
app.marketplaceInfo = [{ isEnterpriseOnly: true } as IMarketplaceInfo];
|
||||
|
||||
const deps = { Apps: AppsMock, License };
|
||||
|
||||
return expect(_canEnableApp(deps, app)).to.eventually.be.rejectedWith('invalid-license');
|
||||
});
|
||||
|
||||
it('should not throw if app is migrated', () => {
|
||||
const app = getDefaultApp();
|
||||
app.migrated = true;
|
||||
|
||||
return expect(_canEnableApp(deps, app)).to.not.eventually.be.rejected;
|
||||
});
|
||||
|
||||
it('should not throw if license allows it', () => {
|
||||
const License = {
|
||||
hasModule() {
|
||||
return true;
|
||||
},
|
||||
shouldPreventAction() {
|
||||
return false;
|
||||
},
|
||||
hasValidLicense() {
|
||||
return true;
|
||||
},
|
||||
} as unknown as LicenseImp;
|
||||
|
||||
const deps = { Apps: AppsMock, License };
|
||||
|
||||
return expect(_canEnableApp(deps, getDefaultApp())).to.not.eventually.be.rejected;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user