ILIAS  release_8 Revision v8.24
ilWhiteListUrlValidatorTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/******************************************************************************
6 *
7 * This file is part of ILIAS, a powerful learning management system.
8 *
9 * ILIAS is licensed with the GPL-3.0, you should have received a copy
10 * of said license along with the source code.
11 *
12 * If this is not the case or you just want to try ILIAS, you'll find
13 * us at:
14 * https://www.ilias.de
15 * https://github.com/ILIAS-eLearning
16 *
17 *****************************************************************************/
18
19use PHPUnit\Framework\TestCase;
20
25class ilWhiteListUrlValidatorTest extends TestCase
26{
27 public function domainProvider(): array
28 {
29 return [
30 'Empty String / Empty Whitelist' => ['', [], false],
31 'Host without Schema / Empty Whitelist' => ['ilias.de', [], false],
32 'Schema with Host / Empty Whitelist' => ['https://ilias.de', [], false],
33 'Host without Schema' => ['ilias.de', ['ilias.de'], false],
34 'Schema with Host' => ['https://ilias.de', ['ilias.de'], true],
35 'Sub Domain' => ['https://www.ilias.de', ['ilias.de'], true],
36 'Multiple Sub Domains' => ['https://server01.www.ilias.de', ['ilias.de'], true],
37 'Multiple Sub Domains / Whitelist Entry with Leading Dot' => [
38 'https://server01.www.ilias.de',
39 ['.ilias.de'],
40 true
41 ],
42 'Multiple Sub Domains / Whitelist Entry with Sub Domain' => [
43 'https://server01.www.ilias.de',
44 ['www.ilias.de'],
45 true
46 ],
47 'Multiple Sub Domains / Whitelist Entry with Sub Domain and Leading Dot' => [
48 'https://server01.www.ilias.de',
49 ['.www.ilias.de'],
50 true
51 ],
52 'Multiple Sub Domains / Whitelist Entry with Multiple Sub Domains' => [
53 'https://server01.www.ilias.de',
54 ['server01.www.ilias.de'],
55 true
56 ],
57 'Multiple Sub Domains / Whitelist Entry with Multiple Sub Domains and Leading Dot' => [
58 'https://server01.www.ilias.de',
59 ['.server01.www.ilias.de'],
60 false
61 ],
62 ];
63 }
64
71 public function testValidator(string $domain, array $whitelist, bool $result): void
72 {
73 $this->assertSame((new ilWhiteListUrlValidator($domain, $whitelist))->isValid(), $result);
74 }
75}
return true
Class ilWhiteListUrlValidatorTest.
testValidator(string $domain, array $whitelist, bool $result)
@dataProvider domainProvider
Class ilWhiteListUrlValidator.