This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from DerManoMann/ldap_excpetion
Use correct namespace for LdapException and add test
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 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
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
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the LdapAuthentication service provider. | ||
* | ||
* (c) Martin Rademacher <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Radebatz\Silex\LdapAuth\Tests; | ||
|
||
use Monolog\Logger; | ||
use Monolog\Handler\StreamHandler; | ||
use Silex\Application; | ||
use Silex\Provider\SessionServiceProvider; | ||
use Radebatz\Silex\LdapAuth\LdapAuthenticationServiceProvider; | ||
|
||
/** | ||
* Test Ldap. | ||
*/ | ||
class LdapTest extends LdapAuthTestCase | ||
{ | ||
|
||
/** | ||
* @expectedException Symfony\Component\Security\Core\Exception\UsernameNotFoundException | ||
*/ | ||
public function testLdapExceptionSimple() | ||
{ | ||
$app = new Application(); | ||
$app['debug'] = true; | ||
$app->register(new SessionServiceProvider()); | ||
|
||
$app['logger'] = new Logger('CLI'); | ||
$app['logger']->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG)); | ||
/* | ||
*/ | ||
|
||
$serviceName = 'ldap-form'; | ||
$app->register(new LdapAuthenticationServiceProvider($serviceName)); | ||
|
||
// try the user provider with invalid Ldap configuration | ||
$app['security.ldap.'.$serviceName.'.user_provider']()->loadUserByUsername('mano'); | ||
} | ||
|
||
/** | ||
* @expectedException Symfony\Component\Security\Core\Exception\UsernameNotFoundException | ||
*/ | ||
public function testLdapExceptionHosts() | ||
{ | ||
$app = new Application(); | ||
$app['debug'] = true; | ||
$app->register(new SessionServiceProvider()); | ||
|
||
$app['logger'] = new Logger('CLI'); | ||
$app['logger']->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG)); | ||
/* | ||
*/ | ||
|
||
$serviceName = 'ldap-form'; | ||
$app->register(new LdapAuthenticationServiceProvider($serviceName), array( | ||
'security.ldap.'.$serviceName.'.options' => array( | ||
'ldap' => array( | ||
'hosts' => array( | ||
'host1', | ||
'host2', | ||
), | ||
), | ||
), | ||
)); | ||
|
||
// try the user provider with invalid Ldap configuration | ||
$app['security.ldap.'.$serviceName.'.user_provider']()->loadUserByUsername('mano'); | ||
} | ||
} |