2011-08-10 16:43:43 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @package testing
|
2011-08-14 18:17:16 +02:00
|
|
|
* @copyright (c) 2011 phpBB Group
|
2011-08-10 16:43:43 +02:00
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
|
|
|
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_transfer.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group slow
|
|
|
|
*/
|
|
|
|
class phpbb_ftp_fsock_test extends phpbb_test_case
|
|
|
|
{
|
2011-08-14 13:19:09 -04:00
|
|
|
static protected $ipv4;
|
|
|
|
|
|
|
|
static public function setUpBeforeClass()
|
2011-08-10 16:43:43 +02:00
|
|
|
{
|
2011-08-11 23:10:53 +02:00
|
|
|
$hostname = 'ftp.debian.org.';
|
2011-08-14 13:19:09 -04:00
|
|
|
self::$ipv4 = gethostbyname($hostname);
|
2011-08-11 23:10:53 +02:00
|
|
|
|
2011-08-14 13:19:09 -04:00
|
|
|
if (self::$ipv4 == $hostname)
|
2011-08-10 16:43:43 +02:00
|
|
|
{
|
2011-08-14 14:33:00 -04:00
|
|
|
self::markTestSkipped("Got no A record back from DNS query for $hostname");
|
2011-08-10 16:43:43 +02:00
|
|
|
}
|
2011-08-14 13:19:09 -04:00
|
|
|
}
|
2011-08-10 16:43:43 +02:00
|
|
|
|
2011-08-14 13:19:09 -04:00
|
|
|
public function test_pasv()
|
|
|
|
{
|
2011-08-11 23:10:53 +02:00
|
|
|
// PASV
|
2011-08-14 13:19:09 -04:00
|
|
|
$this->assert_ls_contains_debian(self::$ipv4);
|
|
|
|
}
|
2011-08-11 23:10:53 +02:00
|
|
|
|
2011-08-14 13:19:09 -04:00
|
|
|
public function test_epsv()
|
|
|
|
{
|
|
|
|
$ipv4 = self::$ipv4;
|
2011-08-11 23:10:53 +02:00
|
|
|
// EPSV
|
|
|
|
$this->assert_ls_contains_debian("[::ffff:$ipv4]");
|
2011-08-10 16:43:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function assert_ls_contains_debian($hostname)
|
|
|
|
{
|
|
|
|
$o = $this->get_object($hostname);
|
2011-08-14 14:11:58 -04:00
|
|
|
$result = $o->_init();
|
|
|
|
// PHP can connect to IPv6 addresses which are IPv6-encapsulated
|
|
|
|
// IPv4 addresses on systems that don't have IPv6 connectivity,
|
|
|
|
// provided that PHP was built with IPv6 support.
|
|
|
|
// If this test fails on such an IPv6-encapsulated IPv4 address,
|
|
|
|
// check whether you disabled IPv6 support in your PHP.
|
|
|
|
if ($result !== true)
|
|
|
|
{
|
|
|
|
$this->markTestSkipped("Failed to connect to $hostname: $result");
|
|
|
|
}
|
2011-08-10 16:43:43 +02:00
|
|
|
$this->assertContains('debian', $o->_ls());
|
|
|
|
$o->_close();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function get_object($hostname)
|
|
|
|
{
|
|
|
|
return new ftp_fsock($hostname, 'anonymous', 'anonymous@localost.tld', '/');
|
|
|
|
}
|
|
|
|
}
|