- Provide six account types and custom combinations of wish, code review, release and management permissions, applied on each authenticated request. - Enforce frontend-only accounts when submitting, answering, widening and reverting wishes; require every contributor to have full access before skipping backend code review. - Gate code review and release decisions by their specific permissions. - Rework member management to create and edit account types, permissions and project access, and reflect those permissions throughout the console. - Update the manual and architecture docs with permission tests and end-to-end coverage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
39 lines
1.8 KiB
TypeScript
39 lines
1.8 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
accountTypeNames,
|
|
accountTypeOf,
|
|
accountTypes,
|
|
normalizePermissions,
|
|
roleFor,
|
|
rolePermissions,
|
|
wishScopeIn,
|
|
} from '@wishforge/contracts/permissions';
|
|
|
|
describe('permissions', () => {
|
|
it('names every ready-made set, and nothing else', () => {
|
|
for (const type of accountTypeNames) expect(accountTypeOf(accountTypes[type])).toBe(type);
|
|
expect(accountTypeOf({ ...accountTypes.frontend, reviewCode: true })).toBeUndefined();
|
|
expect(Object.keys(accountTypes)).toEqual([...accountTypeNames]);
|
|
});
|
|
it('lets managing include everything, and keeps only the four permissions', () => {
|
|
const extra = { wish: 'none', reviewCode: false, releases: false, manage: true, role: 'owner' } as const;
|
|
expect(normalizePermissions(extra)).toEqual(accountTypes.admin);
|
|
expect(accountTypeOf(extra)).toBe('admin');
|
|
});
|
|
it('derives the role that grants the rest', () => {
|
|
expect(roleFor(accountTypes.admin)).toBe('admin');
|
|
expect(roleFor({ ...accountTypes.frontend, releases: true })).toBe('developer');
|
|
expect(roleFor(accountTypes.releaser)).toBe('deployer');
|
|
expect(roleFor({ ...accountTypes.viewer, reviewCode: true })).toBe('viewer');
|
|
expect(rolePermissions('owner')).toEqual(accountTypes.admin);
|
|
expect(rolePermissions('developer')).toEqual(accountTypes.reviewed);
|
|
expect(rolePermissions('deployer')).toEqual(accountTypes.releaser);
|
|
});
|
|
it('lets a project raise only those the role decides for', () => {
|
|
expect(wishScopeIn(accountTypes.reviewed, false, true)).toBe('full');
|
|
expect(wishScopeIn(accountTypes.reviewed, false, false)).toBe('review');
|
|
expect(wishScopeIn(accountTypes.reviewed, true, true)).toBe('review');
|
|
expect(wishScopeIn(accountTypes.frontend, false, true)).toBe('frontend');
|
|
});
|
|
});
|