Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit d0ca274

Browse files
committed
Added limitation filter test
1 parent 7e27250 commit d0ca274

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/AdldapTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff 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' => '[email protected]',
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
}

0 commit comments

Comments
 (0)