This repository was archived by the owner on Jul 24, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -205,4 +205,35 @@ public function testConfigLoginFallback()
205205
206206 $ this ->assertFalse ($ outcome );
207207 }
208+
209+ public function testLimitationFilter ()
210+ {
211+ $ this ->app ['config ' ]->set ('adldap_auth.limitation_filter ' , '(mail=*) ' );
212+
213+ $ credentials = [
214+ 'email ' => 'jdoe@email.com ' ,
215+ 'password ' => 'Password123 ' ,
216+ ];
217+
218+ $ mockedUser = Mockery::mock ('Adldap\Models\User ' );
219+
220+ $ mockedUser ->shouldReceive ('getAttribute ' )->andReturn ('jdoe ' );
221+
222+ $ mockedSearch = Mockery::mock ('Adldap\Classes\Search ' );
223+ $ mockedSearch ->shouldReceive ('select ' )->once ()->andReturn ($ mockedSearch )
224+ ->shouldReceive ('rawFilter ' )->once ()->withArgs (['(mail=*) ' ])->andReturn ($ mockedSearch )
225+ ->shouldReceive ('whereEquals ' )->once ()->andReturn ($ mockedSearch )
226+ ->shouldReceive ('first ' )->once ()->andReturn ($ mockedUser );
227+
228+ $ mockedUsers = Mockery::mock ('Adldap\Classes\Users ' );
229+
230+ $ mockedUsers ->shouldReceive ('search ' )->once ()->andReturn ($ mockedSearch );
231+
232+ Adldap::shouldReceive ('users ' )->once ()->andReturn ($ mockedUsers )
233+ ->shouldReceive ('authenticate ' )->once ()->andReturn (true );
234+
235+ $ outcome = Auth::attempt ($ credentials );
236+
237+ $ this ->assertTrue ($ outcome );
238+ }
208239}
You can’t perform that action at this time.
0 commit comments