File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -522,9 +522,17 @@ private function validateSignerData(mixed $signer): void {
522522 throw new LibresignException ($ this ->l10n ->t ('No signers ' ));
523523 }
524524
525+ $ this ->validateSignerDisplayName ($ signer );
525526 $ this ->validateSignerIdentifyMethods ($ signer );
526527 }
527528
529+ private function validateSignerDisplayName (array $ signer ): void {
530+ if (isset ($ signer ['displayName ' ]) && strlen ($ signer ['displayName ' ]) > 64 ) {
531+ // It's an api error, don't translate
532+ throw new LibresignException ('Display name must not be longer than 64 characters ' );
533+ }
534+ }
535+
528536 private function validateSignerIdentifyMethods (array $ signer ): void {
529537 $ normalizedMethods = $ this ->normalizeIdentifyMethods ($ signer );
530538
Original file line number Diff line number Diff line change @@ -851,6 +851,60 @@ public static function providerValidateIdentifySigners(): array {
851851 true , // should throw
852852 'Invalid identify method structure '
853853 ],
854+ 'valid displayName within 64 characters ' => [
855+ [
856+ 'users ' => [
857+ [
858+ 'displayName ' => 'Valid Display Name ' ,
859+ 'identify ' => [
860+ 'account ' => 'user@example.com '
861+ ]
862+ ]
863+ ]
864+ ],
865+ false , // should not throw
866+ ],
867+ 'displayName exactly 64 characters ' => [
868+ [
869+ 'users ' => [
870+ [
871+ 'displayName ' => str_repeat ('A ' , 64 ),
872+ 'identify ' => [
873+ 'account ' => 'user@example.com '
874+ ]
875+ ]
876+ ]
877+ ],
878+ false , // should not throw
879+ ],
880+ 'displayName too long - 65 characters ' => [
881+ [
882+ 'users ' => [
883+ [
884+ 'displayName ' => str_repeat ('A ' , 65 ),
885+ 'identify ' => [
886+ 'account ' => 'user@example.com '
887+ ]
888+ ]
889+ ]
890+ ],
891+ true , // should throw
892+ 'Display name must not be longer than 64 characters '
893+ ],
894+ 'displayName too long - 100 characters ' => [
895+ [
896+ 'users ' => [
897+ [
898+ 'displayName ' => str_repeat ('B ' , 100 ),
899+ 'identify ' => [
900+ 'account ' => 'user@example.com '
901+ ]
902+ ]
903+ ]
904+ ],
905+ true , // should throw
906+ 'Display name must not be longer than 64 characters '
907+ ],
854908 ];
855909 }
856910}
You can’t perform that action at this time.
0 commit comments