1<?php
2
3namespace dokuwiki\plugin\pureldap\test;
4
5/**
6 * @group plugin_pureldap
7 * @group plugins
8 */
9class authTest extends \DokuWikiTest {
10
11    public function setUp(): void
12    {
13        parent::setUp();
14
15        global $conf;
16        $conf['auth'] = 'pureldap';
17        $conf['plugin']['pureldap']['base_dn'] = 'DC=example,DC=local';
18        $conf['plugin']['pureldap']['suffix'] = 'example.local';
19        $conf['plugin']['pureldap']['servers'] = ['localhost'];
20        $conf['plugin']['pureldap']['port'] = 7636;
21        $conf['plugin']['pureldap']['admin_username'] = 'vagrant';
22        $conf['plugin']['pureldap']['admin_password'] = 'vagrant';
23        $conf['plugin']['pureldap']['encryption'] = 'ssl';
24        $conf['plugin']['pureldap']['validate'] = 'self';
25    }
26
27    public function test_ADlogin() {
28        $auth = new \auth_plugin_pureldap();
29        $this->assertTrue($auth->checkPass('a.legrand', 'Foo_b_ar123!'));
30        $this->assertFalse($auth->checkPass('a.legrand', 'wrong password'));
31    }
32
33    public function test_ADloginSSO() {
34        global $conf;
35        $conf['plugin']['pureldap']['sso'] = 1;
36
37        $_SERVER['REMOTE_USER'] = 'a.legrand';
38
39        $auth = new \auth_plugin_pureldap();
40        $this->assertTrue($auth->checkPass('a.legrand', 'sso-only'));
41    }
42}
43