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.
21 lines
676 B
PHP
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'],
|
|
]);
|