Add unit tests for LDAP and ReverseProxy auth
This commit is contained in:
37
tests/units/Auth/ReverseProxyTest.php
Normal file
37
tests/units/Auth/ReverseProxyTest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/../Base.php';
|
||||
|
||||
use Auth\ReverseProxy;
|
||||
use Model\User;
|
||||
|
||||
class ReverseProxyTest extends Base
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
parent::setup();
|
||||
$_SERVER = array();
|
||||
}
|
||||
|
||||
public function testFailedAuthentication()
|
||||
{
|
||||
$auth = new ReverseProxy($this->container);
|
||||
$this->assertFalse($auth->authenticate());
|
||||
}
|
||||
|
||||
public function testSuccessfulAuthentication()
|
||||
{
|
||||
$_SERVER[REVERSE_PROXY_USER_HEADER] = 'my_user';
|
||||
|
||||
$a = new ReverseProxy($this->container);
|
||||
$u = new User($this->container);
|
||||
|
||||
$this->assertTrue($a->authenticate());
|
||||
|
||||
$user = $u->getByUsername('my_user');
|
||||
$this->assertNotEmpty($user);
|
||||
$this->assertEquals(0, $user['is_admin']);
|
||||
$this->assertEquals(1, $user['is_ldap_user']);
|
||||
$this->assertEquals(1, $user['disable_login_form']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user