Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update phpseclib to 2.0 #11

Merged
merged 8 commits into from
Oct 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"require": {
"php": ">=5.4.0",
"league/flysystem": "~1.0",
"phpseclib/phpseclib": "~0.3.8"
"phpseclib/phpseclib": "~2.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
Expand Down
22 changes: 11 additions & 11 deletions src/SftpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace League\Flysystem\Sftp;

use Crypt_RSA;
use InvalidArgumentException;
use League\Flysystem\Adapter\AbstractFtpAdapter;
use League\Flysystem\Adapter\Polyfill\StreamedCopyTrait;
use League\Flysystem\AdapterInterface;
use League\Flysystem\Config;
use League\Flysystem\Util;
use LogicException;
use Net_SFTP;
use phpseclib\Net\SFTP;
use phpseclib\Crypt\RSA;
use RuntimeException;

class SftpAdapter extends AbstractFtpAdapter
Expand Down Expand Up @@ -93,13 +93,13 @@ public function getDirectoryPerm()
}

/**
* Inject the Net_SFTP instance.
* Inject the SFTP instance.
*
* @param Net_SFTP $connection
* @param SFTP $connection
*
* @return $this
*/
public function setNetSftpConnection(Net_SFTP $connection)
public function setNetSftpConnection(SFTP $connection)
{
$this->connection = $connection;

Expand All @@ -111,7 +111,7 @@ public function setNetSftpConnection(Net_SFTP $connection)
*/
public function connect()
{
$this->connection = $this->connection ?: new Net_SFTP($this->host, $this->port, $this->timeout);
$this->connection = $this->connection ?: new SFTP($this->host, $this->port, $this->timeout);
$this->login();
$this->setConnectionRoot();
}
Expand Down Expand Up @@ -147,7 +147,7 @@ protected function setConnectionRoot()
/**
* Get the password, either the private key or a plain text password.
*
* @return Crypt_RSA|string
* @return RSA|string
*/
public function getPassword()
{
Expand All @@ -161,15 +161,15 @@ public function getPassword()
/**
* Get the private get with the password or private key contents.
*
* @return Crypt_RSA
* @return RSA
*/
public function getPrivateKey()
{
if (is_file($this->privatekey)) {
$this->privatekey = file_get_contents($this->privatekey);
}

$key = new Crypt_RSA();
$key = new RSA();

if ($this->password) {
$key->setPassword($this->password);
Expand Down Expand Up @@ -285,7 +285,7 @@ public function upload($path, $contents, Config $config)
$this->ensureDirectory(Util::dirname($path));
$config = Util::ensureConfig($config);

if (! $connection->put($path, $contents, NET_SFTP_STRING)) {
if (! $connection->put($path, $contents, SFTP::SOURCE_STRING)) {
return false;
}

Expand Down Expand Up @@ -466,7 +466,7 @@ public function setVisibility($path, $visibility)
*/
public function isConnected()
{
if ($this->connection instanceof Net_SFTP && $this->connection->isConnected()) {
if ($this->connection instanceof SFTP && $this->connection->isConnected()) {
return true;
}

Expand Down
10 changes: 5 additions & 5 deletions tests/SftpAdapterTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function setup()
public function adapterProvider()
{
$adapter = new Sftp(['username' => 'test', 'password' => 'test']);
$mock = Mockery::mock('Net_SFTP');
$mock = Mockery::mock('phpseclib\Net\SFTP');
$mock->shouldReceive('__toString')->andReturn('Net_SFTP');
$mock->shouldReceive('isConnected')->andReturn(true);
$mock->shouldReceive('disconnect');
Expand Down Expand Up @@ -342,7 +342,7 @@ public function testPrivateKeySetGet($filesystem, $adapter, $mock)
{
$key = 'private.key';
$this->assertEquals($adapter, $adapter->setPrivateKey($key));
$this->assertInstanceOf('Crypt_RSA', $adapter->getPrivateKey());
$this->assertInstanceOf('phpseclib\Crypt\RSA', $adapter->getPrivateKey());
}

/**
Expand All @@ -352,7 +352,7 @@ public function testPrivateKeyFileSetGet($filesystem, $adapter, $mock)
{
file_put_contents($key = __DIR__.'/some.key', 'key contents');
$this->assertEquals($adapter, $adapter->setPrivateKey($key));
$this->assertInstanceOf('Crypt_RSA', $adapter->getPrivateKey());
$this->assertInstanceOf('phpseclib\Crypt\RSA', $adapter->getPrivateKey());
@unlink($key);
}

Expand Down Expand Up @@ -383,7 +383,7 @@ public function testGetPasswordWithKey($filesystem, $adapter, $mock)
{
$key = 'private.key';
$this->assertEquals($adapter, $adapter->setPrivateKey($key));
$this->assertInstanceOf('Crypt_RSA', $adapter->getPassword());
$this->assertInstanceOf('phpseclib\Crypt\RSA', $adapter->getPassword());
}

/**
Expand Down Expand Up @@ -419,7 +419,7 @@ public function testIsConnected($filesystem, SftpAdapter $adapter, $mock)
*/
public function testIsNotConnected($filesystem, SftpAdapter $adapter)
{
$mock = Mockery::mock('Net_SFTP');
$mock = Mockery::mock('phpseclib\Net\SFTP');
$mock->shouldReceive('__toString')->andReturn('Net_SFTP');
$mock->shouldReceive('disconnect');
$mock->shouldReceive('isConnected')->andReturn(false);
Expand Down