Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_network_ftp_fsock_pasv_epsv_test | |
0.00% |
0 / 14 |
|
0.00% |
0 / 5 |
56 | |
0.00% |
0 / 1 |
| setUpBeforeClass | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| test_pasv | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| test_epsv | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| assert_ls_contains_debian | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
| get_object | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | require_once __DIR__ . '/../../phpBB/includes/functions_transfer.php'; |
| 15 | |
| 16 | /** |
| 17 | * @group slow |
| 18 | */ |
| 19 | class phpbb_network_ftp_fsock_pasv_epsv_test extends phpbb_test_case |
| 20 | { |
| 21 | protected static $ipv4; |
| 22 | |
| 23 | static public function setUpBeforeClass(): void |
| 24 | { |
| 25 | $hostname = 'ftp.debian.org.'; |
| 26 | self::$ipv4 = gethostbyname($hostname); |
| 27 | |
| 28 | if (self::$ipv4 == $hostname) |
| 29 | { |
| 30 | self::markTestSkipped("Got no A record back from DNS query for $hostname"); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | public function test_pasv() |
| 35 | { |
| 36 | // PASV |
| 37 | $this->assert_ls_contains_debian(self::$ipv4); |
| 38 | } |
| 39 | |
| 40 | public function test_epsv() |
| 41 | { |
| 42 | $ipv4 = self::$ipv4; |
| 43 | // EPSV |
| 44 | $this->assert_ls_contains_debian("[::ffff:$ipv4]"); |
| 45 | } |
| 46 | |
| 47 | protected function assert_ls_contains_debian($hostname) |
| 48 | { |
| 49 | $o = $this->get_object($hostname); |
| 50 | $result = $o->_init(); |
| 51 | // This test may fail on IPv6 addresses if IPv6 support is |
| 52 | // not available. PHP must be compiled with IPv6 support enabled, |
| 53 | // and your operating system must be configured for IPv6 as well. |
| 54 | if ($result !== true) |
| 55 | { |
| 56 | $this->markTestSkipped("Failed to connect to $hostname: $result"); |
| 57 | } |
| 58 | $this->assertStringContainsString('debian', $o->_ls()); |
| 59 | $o->_close(); |
| 60 | } |
| 61 | |
| 62 | protected function get_object($hostname) |
| 63 | { |
| 64 | return new ftp_fsock($hostname, 'anonymous', 'anonymous@localhost.tld', '/'); |
| 65 | } |
| 66 | } |