n8n/packages/cli/test/unit
Iván Ovejero 3206b44974
test(core): Improve tests for subworkflow caller policy checks (no-changelog) (#7954)
## Summary
Deduplicate, separate, organize and speed up tests for subworkflow
caller policy checks.

Follow-up to: https://github.com/n8n-io/n8n/pull/7913

```
 PASS  test/unit/PermissionChecker.test.ts
  check()
    ✓ should allow if workflow has no creds (3 ms)
    ✓ should allow if requesting user is instance owner (83 ms)
    ✓ should allow if workflow creds are valid subset (151 ms)
    ✓ should deny if workflow creds are not valid subset (85 ms)
  checkSubworkflowExecutePolicy()
    no caller policy
      ✓ should fall back to N8N_WORKFLOW_CALLER_POLICY_DEFAULT_OPTION (1 ms)
    overridden caller policy
      ✓ if no sharing, policy becomes workflows-from-same-owner (1 ms)
    workflows-from-list caller policy
      ✓ should allow if caller list contains parent workflow ID
      ✓ should deny if caller list does not contain parent workflow ID (1 ms)
    any caller policy
      ✓ should not throw
    workflows-from-same-owner caller policy
      ✓ should deny if the two workflows are owned by different users (1 ms)
      ✓ should allow if both workflows are owned by the same user
```
...

#### How to test the change:
1. ...


## Issues fixed
Include links to Github issue or Community forum post or **Linear
ticket**:
> Important in order to close automatically and provide context to
reviewers

...


## Review / Merge checklist
- [ ] PR title and summary are descriptive. **Remember, the title
automatically goes into the changelog. Use `(no-changelog)` otherwise.**
([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md))
- [ ] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up
ticket created.
- [ ] Tests included.
> A bug is not considered fixed, unless a test is added to prevent it
from happening again. A feature is not complete without tests.
  >
> *(internal)* You can use Slack commands to trigger [e2e
tests](https://www.notion.so/n8n/How-to-use-Test-Instances-d65f49dfc51f441ea44367fb6f67eb0a?pvs=4#a39f9e5ba64a48b58a71d81c837e8227)
or [deploy test
instance](https://www.notion.so/n8n/How-to-use-Test-Instances-d65f49dfc51f441ea44367fb6f67eb0a?pvs=4#f6a177d32bde4b57ae2da0b8e454bfce)
or [deploy early access version on
Cloud](https://www.notion.so/n8n/Cloudbot-3dbe779836004972b7057bc989526998?pvs=4#fef2d36ab02247e1a0f65a74f6fb534e).
2023-12-08 11:21:43 +01:00
..
collaboration feat(editor): Show avatars for users currently working on the same workflow (#7763) 2023-11-23 10:14:34 +01:00
controllers refactor(core): Reorganize error hierarchy in cli package (no-changelog) (#7839) 2023-11-28 10:19:27 +01:00
databases/utils fix(editor): Validate user info before submiting (#7608) 2023-11-22 12:14:44 +01:00
execution-lifecyle test(core): Isolate restore binary data ID in execution lifecycle hooks (no-changelog) (#7953) 2023-12-07 17:30:47 +01:00
ExternalSecrets ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
middleware refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00
push ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
repositories feat: Replace owner checks with scope checks (no-changelog) (#7846) 2023-11-29 14:48:36 +00:00
services fix(core): Ensure inviter and invitee are set correctly in invite link (#7943) 2023-12-07 10:53:31 +01:00
shared refactor(core): Improve instance owner setup and add unit tests (no-changelog) (#5499) 2023-02-17 10:59:09 +01:00
ActiveExecutions.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
CredentialsHelper.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
CredentialTypes.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
CurlConverterHelper.test.ts ci: Expand ESLint to tests in BE packages (no-changelog) (#6147) 2023-05-02 10:37:19 +02:00
Helpers.ts ci: Expand ESLint to tests in BE packages (no-changelog) (#6147) 2023-05-02 10:37:19 +02:00
InternalHooks.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
License.test.ts feat(core): Coordinate manual workflow activation and deactivation in multi-main scenario (#7643) 2023-11-17 15:58:50 +01:00
PermissionChecker.test.ts test(core): Improve tests for subworkflow caller policy checks (no-changelog) (#7954) 2023-12-08 11:21:43 +01:00
PostHog.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
SourceControl.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
Telemetry.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
UserManagementMailer.test.ts fix(core): Do not return inviteAcceptUrl in response if email was sent (#7465) 2023-10-19 13:58:06 +02:00
utils.test.ts refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00
WebhookHelpers.test.ts feat(core): Add Support for custom CORS origins for webhooks (#7455) 2023-11-22 17:49:56 +01:00
webhooks.test.ts feat(core): Add Support for custom CORS origins for webhooks (#7455) 2023-11-22 17:49:56 +01:00
WorkflowCredentials.test.ts refactor(core): Switch plain errors in cli to ApplicationError (#7857) 2023-11-29 12:25:10 +01:00
WorkflowExecuteAdditionalData.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
WorkflowHelpers.test.ts refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00
workflowHistoryHelper.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
WorkflowRunner.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00