@@ -29,7 +29,7 @@ protected function setUp(): void
2929 'auth.defaults.guard ' => 'ldap ' ,
3030 'services.ldap.base_dn ' => 'dc=ldap,dc=local ' ,
3131 'services.ldap.email_attribute ' => 'mail ' ,
32- 'services.ldap.display_name_attribute ' => [ 'cn ' ] ,
32+ 'services.ldap.display_name_attribute ' => 'cn ' ,
3333 'services.ldap.id_attribute ' => 'uid ' ,
3434 'services.ldap.user_to_groups ' => false ,
3535 'services.ldap.version ' => '3 ' ,
@@ -581,7 +581,7 @@ public function test_login_group_mapping_does_not_conflict_with_default_role()
581581 public function test_login_uses_specified_display_name_attribute ()
582582 {
583583 app ('config ' )->set ([
584- 'services.ldap.display_name_attribute ' => [ 'displayName ' ] ,
584+ 'services.ldap.display_name_attribute ' => 'displayName ' ,
585585 ]);
586586
587587 $ this ->commonLdapMocks (1 , 1 , 2 , 4 , 2 );
@@ -603,10 +603,37 @@ public function test_login_uses_specified_display_name_attribute()
603603 $ this ->assertDatabaseHas ('users ' , ['email ' => $ this ->mockUser ->email , 'email_confirmed ' => false , 'external_auth_id ' => $ this ->mockUser ->name , 'name ' => 'displayNameAttribute ' ]);
604604 }
605605
606+ public function test_login_uses_multiple_display_properties_if_defined ()
607+ {
608+ app ('config ' )->set ([
609+ 'services.ldap.display_name_attribute ' => 'firstname|middlename|noname|lastname ' ,
610+ ]);
611+
612+ $ this ->commonLdapMocks (1 , 1 , 1 , 2 , 1 );
613+ $ this ->mockLdap ->shouldReceive ('searchAndGetEntries ' )->times (1 )
614+ ->with ($ this ->resourceId , config ('services.ldap.base_dn ' ), \Mockery::type ('string ' ), \Mockery::type ('array ' ))
615+ ->andReturn (['count ' => 1 , 0 => [
616+ 'uid ' => [$ this ->mockUser ->name ],
617+ 'cn ' => [$ this ->mockUser ->name ],
618+ 'dn ' => 'dc=test ' . config ('services.ldap.base_dn ' ),
619+ 'firstname ' => ['Barry ' ],
620+ 'middlename ' => ['Elliott ' ],
621+ 'lastname ' => ['Chuckle ' ],
622+ 'mail ' => [$ this ->mockUser ->email ],
623+ ]]);
624+
625+ $ this ->mockUserLogin ();
626+
627+ $ this ->assertDatabaseHas ('users ' , [
628+ 'email ' => $ this ->mockUser ->email ,
629+ 'name ' => 'Barry Elliott Chuckle ' ,
630+ ]);
631+ }
632+
606633 public function test_login_uses_default_display_name_attribute_if_specified_not_present ()
607634 {
608635 app ('config ' )->set ([
609- 'services.ldap.display_name_attribute ' => [ 'displayName ' ] ,
636+ 'services.ldap.display_name_attribute ' => 'displayName ' ,
610637 ]);
611638
612639 $ this ->commonLdapMocks (1 , 1 , 2 , 4 , 2 );
0 commit comments