summaryrefslogtreecommitdiff
path: root/tests/units/Auth/ReverseProxyTest.php
blob: bbab7c0db7e791f80eb9ea3492bf45050abd5f40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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']);
    }
}