mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor(core): Separate license state from license service (#15097)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { LicenseProvider, LicenseState } from '@n8n/backend-common';
|
||||
import type { BooleanLicenseFeature, NumericLicenseFeature } from '@n8n/constants';
|
||||
|
||||
import type { License } from '@/license';
|
||||
@@ -17,8 +18,17 @@ export class LicenseMocker {
|
||||
private _defaultQuotas: Map<NumericLicenseFeature, number> = new Map();
|
||||
|
||||
mock(license: License) {
|
||||
license.isFeatureEnabled = this.isFeatureEnabled.bind(this);
|
||||
license.getFeatureValue = this.getFeatureValue.bind(this);
|
||||
license.isLicensed = this.isFeatureEnabled.bind(this);
|
||||
license.getValue = this.getFeatureValue.bind(this);
|
||||
}
|
||||
|
||||
mockLicenseState(licenseState: LicenseState) {
|
||||
const licenseProvider: LicenseProvider = {
|
||||
isLicensed: this.isFeatureEnabled.bind(this),
|
||||
getValue: this.getFeatureValue.bind(this),
|
||||
};
|
||||
|
||||
licenseState.setLicenseProvider(licenseProvider);
|
||||
}
|
||||
|
||||
reset() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { LicenseState } from '@n8n/backend-common';
|
||||
import type { User } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import cookieParser from 'cookie-parser';
|
||||
@@ -125,6 +126,8 @@ export const setupTestServer = ({
|
||||
config.set('userManagement.isInstanceOwnerSetUp', true);
|
||||
|
||||
testServer.license.mock(Container.get(License));
|
||||
testServer.license.mockLicenseState(Container.get(LicenseState));
|
||||
|
||||
if (enabledFeatures) {
|
||||
testServer.license.setDefaults({
|
||||
features: enabledFeatures,
|
||||
|
||||
Reference in New Issue
Block a user