mirror of
https://github.com/projectsend/projectsend.git
synced 2026-09-16 16:45:07 +00:00
6e47d76ba6
Client file sharing, rebuilt from the ground up: a private area per client, resumable uploads, folders, groups and categories, sharing with expiry dates and download limits, comments, file versions, an activity log, a REST API, and sixteen languages. This repository begins here. ProjectSend 2 was developed privately, and that development history is not published — the previous generation remains available, with its own history, at projectsend/legacy. Free software under the GNU General Public License v2, or (at your option) any later version.
32 lines
1.1 KiB
PHP
32 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Modules\Identity\Permissions\Permission;
|
|
|
|
/*
|
|
* Staff token abilities are the Permission enum's own snake_case values.
|
|
* When client tokens arrive they will use a dot-namespaced vocabulary
|
|
* ('files.read', 'groups.read') so the two sets can never be confused for
|
|
* one another — a client scope must never accidentally satisfy a check
|
|
* written against a staff permission, or vice versa.
|
|
*
|
|
* This is the cheap half of that guarantee, asserted now while it costs
|
|
* nothing: reserve the dotted namespace by keeping every staff permission
|
|
* out of it.
|
|
*/
|
|
test('no staff permission uses the namespace reserved for client scopes', function () {
|
|
$dotted = array_filter(
|
|
Permission::cases(),
|
|
static fn (Permission $permission): bool => str_contains($permission->value, '.'),
|
|
);
|
|
|
|
expect($dotted)->toBe([]);
|
|
});
|
|
|
|
test('permission values are unique', function () {
|
|
$values = array_map(static fn (Permission $p): string => $p->value, Permission::cases());
|
|
|
|
expect($values)->toHaveCount(count(array_unique($values)));
|
|
});
|