-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from jonag/add_ignorePassiveAddress_option
Add the ability to configure the ignorePassiveAddress option of the FTP adapter
- Loading branch information
Showing
6 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ flysystem: | |
passive: true | ||
ssl: true | ||
timeout: 30 | ||
ignore_passive_address: ~ | ||
``` | ||
## SFTP | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the flysystem-bundle project. | ||
* | ||
* (c) Titouan Galopin <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Tests\League\FlysystemBundle\Adapter\Builder; | ||
|
||
use League\Flysystem\Adapter\Ftp; | ||
use League\FlysystemBundle\Adapter\Builder\FtpAdapterDefinitionBuilder; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class FtpAdapterDefinitionBuilderTest extends TestCase | ||
{ | ||
public function createBuilder() | ||
{ | ||
return new FtpAdapterDefinitionBuilder(); | ||
} | ||
|
||
public function provideValidOptions() | ||
{ | ||
yield 'minimal' => [[ | ||
'host' => 'ftp.example.com', | ||
'username' => 'username', | ||
'password' => 'password', | ||
]]; | ||
|
||
yield 'full' => [[ | ||
'host' => 'ftp.example.com', | ||
'username' => 'username', | ||
'password' => 'password', | ||
'port' => 21, | ||
'root' => '/path/to/root', | ||
'passive' => true, | ||
'ssl' => true, | ||
'timeout' => 30, | ||
'ignore_passive_address' => true, | ||
]]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideValidOptions | ||
*/ | ||
public function testCreateDefinition($options) | ||
{ | ||
$this->assertSame(Ftp::class, $this->createBuilder()->createDefinition($options)->getClass()); | ||
} | ||
|
||
public function testOptionsBehavior() | ||
{ | ||
$definition = $this->createBuilder()->createDefinition([ | ||
'host' => 'ftp.example.com', | ||
'username' => 'username', | ||
'password' => 'password', | ||
'port' => 21, | ||
'root' => '/path/to/root', | ||
'passive' => true, | ||
'ssl' => true, | ||
'timeout' => 30, | ||
'ignore_passive_address' => true, | ||
]); | ||
|
||
$expected = [ | ||
'port' => 21, | ||
'root' => '/path/to/root', | ||
'passive' => true, | ||
'ssl' => true, | ||
'timeout' => 30, | ||
'host' => 'ftp.example.com', | ||
'username' => 'username', | ||
'password' => 'password', | ||
'ignorePassiveAddress' => true, | ||
]; | ||
|
||
$this->assertSame(Ftp::class, $definition->getClass()); | ||
$this->assertSame($expected, $definition->getArgument(0)); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
tests/Adapter/Builder/SftpAdapterDefinitionBuilderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the flysystem-bundle project. | ||
* | ||
* (c) Titouan Galopin <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Tests\League\FlysystemBundle\Adapter\Builder; | ||
|
||
use League\Flysystem\Sftp\SftpAdapter; | ||
use League\FlysystemBundle\Adapter\Builder\SftpAdapterDefinitionBuilder; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class SftpAdapterDefinitionBuilderTest extends TestCase | ||
{ | ||
public function createBuilder() | ||
{ | ||
return new SftpAdapterDefinitionBuilder(); | ||
} | ||
|
||
public function provideValidOptions() | ||
{ | ||
yield 'minimal' => [[ | ||
'host' => 'ftp.example.com', | ||
'username' => 'username', | ||
'password' => 'password', | ||
]]; | ||
|
||
yield 'full' => [[ | ||
'host' => 'ftp.example.com', | ||
'username' => 'username', | ||
'password' => 'password', | ||
'port' => 22, | ||
'root' => '/path/to/root', | ||
'private_key' => '/path/to/or/contents/of/privatekey', | ||
'timeout' => 30, | ||
]]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideValidOptions | ||
*/ | ||
public function testCreateDefinition($options) | ||
{ | ||
$this->assertSame(SftpAdapter::class, $this->createBuilder()->createDefinition($options)->getClass()); | ||
} | ||
|
||
public function testOptionsBehavior() | ||
{ | ||
$definition = $this->createBuilder()->createDefinition([ | ||
'host' => 'ftp.example.com', | ||
'username' => 'username', | ||
'password' => 'password', | ||
'port' => 22, | ||
'root' => '/path/to/root', | ||
'private_key' => '/path/to/or/contents/of/privatekey', | ||
'timeout' => 30, | ||
]); | ||
|
||
$expected = [ | ||
'port' => 22, | ||
'root' => '/path/to/root', | ||
'private_key' => '/path/to/or/contents/of/privatekey', | ||
'timeout' => 30, | ||
'host' => 'ftp.example.com', | ||
'username' => 'username', | ||
'password' => 'password', | ||
]; | ||
|
||
$this->assertSame(SftpAdapter::class, $definition->getClass()); | ||
$this->assertSame($expected, $definition->getArgument(0)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters