This repository has been archived by the owner on Jul 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df9176f
commit 2074e33
Showing
1 changed file
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,9 +131,43 @@ public function test_auth_fails_when_user_not_found() | |
$this->assertFalse(Auth::attempt(['email' => '[email protected]', 'password' => '12345'])); | ||
} | ||
|
||
public function test_credentials_key_does_not_exist() | ||
public function test_config_limitation_filter() | ||
{ | ||
$this->assertFalse(Auth::attempt(['non-existent-key' => '[email protected]', 'password' => '12345'])); | ||
$filter = '(cn=John Doe)'; | ||
|
||
$expectedFilter = '(&(cn=John Doe)(objectclass=\70\65\72\73\6f\6e)(objectcategory=\70\65\72\73\6f\6e)(mail=\6a\64\6f\65\40\65\6d\61\69\6c\2e\63\6f\6d))'; | ||
|
||
$this->app['config']->set('adldap_auth.limitation_filter', $filter); | ||
|
||
$user = $this->getMockUser([ | ||
'cn' => '', | ||
'mail' => '[email protected]', | ||
'samaccountname' => 'jdoe', | ||
]); | ||
|
||
$connection = $this->getMockConnection(); | ||
|
||
$connection->expects($this->exactly(1))->method('isBound')->willReturn(true); | ||
|
||
$connection->expects($this->exactly(1))->method('search')->with( | ||
$this->equalTo(''), | ||
$this->equalTo($expectedFilter), | ||
$this->equalTo([]) | ||
)->willReturn('resource'); | ||
|
||
$connection->expects($this->exactly(1))->method('getEntries')->willReturn([ | ||
'count' => 1, | ||
$user->getAttributes(), | ||
]); | ||
|
||
$connection->expects($this->exactly(2))->method('bind') | ||
->with($this->logicalOr( | ||
$this->equalTo('jdoe'), | ||
$this->equalTo('admin') | ||
)) | ||
->willReturn(true); | ||
|
||
$this->assertTrue(Auth::attempt(['email' => '[email protected]', 'password' => 'password'])); | ||
} | ||
|
||
public function test_config_callback_attribute_handler() | ||
|