From c72077e151744f16c8ad772938266bf7ec4b4549 Mon Sep 17 00:00:00 2001 From: andreybolonin Date: Tue, 22 Sep 2015 15:04:01 +0300 Subject: [PATCH 1/8] update phpseclib to 2.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 714488f..9b64a75 100644 --- a/composer.json +++ b/composer.json @@ -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", From 7c7fff6d098a21b27d56b5f195ab709f6a57dbbe Mon Sep 17 00:00:00 2001 From: andreybolonin Date: Tue, 22 Sep 2015 15:13:03 +0300 Subject: [PATCH 2/8] update package name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9b64a75..42bd909 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "league/flysystem-sftp", + "name": "andreybolonin/flysystem-sftp", "description": "Flysystem adapter for SFTP", "license": "MIT", "authors": [ From d87c325664b8f9ab286d59ad03fd96d54ac292a3 Mon Sep 17 00:00:00 2001 From: andreybolonin Date: Tue, 22 Sep 2015 15:59:32 +0300 Subject: [PATCH 3/8] fix Net_SFTP class --- src/SftpAdapter.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/SftpAdapter.php b/src/SftpAdapter.php index 5504c72..bbca7eb 100644 --- a/src/SftpAdapter.php +++ b/src/SftpAdapter.php @@ -10,7 +10,7 @@ use League\Flysystem\Config; use League\Flysystem\Util; use LogicException; -use Net_SFTP; +use phpseclib\Net\SFTP; use RuntimeException; class SftpAdapter extends AbstractFtpAdapter @@ -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; @@ -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(); } @@ -207,7 +207,7 @@ protected function listDirectoryContents($directory, $recursive = true) $path = empty($directory) ? $filename : ($directory.'/'.$filename); $result[] = $this->normalizeListingObject($path, $object); - if ($recursive && $object['type'] === NET_SFTP_TYPE_DIRECTORY) { + if ($recursive && $object['type'] === SFTP_TYPE_DIRECTORY) { $result = array_merge($result, $this->listDirectoryContents($path)); } } @@ -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; } From 6cc4c7cd2be7444d32d9d1fd2616a1804a4cc8dd Mon Sep 17 00:00:00 2001 From: andreybolonin Date: Tue, 22 Sep 2015 16:01:05 +0300 Subject: [PATCH 4/8] fix Net_SFTP class --- src/SftpAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SftpAdapter.php b/src/SftpAdapter.php index bbca7eb..9aa5c87 100644 --- a/src/SftpAdapter.php +++ b/src/SftpAdapter.php @@ -207,7 +207,7 @@ protected function listDirectoryContents($directory, $recursive = true) $path = empty($directory) ? $filename : ($directory.'/'.$filename); $result[] = $this->normalizeListingObject($path, $object); - if ($recursive && $object['type'] === SFTP_TYPE_DIRECTORY) { + if ($recursive && $object['type'] === NET_SFTP_TYPE_DIRECTORY) { $result = array_merge($result, $this->listDirectoryContents($path)); } } From 7c8d183e7149161f750fce011f329771e4664016 Mon Sep 17 00:00:00 2001 From: andreybolonin Date: Tue, 22 Sep 2015 16:50:52 +0300 Subject: [PATCH 5/8] revert package name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 42bd909..9b64a75 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "andreybolonin/flysystem-sftp", + "name": "league/flysystem-sftp", "description": "Flysystem adapter for SFTP", "license": "MIT", "authors": [ From 0739ffa8e0d401545b63b26d19018fa7d4d65e43 Mon Sep 17 00:00:00 2001 From: andreybolonin Date: Tue, 22 Sep 2015 17:04:02 +0300 Subject: [PATCH 6/8] fix tests --- src/SftpAdapter.php | 3 ++- tests/SftpAdapterTests.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/SftpAdapter.php b/src/SftpAdapter.php index 9aa5c87..4f2e2b7 100644 --- a/src/SftpAdapter.php +++ b/src/SftpAdapter.php @@ -11,6 +11,7 @@ use League\Flysystem\Util; use LogicException; use phpseclib\Net\SFTP; +use phpseclib\Crypt\RSA; use RuntimeException; class SftpAdapter extends AbstractFtpAdapter @@ -169,7 +170,7 @@ public function getPrivateKey() $this->privatekey = file_get_contents($this->privatekey); } - $key = new Crypt_RSA(); + $key = new RSA(); if ($this->password) { $key->setPassword($this->password); diff --git a/tests/SftpAdapterTests.php b/tests/SftpAdapterTests.php index 3caa517..8dbb9b5 100644 --- a/tests/SftpAdapterTests.php +++ b/tests/SftpAdapterTests.php @@ -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'); @@ -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); From dd5d22b658b1c82b2375b797e083ea46fed8d7e5 Mon Sep 17 00:00:00 2001 From: andreybolonin Date: Tue, 22 Sep 2015 17:19:56 +0300 Subject: [PATCH 7/8] fix tests --- src/SftpAdapter.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/SftpAdapter.php b/src/SftpAdapter.php index 4f2e2b7..32ed77a 100644 --- a/src/SftpAdapter.php +++ b/src/SftpAdapter.php @@ -2,7 +2,6 @@ namespace League\Flysystem\Sftp; -use Crypt_RSA; use InvalidArgumentException; use League\Flysystem\Adapter\AbstractFtpAdapter; use League\Flysystem\Adapter\Polyfill\StreamedCopyTrait; @@ -148,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() { @@ -162,7 +161,7 @@ public function getPassword() /** * Get the private get with the password or private key contents. * - * @return Crypt_RSA + * @return RSA */ public function getPrivateKey() { @@ -286,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; } From 5af2e584afb435575c232f722b2d38fde7762fad Mon Sep 17 00:00:00 2001 From: andreybolonin Date: Tue, 22 Sep 2015 17:22:13 +0300 Subject: [PATCH 8/8] fix tests --- tests/SftpAdapterTests.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/SftpAdapterTests.php b/tests/SftpAdapterTests.php index 8dbb9b5..db6c2bf 100644 --- a/tests/SftpAdapterTests.php +++ b/tests/SftpAdapterTests.php @@ -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()); } /** @@ -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); } @@ -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()); } /**