feat: add oauth2 login against myep

This commit is contained in:
fromme committed 2026-09-13 17:58:11 +02:00
1 parent d433d271d0
commit d63df2cc1b
18 files changed
+1599 -33

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
namespace App\Tests\Security;
use App\Security\Role;
use PHPUnit\Framework\TestCase;
class RoleTest extends TestCase
{
public function testBothEligibleRolesAreRecognised(): void
{
self::assertSame([Role::EMPLOYEE, Role::ADMIN], Role::eligibleOnly(['ROLE_ADMIN', 'ROLE_EMPLOYEE']));
}
public function testEitherRoleOnItsOwnIsEnough(): void
{
self::assertSame([Role::EMPLOYEE], Role::eligibleOnly(['ROLE_EMPLOYEE']));
self::assertSame([Role::ADMIN], Role::eligibleOnly(['ROLE_ADMIN']));
}
/**
* The whole point of the whitelist: myep knows roles this application assigns no meaning to,
* and an injected one must not become storable just because it was in the response.
*/
public function testRolesThisApplicationDoesNotKnowAreDropped(): void
{
$claimed = ['ROLE_TEAMER', 'ROLE_CUSTOMER', 'ROLE_HOUSE_MANAGER', 'ROLE_SUPER_ADMIN', 'ROLE_EMPLOYEE'];
self::assertSame([Role::EMPLOYEE], Role::eligibleOnly($claimed));
}
public function testAPendingMarkerDoesNotCountAsTheRole(): void
{
// myep strips these before exporting, but that is its policy and not our guarantee.
self::assertSame([], Role::eligibleOnly(['ROLE_ADMIN_PENDING']));
}
public function testTheOrderIsStableRegardlessOfWhatMyepSends(): void
{
self::assertSame(
Role::eligibleOnly(['ROLE_ADMIN', 'ROLE_EMPLOYEE']),
Role::eligibleOnly(['ROLE_EMPLOYEE', 'ROLE_ADMIN']),
);
}
public function testAnEmptyClaimYieldsNothing(): void
{
self::assertSame([], Role::eligibleOnly([]));
self::assertSame([], Role::eligibleOnly(['ROLE_USER']));
}
}