Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
/**
18
 * aws_helper unit tests.
19
 *
20
 * @package   core
21
 * @author    Peter Burnett <peterburnett@catalyst-au.net>
22
 * @copyright 2020 Catalyst IT
23
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 * @covers    \core\aws\aws_helper
25
 */
26
 
27
namespace core\aws;
28
 
29
/**
30
 * Testcase for the AWS helper.
31
 *
32
 * @package    factor_sms
33
 * @author     Peter Burnett <peterburnett@catalyst-au.net>
34
 * @copyright  2020 Catalyst IT
35
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 * @covers    \core\aws\aws_helper
37
 */
38
class aws_helper_test extends \advanced_testcase {
39
 
40
    public function test_get_proxy_string(): void {
41
        global $CFG;
42
        $this->resetAfterTest();
43
        // Confirm with no config an empty string is returned.
44
        $CFG->proxyhost = '';
45
        $this->assertEquals('', aws_helper::get_proxy_string());
46
 
47
        // Now set some configs.
48
        $CFG->proxyhost = '127.0.0.1';
49
        $CFG->proxyuser = 'user';
50
        $CFG->proxypassword = 'password';
51
        $CFG->proxyport = '1337';
52
        $this->assertEquals('user:password@127.0.0.1:1337', aws_helper::get_proxy_string());
53
 
54
        // Now change to SOCKS proxy.
55
        $CFG->proxytype = 'SOCKS5';
56
        $this->assertEquals('socks5://user:password@127.0.0.1:1337', aws_helper::get_proxy_string());
57
    }
58
 
59
}