diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-09-06 14:28:06 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-09-06 14:28:06 -0400 |
commit | b0994ba68e7cbaa077d81006fb0f25bcbd049353 (patch) | |
tree | 218b4a1e289f1e6d05ca774486d3d259a4e5dfa7 /tests/units/Auth/ReverseProxyTest.php | |
parent | 3c0b56bc0214d2b0ad561a9001240ae73dea8e64 (diff) |
Add unit tests for LDAP and ReverseProxy auth
Diffstat (limited to 'tests/units/Auth/ReverseProxyTest.php')
-rw-r--r-- | tests/units/Auth/ReverseProxyTest.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/units/Auth/ReverseProxyTest.php b/tests/units/Auth/ReverseProxyTest.php new file mode 100644 index 00000000..bbab7c0d --- /dev/null +++ b/tests/units/Auth/ReverseProxyTest.php @@ -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']); + } +} |