mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
fix(core): Remove subworkflow license check (#10893)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
This commit is contained in:
parent
4effb66952
commit
0290e38f99
|
@ -10,7 +10,6 @@ import {
|
||||||
SUBWORKFLOW_DENIAL_BASE_DESCRIPTION,
|
SUBWORKFLOW_DENIAL_BASE_DESCRIPTION,
|
||||||
SubworkflowPolicyDenialError,
|
SubworkflowPolicyDenialError,
|
||||||
} from '@/errors/subworkflow-policy-denial.error';
|
} from '@/errors/subworkflow-policy-denial.error';
|
||||||
import type { License } from '@/license';
|
|
||||||
import type { AccessService } from '@/services/access.service';
|
import type { AccessService } from '@/services/access.service';
|
||||||
import { OwnershipService } from '@/services/ownership.service';
|
import { OwnershipService } from '@/services/ownership.service';
|
||||||
import type { UrlService } from '@/services/url.service';
|
import type { UrlService } from '@/services/url.service';
|
||||||
|
@ -20,7 +19,6 @@ import { SubworkflowPolicyChecker } from '../subworkflow-policy-checker.service'
|
||||||
|
|
||||||
describe('SubworkflowPolicyChecker', () => {
|
describe('SubworkflowPolicyChecker', () => {
|
||||||
const ownershipService = mockInstance(OwnershipService);
|
const ownershipService = mockInstance(OwnershipService);
|
||||||
const license = mock<License>();
|
|
||||||
const globalConfig = mock<GlobalConfig>({
|
const globalConfig = mock<GlobalConfig>({
|
||||||
workflows: { callerPolicyDefaultOption: 'workflowsFromSameOwner' },
|
workflows: { callerPolicyDefaultOption: 'workflowsFromSameOwner' },
|
||||||
});
|
});
|
||||||
|
@ -29,17 +27,12 @@ describe('SubworkflowPolicyChecker', () => {
|
||||||
|
|
||||||
const checker = new SubworkflowPolicyChecker(
|
const checker = new SubworkflowPolicyChecker(
|
||||||
mock(),
|
mock(),
|
||||||
license,
|
|
||||||
ownershipService,
|
ownershipService,
|
||||||
globalConfig,
|
globalConfig,
|
||||||
accessService,
|
accessService,
|
||||||
urlService,
|
urlService,
|
||||||
);
|
);
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
license.isSharingEnabled.mockReturnValue(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.restoreAllMocks();
|
jest.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
@ -107,24 +100,6 @@ describe('SubworkflowPolicyChecker', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('`any` caller policy', () => {
|
describe('`any` caller policy', () => {
|
||||||
it('if no sharing, should be overriden to `workflows-from-same-owner`', async () => {
|
|
||||||
license.isSharingEnabled.mockReturnValueOnce(false);
|
|
||||||
|
|
||||||
const parentWorkflow = mock<WorkflowEntity>();
|
|
||||||
const subworkflowId = 'subworkflow-id';
|
|
||||||
const subworkflow = mock<Workflow>({ id: subworkflowId, settings: { callerPolicy: 'any' } }); // should be overridden
|
|
||||||
|
|
||||||
const parentWorkflowProject = mock<Project>({ id: uuid() });
|
|
||||||
const subworkflowProject = mock<Project>({ id: uuid(), type: 'team' });
|
|
||||||
|
|
||||||
ownershipService.getWorkflowProjectCached.mockResolvedValueOnce(parentWorkflowProject);
|
|
||||||
ownershipService.getWorkflowProjectCached.mockResolvedValueOnce(subworkflowProject);
|
|
||||||
|
|
||||||
const check = checker.check(subworkflow, parentWorkflow.id);
|
|
||||||
|
|
||||||
await expect(check).rejects.toThrowError(SubworkflowPolicyDenialError);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not throw on a regular subworkflow call', async () => {
|
it('should not throw on a regular subworkflow call', async () => {
|
||||||
const parentWorkflow = mock<WorkflowEntity>({ id: uuid() });
|
const parentWorkflow = mock<WorkflowEntity>({ id: uuid() });
|
||||||
const subworkflow = mock<Workflow>({ settings: { callerPolicy: 'any' } });
|
const subworkflow = mock<Workflow>({ settings: { callerPolicy: 'any' } });
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { Service } from 'typedi';
|
||||||
|
|
||||||
import type { Project } from '@/databases/entities/project';
|
import type { Project } from '@/databases/entities/project';
|
||||||
import { SubworkflowPolicyDenialError } from '@/errors/subworkflow-policy-denial.error';
|
import { SubworkflowPolicyDenialError } from '@/errors/subworkflow-policy-denial.error';
|
||||||
import { License } from '@/license';
|
|
||||||
import { Logger } from '@/logger';
|
import { Logger } from '@/logger';
|
||||||
import { AccessService } from '@/services/access.service';
|
import { AccessService } from '@/services/access.service';
|
||||||
import { OwnershipService } from '@/services/ownership.service';
|
import { OwnershipService } from '@/services/ownership.service';
|
||||||
|
@ -18,7 +17,6 @@ type DenialPolicy = Exclude<Policy, 'any'>;
|
||||||
export class SubworkflowPolicyChecker {
|
export class SubworkflowPolicyChecker {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
private readonly license: License,
|
|
||||||
private readonly ownershipService: OwnershipService,
|
private readonly ownershipService: OwnershipService,
|
||||||
private readonly globalConfig: GlobalConfig,
|
private readonly globalConfig: GlobalConfig,
|
||||||
private readonly accessService: AccessService,
|
private readonly accessService: AccessService,
|
||||||
|
@ -82,10 +80,8 @@ export class SubworkflowPolicyChecker {
|
||||||
* Find the subworkflow's caller policy.
|
* Find the subworkflow's caller policy.
|
||||||
*/
|
*/
|
||||||
private findPolicy(subworkflow: Workflow): WorkflowSettings.CallerPolicy {
|
private findPolicy(subworkflow: Workflow): WorkflowSettings.CallerPolicy {
|
||||||
if (!this.license.isSharingEnabled()) return 'workflowsFromSameOwner';
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
subworkflow.settings?.callerPolicy ?? this.globalConfig.workflows.callerPolicyDefaultOption
|
subworkflow.settings.callerPolicy ?? this.globalConfig.workflows.callerPolicyDefaultOption
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +135,6 @@ export class SubworkflowPolicyChecker {
|
||||||
reason: this.denialReasons[policy],
|
reason: this.denialReasons[policy],
|
||||||
parentWorkflowId,
|
parentWorkflowId,
|
||||||
subworkflowId,
|
subworkflowId,
|
||||||
isSharingEnabled: this.license.isSharingEnabled(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue