404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@52.15.57.54: ~ $
<?php

declare(strict_types=1);

namespace League\Flysystem\Ftp;

use League\Flysystem\AdapterTestUtilities\RetryOnTestException;
use PHPUnit\Framework\TestCase;

use function ftp_close;

/**
 * @group ftp
 */
class FtpConnectionProviderTest extends TestCase
{
    use RetryOnTestException;

    /**
     * @var FtpConnectionProvider
     */
    private $connectionProvider;

    protected function setUp(): void
    {
        $this->retryOnException(UnableToConnectToFtpHost::class);
    }

    /**
     * @before
     */
    public function setupConnectionProvider(): void
    {
        $this->connectionProvider = new FtpConnectionProvider();
    }

    /**
     * @after
     */
    public function resetFunctionMocks(): void
    {
        reset_function_mocks();
    }

    /**
     * @test
     */
    public function connecting_successfully(): void
    {
        $options = FtpConnectionOptions::fromArray([
            'host' => 'localhost',
            'port' => 2121,
            'utf8' => true,
            'passive' => true,
            'ignorePassiveAddress' => true,
            'root' => '/home/foo/upload',
            'username' => 'foo',
            'password' => 'pass',
        ]);

        $this->runScenario(function () use ($options) {
            $connection = $this->connectionProvider->createConnection($options);
            $this->assertTrue(ftp_close($connection));
        });
    }

    /**
     * @test
     */
    public function not_being_able_to_enable_uft8_mode(): void
    {
        $options = FtpConnectionOptions::fromArray([
            'host' => 'localhost',
            'port' => 2121,
            'utf8' => true,
            'root' => '/home/foo/upload',
            'username' => 'foo',
            'password' => 'pass',
       ]);

        mock_function('ftp_raw', ['Error']);

        $this->expectException(UnableToEnableUtf8Mode::class);

        $this->runScenario(function () use ($options) {
            $this->connectionProvider->createConnection($options);
        });
    }

    /**
     * @test
     */
    public function uft8_mode_already_active_by_server(): void
    {
        $options = FtpConnectionOptions::fromArray([
            'host' => 'localhost',
            'port' => 2121,
            'utf8' => true,
            'root' => '/home/foo/upload',
            'username' => 'foo',
            'password' => 'pass',
       ]);

        mock_function('ftp_raw', ['202 UTF8 mode is always enabled. No need to send this command.']);
        $this->expectNotToPerformAssertions();

        $this->runScenario(function () use ($options) {
            $this->connectionProvider->createConnection($options);
        });
    }

    /**
     * @test
     */
    public function not_being_able_to_ignore_the_passive_address(): void
    {
        $options = FtpConnectionOptions::fromArray([
            'host' => 'localhost',
            'port' => 2121,
            'ignorePassiveAddress' => true,
            'root' => '/home/foo/upload',
            'username' => 'foo',
            'password' => 'pass',
       ]);

        mock_function('ftp_set_option', false);

        $this->expectException(UnableToSetFtpOption::class);

        $this->runScenario(function () use ($options) {
            $this->connectionProvider->createConnection($options);
        });
    }

    /**
     * @test
     */
    public function not_being_able_to_make_the_connection_passive(): void
    {
        $options = FtpConnectionOptions::fromArray([
            'host' => 'localhost',
            'port' => 2121,
            'utf8' => true,
            'root' => '/home/foo/upload',
            'username' => 'foo',
            'password' => 'pass',
       ]);

        mock_function('ftp_pasv', false);

        $this->expectException(UnableToMakeConnectionPassive::class);

        $this->runScenario(function () use ($options) {
            $this->connectionProvider->createConnection($options);
        });
    }

    /**
     * @test
     */
    public function not_being_able_to_connect(): void
    {
        $this->dontRetryOnException();

        $options = FtpConnectionOptions::fromArray([
           'host' => 'localhost',
           'port' => 313131,
           'root' => '/home/foo/upload',
           'username' => 'foo',
           'password' => 'pass',
        ]);

        $this->expectException(UnableToConnectToFtpHost::class);

        $this->connectionProvider->createConnection($options);
    }

    /**
     * @test
     */
    public function not_being_able_to_connect_over_ssl(): void
    {
        $this->dontRetryOnException();

        $options = FtpConnectionOptions::fromArray([
           'host' => 'localhost',
           'ssl' => true,
           'port' => 313131,
           'root' => '/home/foo/upload',
           'username' => 'foo',
           'password' => 'pass',
        ]);

        $this->expectException(UnableToConnectToFtpHost::class);

        $this->connectionProvider->createConnection($options);
    }

    /**
     * @test
     */
    public function not_being_able_to_authenticate(): void
    {
        $options = FtpConnectionOptions::fromArray([
           'host' => 'localhost',
           'port' => 2121,
           'root' => '/home/foo/upload',
           'username' => 'foo',
           'password' => 'lolnope',
       ]);

        $this->expectException(UnableToAuthenticate::class);
        $this->retryOnException(UnableToConnectToFtpHost::class);
        $this->runScenario(function () use ($options) {
            $this->connectionProvider->createConnection($options);
        });
    }
}

Filemanager

Name Type Size Permission Actions
.github Folder 0755
.gitattributes File 154 B 0644
ConnectionProvider.php File 221 B 0644
ConnectivityChecker.php File 216 B 0644
ConnectivityCheckerThatCanFail.php File 678 B 0644
FtpAdapter.php File 21.83 KB 0644
FtpAdapterTest.php File 2.85 KB 0644
FtpAdapterTestCase.php File 11.47 KB 0644
FtpConnectionException.php File 185 B 0644
FtpConnectionOptions.php File 3.01 KB 0644
FtpConnectionProvider.php File 3.11 KB 0644
FtpConnectionProviderTest.php File 5.67 KB 0644
FtpdAdapterTest.php File 761 B 0644
InvalidListResponseReceived.php File 237 B 0644
NoopCommandConnectivityChecker.php File 628 B 0644
NoopCommandConnectivityCheckerTest.php File 1.62 KB 0644
README.md File 289 B 0644
RawListFtpConnectivityChecker.php File 450 B 0644
RawListFtpConnectivityCheckerTest.php File 1.13 KB 0644
UnableToAuthenticate.php File 316 B 0644
UnableToConnectToFtpHost.php File 467 B 0644
UnableToEnableUtf8Mode.php File 198 B 0644
UnableToMakeConnectionPassive.php File 199 B 0644
UnableToResolveConnectionRoot.php File 955 B 0644
UnableToSetFtpOption.php File 368 B 0644
composer.json File 663 B 0644