chore(core): Use roles from database in global roles (#18768)

This commit is contained in:
Andreas Fitzek
2025-08-26 17:53:46 +02:00
committed by GitHub
parent cff3f4a67e
commit ecad12b77a
117 changed files with 956 additions and 424 deletions

View File

@@ -222,7 +222,7 @@ describe('Public API endpoints with feat:apiKeyScopes enabled', () => {
expect(returnedUser.id).toBe(storedUser.id);
expect(returnedUser.email).toBe(storedUser.email);
expect(returnedUser.email).toBe(payloadUser.email);
expect(storedUser.role).toBe(payloadUser.role);
expect(storedUser.role.slug).toBe(payloadUser.role);
});
test('should fail to create user when API key doesn\'t have "user:create" scope', async () => {
@@ -267,7 +267,7 @@ describe('Public API endpoints with feat:apiKeyScopes enabled', () => {
*/
expect(response.status).toBe(204);
const storedUser = await getUserById(member.id);
expect(storedUser.role).toBe(payload.newRoleName);
expect(storedUser.role.slug).toBe(payload.newRoleName);
});
test('should fail to change role when API key doesn\'t have "user:changeRole" scope', async () => {

View File

@@ -4,7 +4,7 @@ import {
testDb,
mockInstance,
} from '@n8n/backend-test-utils';
import type { User } from '@n8n/db';
import { GLOBAL_MEMBER_ROLE, type User } from '@n8n/db';
import { v4 as uuid } from 'uuid';
import validator from 'validator';
@@ -155,7 +155,7 @@ describe('With license unlimited quota:users', () => {
test('should return a pending user', async () => {
const owner = await createOwnerWithApiKey();
const { id: memberId } = await createUserShell('global:member');
const { id: memberId } = await createUserShell(GLOBAL_MEMBER_ROLE);
const authOwnerAgent = testServer.publicApiAgentFor(owner);
const response = await authOwnerAgent.get(`/users/${memberId}`).expect(200);

View File

@@ -95,7 +95,7 @@ describe('Users in Public API', () => {
expect(returnedUser.id).toBe(storedUser.id);
expect(returnedUser.email).toBe(storedUser.email);
expect(returnedUser.email).toBe(payloadUser.email);
expect(storedUser.role).toBe(payloadUser.role);
expect(storedUser.role.slug).toBe(payloadUser.role);
});
});
@@ -275,7 +275,7 @@ describe('Users in Public API', () => {
*/
expect(response.status).toBe(204);
const storedUser = await getUserById(member.id);
expect(storedUser.role).toBe(payload.newRoleName);
expect(storedUser.role.slug).toBe(payload.newRoleName);
});
});
});