Files
api/services/nginx/app/tests/Unit/Subusers/SubuserPasswordPolicyTest.php
T
Jeppe Bundgaard eef436d44b Add tests for subuser password validation and grant permission normalization
Introduce unit and API tests for subuser password policies ensuring compliance with complexity requirements. Normalize subuser grant permission handling for consistency, including support for legacy zero permissions.
2026-05-27 19:17:19 +02:00

21 lines
676 B
PHP

<?php
use objects\subusers_o;
it('accepts subuser passwords that match the shared policy', function (): void {
subusers_o::assertValidPassword('Test1234');
expect(true)->toBeTrue();
});
it('rejects subuser passwords that do not match the shared policy', function (string $password): void {
expect(fn () => subusers_o::assertValidPassword($password))
->toThrow(Exception::class, 'Password must be between 8 and 255 characters long');
})->with([
'too short' => ['Tes123'],
'missing uppercase' => ['test1234'],
'missing lowercase' => ['TEST1234'],
'missing number' => ['TestPassword'],
'too long' => [str_repeat('A', 256) . 'a1'],
]);