mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat: RBAC (#8922)
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> Co-authored-by: Val <68596159+valya@users.noreply.github.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in> Co-authored-by: Valya Bullions <valya@n8n.io> Co-authored-by: Danny Martini <danny@n8n.io> Co-authored-by: Danny Martini <despair.blue@gmail.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: oleg <me@olegivaniv.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: Elias Meire <elias@meire.dev> Co-authored-by: Giulio Andreini <andreini@netseven.it> Co-authored-by: Giulio Andreini <g.andreini@gmail.com> Co-authored-by: Ayato Hayashi <go12limchangyong@gmail.com>
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import type { User } from '@db/entities/User';
|
||||
import { EnterpriseExecutionsService } from '@/executions/execution.service.ee';
|
||||
import { WaitTracker } from '@/WaitTracker';
|
||||
|
||||
import { createSuccessfulExecution, getAllExecutions } from './shared/db/executions';
|
||||
import { createOwner } from './shared/db/users';
|
||||
import { createWorkflow } from './shared/db/workflows';
|
||||
import { createMember, createOwner } from './shared/db/users';
|
||||
import { createWorkflow, shareWorkflowWithUsers } from './shared/db/workflows';
|
||||
import * as testDb from './shared/testDb';
|
||||
import { setupTestServer } from './shared/utils';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import { WaitTracker } from '@/WaitTracker';
|
||||
|
||||
mockInstance(EnterpriseExecutionsService);
|
||||
mockInstance(WaitTracker);
|
||||
|
||||
let testServer = setupTestServer({ endpointGroups: ['executions'] });
|
||||
const testServer = setupTestServer({ endpointGroups: ['executions'] });
|
||||
|
||||
let owner: User;
|
||||
let member: User;
|
||||
|
||||
// This is necessary for the tests to shutdown cleanly.
|
||||
mockInstance(WaitTracker);
|
||||
|
||||
const saveExecution = async ({ belongingTo }: { belongingTo: User }) => {
|
||||
const workflow = await createWorkflow({}, belongingTo);
|
||||
@@ -23,7 +23,44 @@ const saveExecution = async ({ belongingTo }: { belongingTo: User }) => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await testDb.truncate(['Execution', 'Workflow', 'SharedWorkflow']);
|
||||
testServer.license.reset();
|
||||
owner = await createOwner();
|
||||
member = await createMember();
|
||||
});
|
||||
|
||||
describe('GET /executions', () => {
|
||||
test('only returns executions of shared workflows if sharing is enabled', async () => {
|
||||
const workflow = await createWorkflow({}, owner);
|
||||
await shareWorkflowWithUsers(workflow, [member]);
|
||||
await createSuccessfulExecution(workflow);
|
||||
|
||||
const response1 = await testServer.authAgentFor(member).get('/executions').expect(200);
|
||||
expect(response1.body.data.count).toBe(0);
|
||||
|
||||
testServer.license.enable('feat:sharing');
|
||||
|
||||
const response2 = await testServer.authAgentFor(member).get('/executions').expect(200);
|
||||
expect(response2.body.data.count).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /executions/:id', () => {
|
||||
test('only returns executions of shared workflows if sharing is enabled', async () => {
|
||||
const workflow = await createWorkflow({}, owner);
|
||||
await shareWorkflowWithUsers(workflow, [member]);
|
||||
const execution = await createSuccessfulExecution(workflow);
|
||||
|
||||
await testServer.authAgentFor(member).get(`/executions/${execution.id}`).expect(404);
|
||||
|
||||
testServer.license.enable('feat:sharing');
|
||||
|
||||
const response = await testServer
|
||||
.authAgentFor(member)
|
||||
.get(`/executions/${execution.id}`)
|
||||
.expect(200);
|
||||
|
||||
expect(response.body.data.id).toBe(execution.id);
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /executions/delete', () => {
|
||||
|
||||
Reference in New Issue
Block a user