Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 24... Línea 24...
24
 *
24
 *
25
 * @package    core
25
 * @package    core
26
 * @copyright  2016 Jake Dallimore <jrhdallimore@gmail.com>
26
 * @copyright  2016 Jake Dallimore <jrhdallimore@gmail.com>
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 */
28
 */
29
class curl_security_helper_test extends \advanced_testcase {
29
final class curl_security_helper_test extends \advanced_testcase {
30
    /**
30
    /**
31
     * Test for \core\files\curl_security_helper::url_is_blocked().
31
     * Test for \core\files\curl_security_helper::url_is_blocked().
32
     *
32
     *
33
     * @param array $dns a mapping between hosts and IPs to be used instead of a real DNS lookup. The values must be arrays.
33
     * @param array $dns a mapping between hosts and IPs to be used instead of a real DNS lookup. The values must be arrays.
34
     * @param string $url the url to validate.
34
     * @param string $url the url to validate.
Línea 60... Línea 60...
60
    /**
60
    /**
61
     * Data provider for test_curl_security_helper_url_is_blocked().
61
     * Data provider for test_curl_security_helper_url_is_blocked().
62
     *
62
     *
63
     * @return array
63
     * @return array
64
     */
64
     */
65
    public function curl_security_url_data_provider() {
65
    public static function curl_security_url_data_provider(): array {
66
        $simpledns = ['localhost' => ['127.0.0.1']];
66
        $simpledns = ['localhost' => ['127.0.0.1']];
67
        $multiplerecorddns = [
67
        $multiplerecorddns = [
68
            'sub.example.com' => ['1.2.3.4', '5.6.7.8']
68
            'sub.example.com' => ['1.2.3.4', '5.6.7.8']
69
        ];
69
        ];
70
        // Format: url, blocked hosts, allowed ports, expected result.
70
        // Format: url, blocked hosts, allowed ports, expected result.
Línea 178... Línea 178...
178
    /**
178
    /**
179
     * Data provider for test_curl_security_helper_is_enabled().
179
     * Data provider for test_curl_security_helper_is_enabled().
180
     *
180
     *
181
     * @return array
181
     * @return array
182
     */
182
     */
183
    public function curl_security_settings_data_provider() {
183
    public static function curl_security_settings_data_provider(): array {
184
        // Format: blocked hosts, allowed ports, expected result.
184
        // Format: blocked hosts, allowed ports, expected result.
185
        return [
185
        return [
186
            ["", "", false],
186
            ["", "", false],
187
            ["127.0.0.1", "", true],
187
            ["127.0.0.1", "", true],
188
            ["localhost", "", true],
188
            ["localhost", "", true],
Línea 210... Línea 210...
210
    /**
210
    /**
211
     * Data provider for test_curl_security_helper_host_is_blocked().
211
     * Data provider for test_curl_security_helper_host_is_blocked().
212
     *
212
     *
213
     * @return array
213
     * @return array
214
     */
214
     */
215
    public function curl_security_host_data_provider() {
215
    public static function curl_security_host_data_provider(): array {
216
        return [
216
        return [
217
            // IPv4 hosts.
217
            // IPv4 hosts.
218
            ["127.0.0.1", "127.0.0.1", true],
218
            ["127.0.0.1", "127.0.0.1", true],
219
            ["127.0.0.1", "127.0.0.0/24", true],
219
            ["127.0.0.1", "127.0.0.0/24", true],
220
            ["127.0.0.1", "127.0.0.0-40", true],
220
            ["127.0.0.1", "127.0.0.0-40", true],
Línea 264... Línea 264...
264
    /**
264
    /**
265
     * Data provider for test_curl_security_helper_port_is_blocked().
265
     * Data provider for test_curl_security_helper_port_is_blocked().
266
     *
266
     *
267
     * @return array
267
     * @return array
268
     */
268
     */
269
    public function curl_security_port_data_provider() {
269
    public static function curl_security_port_data_provider(): array {
270
        return [
270
        return [
271
            ["", "80\n443", true],
271
            ["", "80\n443", true],
272
            [" ", "80\n443", true],
272
            [" ", "80\n443", true],
273
            ["-1", "80\n443", true],
273
            ["-1", "80\n443", true],
274
            [-1, "80\n443", true],
274
            [-1, "80\n443", true],