feat(identity): redesign identity module and introduce RBAC foundation
- Redesign the Identity module with a richer domain model. - Extend the User entity to support username, Authentik integration, activity tracking, and storage information. - Add Role and Permission domain models with many-to-many relationships. - Implement RBAC foundation using UserRole, RolePermission, and UserPermission mappings. - Add user storage quota and usage fields with default values. - Introduce Authentik identifiers and synchronization metadata. - Refactor user domain logic for role and permission management. - Update Prisma schema to support the new identity architecture. - Improve JWT authentication and permission guard integration. - Update repositories, handlers, controllers, mappers, DTOs, and Swagger configuration. - Refresh environment configuration and project dependencies.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import test from '@playwright/test';
|
||||
import { requestPatch } from '../../helpers/request';
|
||||
|
||||
const { expect } = test;
|
||||
|
||||
test.describe('Users - PATCH /users/:id/enable', () => {
|
||||
test('should return 404 for non-existing user', async () => {
|
||||
const res = await requestPatch('/users/non-existing-id/enable');
|
||||
expect([404, 400, 500]).toContain(res.status);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import test from '@playwright/test';
|
||||
import { requestGet } from '../../helpers/request';
|
||||
|
||||
const { expect } = test;
|
||||
|
||||
test.describe('Users - GET /users/me', () => {
|
||||
test('should return current user when token provided', async () => {
|
||||
const res = await requestGet('/users/me');
|
||||
expect(res.status).toBeGreaterThanOrEqual(200);
|
||||
expect(res.status).toBeLessThan(300);
|
||||
expect(res.body.success).toBe(true);
|
||||
expect(res.body.data).toBeDefined();
|
||||
expect(res.body.data.email).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should be unauthorized without token', async () => {
|
||||
const res = await requestGet('/users/me', null);
|
||||
expect(res.status).toBe(401);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import test from '@playwright/test';
|
||||
import { requestGet } from '../../helpers/request';
|
||||
|
||||
const { expect } = test;
|
||||
|
||||
test.describe('Users - GET /users/:id', () => {
|
||||
test('should return 404 for non-existing user', async () => {
|
||||
const res = await requestGet('/users/non-existing-id');
|
||||
expect([404, 400, 500]).toContain(res.status);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import test from '@playwright/test';
|
||||
import { requestGet } from '../../helpers/request';
|
||||
|
||||
|
||||
const { expect } = test;
|
||||
|
||||
test.describe('Users - GET /users', () => {
|
||||
test('should return list of users (authorized)', async () => {
|
||||
const res = await requestGet('/users');
|
||||
|
||||
expect(res.status).toBeGreaterThanOrEqual(200);
|
||||
expect(res.status).toBeLessThan(300);
|
||||
expect(res.body).toBeTruthy();
|
||||
expect(res.body.success).toBe(true);
|
||||
expect(res.body.data).toBeInstanceOf(Array);
|
||||
expect(res.body.meta).toBeDefined();
|
||||
});
|
||||
|
||||
test('should return unauthorized when missing token', async () => {
|
||||
const res = await requestGet('/users', null);
|
||||
expect(res.status).toBe(401);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user