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

This commit is contained in:
Danny Martini 2024-09-23 17:01:52 +02:00 committed by GitHub
parent 4effb66952
commit 0290e38f99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1 additions and 31 deletions

View file

@ -10,7 +10,6 @@ import {
SUBWORKFLOW_DENIAL_BASE_DESCRIPTION,
SubworkflowPolicyDenialError,
} from '@/errors/subworkflow-policy-denial.error';
import type { License } from '@/license';
import type { AccessService } from '@/services/access.service';
import { OwnershipService } from '@/services/ownership.service';
import type { UrlService } from '@/services/url.service';
@ -20,7 +19,6 @@ import { SubworkflowPolicyChecker } from '../subworkflow-policy-checker.service'
describe('SubworkflowPolicyChecker', () => {
const ownershipService = mockInstance(OwnershipService);
const license = mock<License>();
const globalConfig = mock<GlobalConfig>({
workflows: { callerPolicyDefaultOption: 'workflowsFromSameOwner' },
});
@ -29,17 +27,12 @@ describe('SubworkflowPolicyChecker', () => {
const checker = new SubworkflowPolicyChecker(
mock(),
license,
ownershipService,
globalConfig,
accessService,
urlService,
);
beforeEach(() => {
license.isSharingEnabled.mockReturnValue(true);
});
afterEach(() => {
jest.restoreAllMocks();
});
@ -107,24 +100,6 @@ describe('SubworkflowPolicyChecker', () => {
});
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 () => {
const parentWorkflow = mock<WorkflowEntity>({ id: uuid() });
const subworkflow = mock<Workflow>({ settings: { callerPolicy: 'any' } });

View file

@ -5,7 +5,6 @@ import { Service } from 'typedi';
import type { Project } from '@/databases/entities/project';
import { SubworkflowPolicyDenialError } from '@/errors/subworkflow-policy-denial.error';
import { License } from '@/license';
import { Logger } from '@/logger';
import { AccessService } from '@/services/access.service';
import { OwnershipService } from '@/services/ownership.service';
@ -18,7 +17,6 @@ type DenialPolicy = Exclude<Policy, 'any'>;
export class SubworkflowPolicyChecker {
constructor(
private readonly logger: Logger,
private readonly license: License,
private readonly ownershipService: OwnershipService,
private readonly globalConfig: GlobalConfig,
private readonly accessService: AccessService,
@ -82,10 +80,8 @@ export class SubworkflowPolicyChecker {
* Find the subworkflow's caller policy.
*/
private findPolicy(subworkflow: Workflow): WorkflowSettings.CallerPolicy {
if (!this.license.isSharingEnabled()) return 'workflowsFromSameOwner';
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],
parentWorkflowId,
subworkflowId,
isSharingEnabled: this.license.isSharingEnabled(),
});
}
}