This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * tollwerk-admin |
||
5 | * |
||
6 | * @category Tollwerk |
||
7 | * @package Tollwerk\Admin |
||
8 | * @subpackage Tollwerk\Admin\Tests |
||
9 | * @author Joschi Kuphal <[email protected]> / @jkphl |
||
10 | * @copyright Copyright © 2018 Joschi Kuphal <[email protected]> / @jkphl |
||
11 | * @license http://opensource.org/licenses/MIT The MIT License (MIT) |
||
12 | */ |
||
13 | |||
14 | /*********************************************************************************** |
||
15 | * The MIT License (MIT) |
||
16 | * |
||
17 | * Copyright © 2018 Joschi Kuphal <[email protected]> / @jkphl |
||
18 | * |
||
19 | * Permission is hereby granted, free of charge, to any person obtaining a copy of |
||
20 | * this software and associated documentation files (the "Software"), to deal in |
||
21 | * the Software without restriction, including without limitation the rights to |
||
22 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
||
23 | * the Software, and to permit persons to whom the Software is furnished to do so, |
||
24 | * subject to the following conditions: |
||
25 | * |
||
26 | * The above copyright notice and this permission notice shall be included in all |
||
27 | * copies or substantial portions of the Software. |
||
28 | * |
||
29 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
30 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
||
31 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
||
32 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
||
33 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||
34 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
35 | ***********************************************************************************/ |
||
36 | |||
37 | namespace Tollwerk\Admin\Tests; |
||
38 | |||
39 | use PHPUnit\Framework\TestCase; |
||
40 | use Tollwerk\Admin\Domain\Factory\DomainFactory; |
||
41 | use Tollwerk\Admin\Domain\Vhost\Vhost; |
||
42 | |||
43 | /** |
||
44 | * Virtual host tests |
||
45 | * |
||
46 | * @package Tollwerk\Admin |
||
47 | * @subpackage Tollwerk\Admin\Tests |
||
48 | */ |
||
49 | class VhostTests extends TestCase |
||
50 | { |
||
51 | /** |
||
52 | * Test the instantiation of a virtual host |
||
53 | */ |
||
54 | public function testVirtualHost() |
||
55 | { |
||
56 | $domain = DomainFactory::parseString('example.com'); |
||
57 | $vhost = new Vhost($domain, __DIR__); |
||
58 | $this->assertInstanceOf(Vhost::class, $vhost); |
||
59 | $this->assertEquals($domain, $vhost->getPrimaryDomain()); |
||
60 | $this->assertEquals(__DIR__, $vhost->getDocroot()); |
||
61 | $this->assertNull($vhost->getPorts(Vhost::PROTOCOL_HTTP)); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Test setting / adding / removing secondary domains |
||
66 | * |
||
67 | * @expectedException \RuntimeException |
||
68 | * @expectedExceptionCode 1475484852 |
||
69 | */ |
||
70 | public function testVirtualHostSecondaryDomains() |
||
71 | { |
||
72 | $domain = DomainFactory::parseString('example.com'); |
||
73 | $vhost = new Vhost($domain, __DIR__); |
||
74 | $this->assertInstanceOf(Vhost::class, $vhost); |
||
75 | |||
76 | $secondaryDomainA = DomainFactory::parseString('a.example.com'); |
||
77 | $secondaryDomainB = DomainFactory::parseString('b.example.com'); |
||
78 | $secondaryDomainC = DomainFactory::parseString('c.example.com'); |
||
79 | $vhost->setSecondaryDomains([$secondaryDomainA, $secondaryDomainB]); |
||
80 | $vhost->addSecondaryDomain($secondaryDomainC); |
||
81 | $vhost->removeSecondaryDomain($secondaryDomainA); |
||
82 | $this->assertEquals($vhost->getSecondaryDomains(), [$secondaryDomainB, $secondaryDomainC]); |
||
83 | |||
84 | $vhost->setSecondaryDomains(['one', 'two']); |
||
0 ignored issues
–
show
|
|||
85 | } |
||
86 | |||
87 | /** |
||
88 | * Test the enabling / disabling the supported PHP version |
||
89 | * |
||
90 | * @expectedException \RuntimeException |
||
91 | * @expectedExceptionCode 1475485163 |
||
92 | */ |
||
93 | public function testVirtualHostPhp() |
||
94 | { |
||
95 | $domain = DomainFactory::parseString('example.com'); |
||
96 | $vhost = new Vhost($domain, __DIR__); |
||
97 | $this->assertInstanceOf(Vhost::class, $vhost); |
||
98 | |||
99 | $this->assertNull($vhost->getPhp()); |
||
100 | $vhost->setPhp('5.0'); |
||
101 | $this->assertEquals('5.0', $vhost->getPhp()); |
||
102 | $vhost->setPhp(null); |
||
103 | $this->assertNull($vhost->getPhp()); |
||
104 | $vhost->setPhp('five'); |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Test the retrieval of the port for an invalid protocol |
||
109 | */ |
||
110 | public function testVirtualHostPorts() |
||
111 | { |
||
112 | $domain = DomainFactory::parseString('example.com'); |
||
113 | $vhost = new Vhost($domain, __DIR__); |
||
114 | $this->assertInstanceOf(Vhost::class, $vhost); |
||
115 | |||
116 | $vhost->enablePort(Vhost::PROTOCOL_HTTP); |
||
117 | $this->assertEquals([Vhost::PROTOCOL_HTTP => [Vhost::PORT_HTTP_DEFAULT]], $vhost->getPorts()); |
||
118 | $this->assertEquals([Vhost::PORT_HTTP_DEFAULT], $vhost->getPorts(Vhost::PROTOCOL_HTTP)); |
||
119 | $this->assertNull($vhost->getPorts(Vhost::PROTOCOL_HTTPS)); |
||
120 | $vhost->enablePort(Vhost::PROTOCOL_HTTP, 81); |
||
121 | $vhost->disablePort(80); |
||
122 | $this->assertEquals([81], $vhost->getPorts(Vhost::PROTOCOL_HTTP)); |
||
123 | $vhost->enablePort(Vhost::PROTOCOL_HTTPS); |
||
124 | $vhost->disableProtocol(Vhost::PROTOCOL_HTTP); |
||
125 | $this->assertEquals([Vhost::PROTOCOL_HTTPS => [Vhost::PORT_HTTPS_DEFAULT]], $vhost->getPorts()); |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * Test the retrieval of the port for an invalid protocol |
||
130 | * |
||
131 | * @expectedException \RuntimeException |
||
132 | * @expectedExceptionCode 1475484081 |
||
133 | */ |
||
134 | public function testVirtualHostInvalidProtocol() |
||
135 | { |
||
136 | $domain = DomainFactory::parseString('example.com'); |
||
137 | $vhost = new Vhost($domain, __DIR__); |
||
138 | $this->assertInstanceOf(Vhost::class, $vhost); |
||
139 | |||
140 | $vhost->getPorts(4); |
||
141 | } |
||
142 | |||
143 | /** |
||
144 | * Test the enabling of an invalid port |
||
145 | * |
||
146 | * @expectedException \RuntimeException |
||
147 | * @expectedExceptionCode 1475502412 |
||
148 | */ |
||
149 | public function testVirtualHostEnableInvalidPort() |
||
150 | { |
||
151 | $domain = DomainFactory::parseString('example.com'); |
||
152 | $vhost = new Vhost($domain, __DIR__); |
||
153 | $this->assertInstanceOf(Vhost::class, $vhost); |
||
154 | |||
155 | $vhost->enablePort(Vhost::PROTOCOL_HTTP, -1); |
||
156 | } |
||
157 | |||
158 | /** |
||
159 | * Test the disabling of an invalid protocol |
||
160 | * |
||
161 | * @expectedException \RuntimeException |
||
162 | * @expectedExceptionCode 1475484081 |
||
163 | */ |
||
164 | public function testVirtualHostDisableInvalidProtocol() |
||
165 | { |
||
166 | $domain = DomainFactory::parseString('example.com'); |
||
167 | $vhost = new Vhost($domain, __DIR__); |
||
168 | $this->assertInstanceOf(Vhost::class, $vhost); |
||
169 | |||
170 | $vhost->disableProtocol(4); |
||
171 | } |
||
172 | |||
173 | /** |
||
174 | * Test setting a redirect URL |
||
175 | * |
||
176 | * @expectedException \RuntimeException |
||
177 | * @expectedExceptionCode 1475486589 |
||
178 | */ |
||
179 | public function testVirtualHostRedirectUrl() |
||
180 | { |
||
181 | $domain = DomainFactory::parseString('example.com'); |
||
182 | $vhost = new Vhost($domain, __DIR__); |
||
183 | $this->assertInstanceOf(Vhost::class, $vhost); |
||
184 | |||
185 | $vhost->setRedirectUrl('http://test.com/abc'); |
||
186 | $this->assertEquals('http://test.com/abc', $vhost->getRedirectUrl()); |
||
187 | $vhost->setRedirectUrl(null); |
||
188 | $this->assertNull($vhost->getRedirectUrl()); |
||
189 | $vhost->setRedirectUrl('invalid'); |
||
190 | } |
||
191 | |||
192 | /** |
||
193 | * Test setting a redirect status |
||
194 | * |
||
195 | * @expectedException \RuntimeException |
||
196 | * @expectedExceptionCode 1475486679 |
||
197 | */ |
||
198 | public function testVirtualHostRedirectStatus() |
||
199 | { |
||
200 | $domain = DomainFactory::parseString('example.com'); |
||
201 | $vhost = new Vhost($domain, __DIR__); |
||
202 | $this->assertInstanceOf(Vhost::class, $vhost); |
||
203 | |||
204 | $this->assertEquals(301, $vhost->getRedirectStatus()); |
||
205 | $vhost->setRedirectStatus(302); |
||
206 | $this->assertEquals(302, $vhost->getRedirectStatus()); |
||
207 | $vhost->setRedirectStatus(100); |
||
208 | } |
||
209 | } |
||
210 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: