| Línea 35... |
Línea 35... |
| 35 |
* @param string $blockedhosts the list of blocked hosts.
|
35 |
* @param string $blockedhosts the list of blocked hosts.
|
| 36 |
* @param string $allowedports the list of allowed ports.
|
36 |
* @param string $allowedports the list of allowed ports.
|
| 37 |
* @param bool $expected the expected result.
|
37 |
* @param bool $expected the expected result.
|
| 38 |
* @dataProvider curl_security_url_data_provider
|
38 |
* @dataProvider curl_security_url_data_provider
|
| 39 |
*/
|
39 |
*/
|
| 40 |
public function test_curl_security_helper_url_is_blocked($dns, $url, $blockedhosts, $allowedports, $expected) {
|
40 |
public function test_curl_security_helper_url_is_blocked($dns, $url, $blockedhosts, $allowedports, $expected): void {
|
| 41 |
$this->resetAfterTest(true);
|
41 |
$this->resetAfterTest(true);
|
| 42 |
$helper = $this->getMockBuilder('\core\files\curl_security_helper')
|
42 |
$helper = $this->getMockBuilder('\core\files\curl_security_helper')
|
| 43 |
->onlyMethods(['get_host_list_by_name'])
|
43 |
->onlyMethods(['get_host_list_by_name'])
|
| 44 |
->getMock();
|
44 |
->getMock();
|
| Línea 165... |
Línea 165... |
| 165 |
* @param string $blockedhosts the list of blocked hosts.
|
165 |
* @param string $blockedhosts the list of blocked hosts.
|
| 166 |
* @param string $allowedports the list of allowed ports.
|
166 |
* @param string $allowedports the list of allowed ports.
|
| 167 |
* @param bool $expected the expected result.
|
167 |
* @param bool $expected the expected result.
|
| 168 |
* @dataProvider curl_security_settings_data_provider
|
168 |
* @dataProvider curl_security_settings_data_provider
|
| 169 |
*/
|
169 |
*/
|
| 170 |
public function test_curl_security_helper_is_enabled($blockedhosts, $allowedports, $expected) {
|
170 |
public function test_curl_security_helper_is_enabled($blockedhosts, $allowedports, $expected): void {
|
| 171 |
$this->resetAfterTest(true);
|
171 |
$this->resetAfterTest(true);
|
| 172 |
$helper = new \core\files\curl_security_helper();
|
172 |
$helper = new \core\files\curl_security_helper();
|
| 173 |
set_config('curlsecurityblockedhosts', $blockedhosts);
|
173 |
set_config('curlsecurityblockedhosts', $blockedhosts);
|
| 174 |
set_config('curlsecurityallowedport', $allowedports);
|
174 |
set_config('curlsecurityallowedport', $allowedports);
|
| 175 |
$this->assertEquals($expected, $helper->is_enabled());
|
175 |
$this->assertEquals($expected, $helper->is_enabled());
|
| Línea 197... |
Línea 197... |
| 197 |
* @param string $host the host to validate.
|
197 |
* @param string $host the host to validate.
|
| 198 |
* @param string $blockedhosts the list of blocked hosts.
|
198 |
* @param string $blockedhosts the list of blocked hosts.
|
| 199 |
* @param bool $expected the expected result.
|
199 |
* @param bool $expected the expected result.
|
| 200 |
* @dataProvider curl_security_host_data_provider
|
200 |
* @dataProvider curl_security_host_data_provider
|
| 201 |
*/
|
201 |
*/
|
| 202 |
public function test_curl_security_helper_host_is_blocked($host, $blockedhosts, $expected) {
|
202 |
public function test_curl_security_helper_host_is_blocked($host, $blockedhosts, $expected): void {
|
| 203 |
$this->resetAfterTest(true);
|
203 |
$this->resetAfterTest(true);
|
| 204 |
$helper = new \core\files\curl_security_helper();
|
204 |
$helper = new \core\files\curl_security_helper();
|
| 205 |
set_config('curlsecurityblockedhosts', $blockedhosts);
|
205 |
set_config('curlsecurityblockedhosts', $blockedhosts);
|
| 206 |
$this->assertEquals($expected, \phpunit_util::call_internal_method($helper, 'host_is_blocked', [$host],
|
206 |
$this->assertEquals($expected, \phpunit_util::call_internal_method($helper, 'host_is_blocked', [$host],
|
| 207 |
'\core\files\curl_security_helper'));
|
207 |
'\core\files\curl_security_helper'));
|
| Línea 251... |
Línea 251... |
| 251 |
* @param int|string $port the port to validate.
|
251 |
* @param int|string $port the port to validate.
|
| 252 |
* @param string $allowedports the list of allowed ports.
|
252 |
* @param string $allowedports the list of allowed ports.
|
| 253 |
* @param bool $expected the expected result.
|
253 |
* @param bool $expected the expected result.
|
| 254 |
* @dataProvider curl_security_port_data_provider
|
254 |
* @dataProvider curl_security_port_data_provider
|
| 255 |
*/
|
255 |
*/
|
| 256 |
public function test_curl_security_helper_port_is_blocked($port, $allowedports, $expected) {
|
256 |
public function test_curl_security_helper_port_is_blocked($port, $allowedports, $expected): void {
|
| 257 |
$this->resetAfterTest(true);
|
257 |
$this->resetAfterTest(true);
|
| 258 |
$helper = new \core\files\curl_security_helper();
|
258 |
$helper = new \core\files\curl_security_helper();
|
| 259 |
set_config('curlsecurityallowedport', $allowedports);
|
259 |
set_config('curlsecurityallowedport', $allowedports);
|
| 260 |
$this->assertEquals($expected, \phpunit_util::call_internal_method($helper, 'port_is_blocked', [$port],
|
260 |
$this->assertEquals($expected, \phpunit_util::call_internal_method($helper, 'port_is_blocked', [$port],
|
| 261 |
'\core\files\curl_security_helper'));
|
261 |
'\core\files\curl_security_helper'));
|
| Línea 287... |
Línea 287... |
| 287 |
}
|
287 |
}
|
| Línea 288... |
Línea 288... |
| 288 |
|
288 |
|
| 289 |
/**
|
289 |
/**
|
| 290 |
* Test for \core\files\curl_security_helper::get_blocked_url_string().
|
290 |
* Test for \core\files\curl_security_helper::get_blocked_url_string().
|
| 291 |
*/
|
291 |
*/
|
| 292 |
public function test_curl_security_helper_get_blocked_url_string() {
|
292 |
public function test_curl_security_helper_get_blocked_url_string(): void {
|
| 293 |
$helper = new \core\files\curl_security_helper();
|
293 |
$helper = new \core\files\curl_security_helper();
|
| 294 |
$this->assertEquals(get_string('curlsecurityurlblocked', 'admin'), $helper->get_blocked_url_string());
|
294 |
$this->assertEquals(get_string('curlsecurityurlblocked', 'admin'), $helper->get_blocked_url_string());
|
| 295 |
}
|
295 |
}
|