@@ -32,7 +32,7 @@ protected function setUp(): void
3232 'services.ldap.id_attribute ' => 'uid ' ,
3333 'services.ldap.user_to_groups ' => false ,
3434 'services.ldap.version ' => '3 ' ,
35- 'services.ldap.user_filter ' => '(&(uid=$ {user})) ' ,
35+ 'services.ldap.user_filter ' => '(&(uid={user})) ' ,
3636 'services.ldap.follow_referrals ' => false ,
3737 'services.ldap.tls_insecure ' => false ,
3838 'services.ldap.thumbnail_attribute ' => null ,
@@ -178,6 +178,38 @@ public function test_a_custom_uid_attribute_can_be_specified_and_is_used_properl
178178 $ this ->assertDatabaseHas ('users ' , ['email ' => $ this ->mockUser ->email , 'email_confirmed ' => false , 'external_auth_id ' => 'cooluser456 ' ]);
179179 }
180180
181+ public function test_user_filter_default_placeholder_format ()
182+ {
183+ config ()->set ('services.ldap.user_filter ' , '(&(uid={user})) ' );
184+ $ this ->mockUser ->name = 'barryldapuser ' ;
185+ $ expectedFilter = '(&(uid=\62\61\72\72\79\6c\64\61\70\75\73\65\72)) ' ;
186+
187+ $ this ->commonLdapMocks (1 , 1 , 1 , 1 , 1 );
188+ $ this ->mockLdap ->shouldReceive ('searchAndGetEntries ' )
189+ ->once ()
190+ ->with ($ this ->resourceId , config ('services.ldap.base_dn ' ), $ expectedFilter , \Mockery::type ('array ' ))
191+ ->andReturn (['count ' => 0 , 0 => []]);
192+
193+ $ resp = $ this ->mockUserLogin ();
194+ $ resp ->assertRedirect ('/login ' );
195+ }
196+
197+ public function test_user_filter_old_placeholder_format ()
198+ {
199+ config ()->set ('services.ldap.user_filter ' , '(&(username=${user})) ' );
200+ $ this ->mockUser ->name = 'barryldapuser ' ;
201+ $ expectedFilter = '(&(username=\62\61\72\72\79\6c\64\61\70\75\73\65\72)) ' ;
202+
203+ $ this ->commonLdapMocks (1 , 1 , 1 , 1 , 1 );
204+ $ this ->mockLdap ->shouldReceive ('searchAndGetEntries ' )
205+ ->once ()
206+ ->with ($ this ->resourceId , config ('services.ldap.base_dn ' ), $ expectedFilter , \Mockery::type ('array ' ))
207+ ->andReturn (['count ' => 0 , 0 => []]);
208+
209+ $ resp = $ this ->mockUserLogin ();
210+ $ resp ->assertRedirect ('/login ' );
211+ }
212+
181213 public function test_initial_incorrect_credentials ()
182214 {
183215 $ this ->commonLdapMocks (1 , 1 , 1 , 0 , 1 );
0 commit comments