From 00deffdd4780968915ac0ee2b7c3c9da0175dd14 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 13 Aug 2015 16:28:44 +0200 Subject: [PATCH] update icewind/smb to 1.0.3 --- apps/files_external/3rdparty/.gitignore | 1 + apps/files_external/3rdparty/composer.json | 2 +- apps/files_external/3rdparty/composer.lock | 14 +- .../3rdparty/composer/installed.json | 12 +- .../3rdparty/icewind/smb/.travis.yml | 20 +- .../icewind/smb/install_libsmbclient.sh | 8 + .../3rdparty/icewind/smb/src/NativeServer.php | 7 +- .../3rdparty/icewind/smb/src/NativeShare.php | 11 +- .../3rdparty/icewind/smb/src/Server.php | 33 +- .../3rdparty/icewind/smb/src/Share.php | 12 +- .../icewind/smb/tests/AbstractShare.php | 539 ------------------ .../icewind/smb/tests/NativeShare.php | 27 - .../icewind/smb/tests/NativeStream.php | 143 ----- .../3rdparty/icewind/smb/tests/Parser.php | 103 ---- .../3rdparty/icewind/smb/tests/Server.php | 57 -- .../3rdparty/icewind/smb/tests/Share.php | 24 - .../3rdparty/icewind/smb/tests/bootstrap.php | 9 - .../3rdparty/icewind/smb/tests/config.json | 7 - .../3rdparty/icewind/smb/tests/phpunit.xml | 6 - 19 files changed, 81 insertions(+), 954 deletions(-) create mode 100755 apps/files_external/3rdparty/icewind/smb/install_libsmbclient.sh delete mode 100644 apps/files_external/3rdparty/icewind/smb/tests/AbstractShare.php delete mode 100644 apps/files_external/3rdparty/icewind/smb/tests/NativeShare.php delete mode 100644 apps/files_external/3rdparty/icewind/smb/tests/NativeStream.php delete mode 100644 apps/files_external/3rdparty/icewind/smb/tests/Parser.php delete mode 100644 apps/files_external/3rdparty/icewind/smb/tests/Server.php delete mode 100644 apps/files_external/3rdparty/icewind/smb/tests/Share.php delete mode 100644 apps/files_external/3rdparty/icewind/smb/tests/bootstrap.php delete mode 100644 apps/files_external/3rdparty/icewind/smb/tests/config.json delete mode 100644 apps/files_external/3rdparty/icewind/smb/tests/phpunit.xml diff --git a/apps/files_external/3rdparty/.gitignore b/apps/files_external/3rdparty/.gitignore index a9a7266a62..8a84deb27c 100644 --- a/apps/files_external/3rdparty/.gitignore +++ b/apps/files_external/3rdparty/.gitignore @@ -1 +1,2 @@ example.php +icewind/smb/tests diff --git a/apps/files_external/3rdparty/composer.json b/apps/files_external/3rdparty/composer.json index 9680d92e54..563047dfd1 100644 --- a/apps/files_external/3rdparty/composer.json +++ b/apps/files_external/3rdparty/composer.json @@ -6,7 +6,7 @@ "vendor-dir": "." }, "require": { - "icewind/smb": "1.0.1", + "icewind/smb": "1.0.3", "icewind/streams": "0.2" } } diff --git a/apps/files_external/3rdparty/composer.lock b/apps/files_external/3rdparty/composer.lock index 84fbb046d5..96eac7f28f 100644 --- a/apps/files_external/3rdparty/composer.lock +++ b/apps/files_external/3rdparty/composer.lock @@ -1,23 +1,23 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "7b46d64e33feb600c5f0ec830b211e6f", + "hash": "2c7c72fe357eb667fbd9921bad770ecd", "packages": [ { "name": "icewind/smb", - "version": "v1.0.1", + "version": "v1.0.3", "source": { "type": "git", "url": "https://github.com/icewind1991/SMB.git", - "reference": "8041bc1960bf2da94e60b88b34e5c78300eac476" + "reference": "33ab10cc4d5c3e48cba3a074b5f9fc67590cd032" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/icewind1991/SMB/zipball/8041bc1960bf2da94e60b88b34e5c78300eac476", - "reference": "8041bc1960bf2da94e60b88b34e5c78300eac476", + "url": "https://api.github.com/repos/icewind1991/SMB/zipball/33ab10cc4d5c3e48cba3a074b5f9fc67590cd032", + "reference": "33ab10cc4d5c3e48cba3a074b5f9fc67590cd032", "shasum": "" }, "require": { @@ -45,7 +45,7 @@ } ], "description": "php wrapper for smbclient and libsmbclient-php", - "time": "2015-04-20 11:16:24" + "time": "2015-08-13 14:19:03" }, { "name": "icewind/streams", diff --git a/apps/files_external/3rdparty/composer/installed.json b/apps/files_external/3rdparty/composer/installed.json index 42e8fdd29d..db2da5d45b 100644 --- a/apps/files_external/3rdparty/composer/installed.json +++ b/apps/files_external/3rdparty/composer/installed.json @@ -43,17 +43,17 @@ }, { "name": "icewind/smb", - "version": "v1.0.1", - "version_normalized": "1.0.1.0", + "version": "v1.0.3", + "version_normalized": "1.0.3.0", "source": { "type": "git", "url": "https://github.com/icewind1991/SMB.git", - "reference": "8041bc1960bf2da94e60b88b34e5c78300eac476" + "reference": "33ab10cc4d5c3e48cba3a074b5f9fc67590cd032" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/icewind1991/SMB/zipball/8041bc1960bf2da94e60b88b34e5c78300eac476", - "reference": "8041bc1960bf2da94e60b88b34e5c78300eac476", + "url": "https://api.github.com/repos/icewind1991/SMB/zipball/33ab10cc4d5c3e48cba3a074b5f9fc67590cd032", + "reference": "33ab10cc4d5c3e48cba3a074b5f9fc67590cd032", "shasum": "" }, "require": { @@ -63,7 +63,7 @@ "require-dev": { "satooshi/php-coveralls": "dev-master" }, - "time": "2015-04-20 11:16:24", + "time": "2015-08-13 14:19:03", "type": "library", "installation-source": "source", "autoload": { diff --git a/apps/files_external/3rdparty/icewind/smb/.travis.yml b/apps/files_external/3rdparty/icewind/smb/.travis.yml index c1ac3727d0..bb2a875c39 100644 --- a/apps/files_external/3rdparty/icewind/smb/.travis.yml +++ b/apps/files_external/3rdparty/icewind/smb/.travis.yml @@ -3,21 +3,29 @@ php: - 5.3 - 5.4 - 5.5 + - 5.6 + - 7.0 + +env: + + +matrix: + allow_failures: + - php: 7.0 env: global: - CURRENT_DIR=`pwd` + matrix: + - BACKEND=smbclient + - BACKEND=libsmbclient before_install: - pass=$(perl -e 'print crypt("test", "password")') - sudo useradd -m -p $pass test - sudo apt-get update -qq - - sudo apt-get install samba smbclient libsmbclient-dev libsmbclient - - wget -O /tmp/libsmbclient-php.zip https://github.com/eduardok/libsmbclient-php/archive/master.zip - - unzip /tmp/libsmbclient-php.zip -d /tmp - - cd /tmp/libsmbclient-php-master - - phpize && ./configure && make && sudo make install - - echo 'extension="libsmbclient.so"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini + - sudo apt-get install samba smbclient + - if [ "$BACKEND" == 'libsmbclient' ]; then ./install_libsmbclient.sh; fi - cd $CURRENT_DIR - chmod go+w $HOME - printf "%s\n%s\n" test test|sudo smbpasswd -s test diff --git a/apps/files_external/3rdparty/icewind/smb/install_libsmbclient.sh b/apps/files_external/3rdparty/icewind/smb/install_libsmbclient.sh new file mode 100755 index 0000000000..63544e3ee1 --- /dev/null +++ b/apps/files_external/3rdparty/icewind/smb/install_libsmbclient.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +sudo apt-get install libsmbclient-dev libsmbclient +wget -O /tmp/libsmbclient-php.zip https://github.com/eduardok/libsmbclient-php/archive/master.zip +unzip /tmp/libsmbclient-php.zip -d /tmp +cd /tmp/libsmbclient-php-master +phpize && ./configure && make && sudo make install +echo 'extension="libsmbclient.so"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini diff --git a/apps/files_external/3rdparty/icewind/smb/src/NativeServer.php b/apps/files_external/3rdparty/icewind/smb/src/NativeServer.php index 4628e3ec10..ce8e6d636a 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/NativeServer.php +++ b/apps/files_external/3rdparty/icewind/smb/src/NativeServer.php @@ -24,12 +24,7 @@ class NativeServer extends Server { } protected function connect() { - $user = $this->getUser(); - $workgroup = null; - if (strpos($user, '/')) { - list($workgroup, $user) = explode($user, '/'); - } - $this->state->init($workgroup, $user, $this->getPassword()); + $this->state->init($this->getWorkgroup(), $this->getUser(), $this->getPassword()); } /** diff --git a/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php b/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php index c84e961166..ecef8c744c 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php +++ b/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php @@ -43,15 +43,7 @@ class NativeShare implements IShare { return; } - $user = $this->server->getUser(); - if (strpos($user, '/')) { - list($workgroup, $user) = explode('/', $user); - } elseif (strpos($user, '\\')) { - list($workgroup, $user) = explode('\\', $user); - } else { - $workgroup = null; - } - $this->state->init($workgroup, $user, $this->server->getPassword()); + $this->state->init($this->server->getWorkgroup(), $this->server->getUser(), $this->server->getPassword()); } /** @@ -149,6 +141,7 @@ class NativeShare implements IShare { * @throws \Icewind\SMB\Exception\InvalidTypeException */ public function del($path) { + $this->connect(); return $this->state->unlink($this->buildUrl($path)); } diff --git a/apps/files_external/3rdparty/icewind/smb/src/Server.php b/apps/files_external/3rdparty/icewind/smb/src/Server.php index f7227d4bae..5c07d1c517 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/Server.php +++ b/apps/files_external/3rdparty/icewind/smb/src/Server.php @@ -29,6 +29,11 @@ class Server { */ protected $password; + /** + * @var string $workgroup + */ + protected $workgroup; + /** * Check if the smbclient php extension is available * @@ -45,10 +50,28 @@ class Server { */ public function __construct($host, $user, $password) { $this->host = $host; + list($workgroup, $user) = $this->splitUser($user); $this->user = $user; + $this->workgroup = $workgroup; $this->password = $password; } + /** + * Split workgroup from username + * + * @param $user + * @return string[] [$workgroup, $user] + */ + public function splitUser($user) { + if (strpos($user, '/')) { + return explode('/', $user, 2); + } elseif (strpos($user, '\\')) { + return explode('\\', $user); + } else { + return [null, $user]; + } + } + /** * @return string */ @@ -77,6 +100,13 @@ class Server { return $this->host; } + /** + * @return string + */ + public function getWorkgroup() { + return $this->workgroup; + } + /** * @return \Icewind\SMB\IShare[] * @@ -84,7 +114,8 @@ class Server { * @throws \Icewind\SMB\Exception\InvalidHostException */ public function listShares() { - $command = Server::CLIENT . ' --authentication-file=/proc/self/fd/3' . + $workgroupArgument = ($this->workgroup) ? ' -W ' . escapeshellarg($this->workgroup) : ''; + $command = Server::CLIENT . $workgroupArgument . ' --authentication-file=/proc/self/fd/3' . ' -gL ' . escapeshellarg($this->getHost()); $connection = new RawConnection($command); $connection->writeAuthentication($this->getUser(), $this->getPassword()); diff --git a/apps/files_external/3rdparty/icewind/smb/src/Share.php b/apps/files_external/3rdparty/icewind/smb/src/Share.php index 7c24f9f2e9..8657e698af 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/Share.php +++ b/apps/files_external/3rdparty/icewind/smb/src/Share.php @@ -57,8 +57,10 @@ class Share implements IShare { if ($this->connection and $this->connection->isValid()) { return; } - $command = sprintf('%s --authentication-file=/proc/self/fd/3 //%s/%s', + $workgroupArgument = ($this->server->getWorkgroup()) ? ' -W ' . escapeshellarg($this->server->getWorkgroup()) : ''; + $command = sprintf('%s %s --authentication-file=/proc/self/fd/3 //%s/%s', Server::CLIENT, + $workgroupArgument, $this->server->getHost(), $this->name ); @@ -260,8 +262,10 @@ class Share implements IShare { $source = str_replace('\'', '\'"\'"\'', $source); // since returned stream is closed by the caller we need to create a new instance // since we can't re-use the same file descriptor over multiple calls - $command = sprintf('%s --authentication-file=/proc/self/fd/3 //%s/%s -c \'get %s /proc/self/fd/5\'', + $workgroupArgument = ($this->server->getWorkgroup()) ? ' -W ' . escapeshellarg($this->server->getWorkgroup()) : ''; + $command = sprintf('%s %s --authentication-file=/proc/self/fd/3 //%s/%s -c \'get %s /proc/self/fd/5\'', Server::CLIENT, + $workgroupArgument, $this->server->getHost(), $this->name, $source @@ -288,8 +292,10 @@ class Share implements IShare { $target = str_replace('\'', '\'"\'"\'', $target); // since returned stream is closed by the caller we need to create a new instance // since we can't re-use the same file descriptor over multiple calls - $command = sprintf('%s --authentication-file=/proc/self/fd/3 //%s/%s -c \'put /proc/self/fd/4 %s\'', + $workgroupArgument = ($this->server->getWorkgroup()) ? ' -W ' . escapeshellarg($this->server->getWorkgroup()) : ''; + $command = sprintf('%s %s --authentication-file=/proc/self/fd/3 //%s/%s -c \'put /proc/self/fd/4 %s\'', Server::CLIENT, + $workgroupArgument, $this->server->getHost(), $this->name, $target diff --git a/apps/files_external/3rdparty/icewind/smb/tests/AbstractShare.php b/apps/files_external/3rdparty/icewind/smb/tests/AbstractShare.php deleted file mode 100644 index f8ccb7119e..0000000000 --- a/apps/files_external/3rdparty/icewind/smb/tests/AbstractShare.php +++ /dev/null @@ -1,539 +0,0 @@ - - * This file is licensed under the Licensed under the MIT license: - * http://opensource.org/licenses/MIT - */ - -namespace Icewind\SMB\Test; - -use Icewind\SMB\FileInfo; - -abstract class AbstractShare extends \PHPUnit_Framework_TestCase { - /** - * @var \Icewind\SMB\Server $server - */ - protected $server; - - /** - * @var \Icewind\SMB\IShare $share - */ - protected $share; - - /** - * @var string $root - */ - protected $root; - - protected $config; - - public function tearDown() { - try { - if ($this->share) { - $this->cleanDir($this->root); - } - unset($this->share); - } catch (\Exception $e) { - unset($this->share); - throw $e; - } - } - - public function nameProvider() { - // / ? < > \ : * | " are illegal characters in path on windows - return array( - array('simple'), - array('with spaces_and-underscores'), - array("single'quote'"), - array('日本語'), - array('url %2F +encode'), - array('a somewhat longer filename than the other with more charaters as the all the other filenames'), - array('$as#d€££Ö€ßœĚęĘĞĜΣΥΦΩΫ') - ); - } - - public function fileDataProvider() { - return array( - array('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua'), - array('Mixed language, 日本語 が わからか and Various _/* characters \\|” €') - ); - } - - public function nameAndDataProvider() { - $names = $this->nameProvider(); - $data = $this->fileDataProvider(); - $result = array(); - foreach ($names as $name) { - foreach ($data as $text) { - $result[] = array($name[0], $text[0]); - } - } - return $result; - } - - public function cleanDir($dir) { - $content = $this->share->dir($dir); - foreach ($content as $metadata) { - if ($metadata->isDirectory()) { - $this->cleanDir($metadata->getPath()); - } else { - $this->share->del($metadata->getPath()); - } - } - $this->share->rmdir($dir); - } - - private function getTextFile($text = '') { - if (!$text) { - $text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua'; - } - $file = tempnam('/tmp', 'smb_test_'); - file_put_contents($file, $text); - return $file; - } - - public function testListShares() { - $shares = $this->server->listShares(); - foreach ($shares as $share) { - if ($share->getName() === $this->config->share) { - return; - } - } - $this->fail('Share "' . $this->config->share . '" not found'); - } - - public function testRootStartsEmpty() { - $this->assertEquals(array(), $this->share->dir($this->root)); - } - - /** - * @dataProvider nameProvider - */ - public function testMkdir($name) { - $this->share->mkdir($this->root . '/' . $name); - $dirs = $this->share->dir($this->root); - $this->assertCount(1, $dirs); - $this->assertEquals($name, $dirs[0]->getName()); - $this->assertTrue($dirs[0]->isDirectory()); - } - - /** - * @dataProvider nameProvider - */ - public function testRenameDirectory($name) { - $this->share->mkdir($this->root . '/' . $name); - $this->share->rename($this->root . '/' . $name, $this->root . '/' . $name . '_rename'); - $dirs = $this->share->dir($this->root); - $this->assertEquals(1, count($dirs)); - $this->assertEquals($name . '_rename', $dirs[0]->getName()); - } - - /** - * @dataProvider nameProvider - */ - public function testRmdir($name) { - $this->share->mkdir($this->root . '/' . $name); - $this->share->rmdir($this->root . '/' . $name); - $this->assertCount(0, $this->share->dir($this->root)); - } - - /** - * @dataProvider nameAndDataProvider - */ - public function testPut($name, $text) { - $tmpFile = $this->getTextFile($text); - $size = filesize($tmpFile); - - $this->share->put($tmpFile, $this->root . '/' . $name); - unlink($tmpFile); - - $files = $this->share->dir($this->root); - $this->assertCount(1, $files); - $this->assertEquals($name, $files[0]->getName()); - $this->assertEquals($size, $files[0]->getSize()); - $this->assertFalse($files[0]->isDirectory()); - } - - /** - * @dataProvider nameProvider - */ - public function testRenameFile($name) { - $tmpFile = $this->getTextFile(); - - $this->share->put($tmpFile, $this->root . '/' . $name); - unlink($tmpFile); - - $this->share->rename($this->root . '/' . $name, $this->root . '/' . $name . '_renamed'); - - $files = $this->share->dir($this->root); - $this->assertEquals(1, count($files)); - $this->assertEquals($name . '_renamed', $files[0]->getName()); - } - - /** - * @dataProvider nameAndDataProvider - */ - public function testGet($name, $text) { - $tmpFile = $this->getTextFile($text); - - $this->share->put($tmpFile, $this->root . '/' . $name); - unlink($tmpFile); - - $targetFile = tempnam('/tmp', 'smb_test_'); - $this->share->get($this->root . '/' . $name, $targetFile); - - $this->assertEquals($text, file_get_contents($targetFile)); - unlink($targetFile); - } - - /** - * @dataProvider nameProvider - */ - public function testDel($name) { - $tmpFile = $this->getTextFile(); - - $this->share->put($tmpFile, $this->root . '/' . $name); - unlink($tmpFile); - - $this->share->del($this->root . '/' . $name); - $this->assertCount(0, $this->share->dir($this->root)); - } - - /** - * @expectedException \Icewind\SMB\Exception\NotFoundException - */ - public function testCreateFolderInNonExistingFolder() { - $this->share->mkdir($this->root . '/foo/bar'); - } - - /** - * @expectedException \Icewind\SMB\Exception\NotFoundException - */ - public function testRemoveFolderInNonExistingFolder() { - $this->share->rmdir($this->root . '/foo/bar'); - } - - /** - * @expectedException \Icewind\SMB\Exception\NotFoundException - */ - public function testRemoveNonExistingFolder() { - $this->share->rmdir($this->root . '/foo'); - } - - /** - * @expectedException \Icewind\SMB\Exception\AlreadyExistsException - */ - public function testCreateExistingFolder() { - $this->share->mkdir($this->root . '/bar'); - $this->share->mkdir($this->root . '/bar'); - $this->share->rmdir($this->root . '/bar'); - } - - /** - * @expectedException \Icewind\SMB\Exception\InvalidTypeException - */ - public function testCreateFileExistingFolder() { - $this->share->mkdir($this->root . '/bar'); - $this->share->put($this->getTextFile(), $this->root . '/bar'); - $this->share->rmdir($this->root . '/bar'); - } - - /** - * @expectedException \Icewind\SMB\Exception\NotFoundException - */ - public function testCreateFileInNonExistingFolder() { - $this->share->put($this->getTextFile(), $this->root . '/foo/bar'); - } - - /** - * @expectedException \Icewind\SMB\Exception\NotFoundException - */ - public function testTestRemoveNonExistingFile() { - $this->share->del($this->root . '/foo'); - } - - /** - * @expectedException \Icewind\SMB\Exception\NotFoundException - */ - public function testDownloadNonExistingFile() { - $this->share->get($this->root . '/foo', '/dev/null'); - } - - /** - * @expectedException \Icewind\SMB\Exception\InvalidTypeException - */ - public function testDownloadFolder() { - $this->share->mkdir($this->root . '/foobar'); - $this->share->get($this->root . '/foobar', '/dev/null'); - $this->share->rmdir($this->root . '/foobar'); - } - - /** - * @expectedException \Icewind\SMB\Exception\InvalidTypeException - */ - public function testDelFolder() { - $this->share->mkdir($this->root . '/foobar'); - $this->share->del($this->root . '/foobar'); - $this->share->rmdir($this->root . '/foobar'); - } - - /** - * @expectedException \Icewind\SMB\Exception\InvalidTypeException - */ - public function testRmdirFile() { - $this->share->put($this->getTextFile(), $this->root . '/foobar'); - $this->share->rmdir($this->root . '/foobar'); - $this->share->del($this->root . '/foobar'); - } - - /** - * @expectedException \Icewind\SMB\Exception\NotEmptyException - */ - public function testRmdirNotEmpty() { - $this->share->mkdir($this->root . '/foobar'); - $this->share->put($this->getTextFile(), $this->root . '/foobar/asd'); - $this->share->rmdir($this->root . '/foobar'); - } - - /** - * @expectedException \Icewind\SMB\Exception\NotFoundException - */ - public function testDirNonExisting() { - $this->share->dir('/foobar/asd'); - } - - /** - * @expectedException \Icewind\SMB\Exception\NotFoundException - */ - public function testRmDirNonExisting() { - $this->share->rmdir('/foobar/asd'); - } - - /** - * @expectedException \Icewind\SMB\Exception\NotFoundException - */ - public function testRenameNonExisting() { - $this->share->rename('/foobar/asd', '/foobar/bar'); - } - - /** - * @expectedException \Icewind\SMB\Exception\NotFoundException - */ - public function testRenameTargetNonExisting() { - $txt = $this->getTextFile(); - $this->share->put($txt, $this->root . '/foo.txt'); - unlink($txt); - $this->share->rename($this->root . '/foo.txt', $this->root . '/bar/foo.txt'); - } - - public function testModifiedDate() { - $now = time(); - $this->share->put($this->getTextFile(), $this->root . '/foo.txt'); - $dir = $this->share->dir($this->root); - $mtime = $dir[0]->getMTime(); - $this->assertTrue(abs($now - $mtime) <= 2, 'Modified time differs by ' . abs($now - $mtime) . ' seconds'); - $this->share->del($this->root . '/foo.txt'); - } - - /** - * @dataProvider nameAndDataProvider - */ - public function testReadStream($name, $text) { - $sourceFile = $this->getTextFile($text); - $this->share->put($sourceFile, $this->root . '/' . $name); - $fh = $this->share->read($this->root . '/' . $name); - $content = stream_get_contents($fh); - fclose($fh); - $this->share->del($this->root . '/' . $name); - - $this->assertEquals(file_get_contents($sourceFile), $content); - } - - /** - * @dataProvider nameAndDataProvider - */ - public function testWriteStream($name, $text) { - $fh = $this->share->write($this->root . '/' . $name); - fwrite($fh, $text); - fclose($fh); - - $tmpFile1 = tempnam('/tmp', 'smb_test_'); - $this->share->get($this->root . '/' . $name, $tmpFile1); - $this->assertEquals($text, file_get_contents($tmpFile1)); - $this->share->del($this->root . '/' . $name); - unlink($tmpFile1); - } - - public function testDir() { - $txtFile = $this->getTextFile(); - - $this->share->mkdir($this->root . '/dir'); - $this->share->put($txtFile, $this->root . '/file.txt'); - unlink($txtFile); - - $dir = $this->share->dir($this->root); - if ($dir[0]->getName() === 'dir') { - $dirEntry = $dir[0]; - } else { - $dirEntry = $dir[1]; - } - $this->assertTrue($dirEntry->isDirectory()); - $this->assertFalse($dirEntry->isReadOnly()); - $this->assertFalse($dirEntry->isReadOnly()); - - if ($dir[0]->getName() === 'file.txt') { - $fileEntry = $dir[0]; - } else { - $fileEntry = $dir[1]; - } - $this->assertFalse($fileEntry->isDirectory()); - $this->assertFalse($fileEntry->isReadOnly()); - $this->assertFalse($fileEntry->isReadOnly()); - } - - /** - * @dataProvider nameProvider - */ - public function testStat($name) { - $txtFile = $this->getTextFile(); - $size = filesize($txtFile); - - $this->share->put($txtFile, $this->root . '/' . $name); - unlink($txtFile); - - $info = $this->share->stat($this->root . '/' . $name); - $this->assertEquals($size, $info->getSize()); - } - - /** - * @expectedException \Icewind\SMB\Exception\NotFoundException - */ - public function testStatNonExisting() { - $this->share->stat($this->root . '/fo.txt'); - } - - /** - * note setting archive and system bit is not supported - * - * @dataProvider nameProvider - */ - public function testSetMode($name) { - $txtFile = $this->getTextFile(); - - $this->share->put($txtFile, $this->root . '/' . $name); - - $this->share->setMode($this->root . '/' . $name, FileInfo::MODE_NORMAL); - $info = $this->share->stat($this->root . '/' . $name); - $this->assertFalse($info->isReadOnly()); - $this->assertFalse($info->isArchived()); - $this->assertFalse($info->isSystem()); - $this->assertFalse($info->isHidden()); - - $this->share->setMode($this->root . '/' . $name, FileInfo::MODE_READONLY); - $info = $this->share->stat($this->root . '/' . $name); - $this->assertTrue($info->isReadOnly()); - $this->assertFalse($info->isArchived()); - $this->assertFalse($info->isSystem()); - $this->assertFalse($info->isHidden()); - - $this->share->setMode($this->root . '/' . $name, FileInfo::MODE_ARCHIVE); - $info = $this->share->stat($this->root . '/' . $name); - $this->assertFalse($info->isReadOnly()); - $this->assertTrue($info->isArchived()); - $this->assertFalse($info->isSystem()); - $this->assertFalse($info->isHidden()); - - $this->share->setMode($this->root . '/' . $name, FileInfo::MODE_READONLY | FileInfo::MODE_ARCHIVE); - $info = $this->share->stat($this->root . '/' . $name); - $this->assertTrue($info->isReadOnly()); - $this->assertTrue($info->isArchived()); - $this->assertFalse($info->isSystem()); - $this->assertFalse($info->isHidden()); - - $this->share->setMode($this->root . '/' . $name, FileInfo::MODE_HIDDEN); - $info = $this->share->stat($this->root . '/' . $name); - $this->assertFalse($info->isReadOnly()); - $this->assertFalse($info->isArchived()); - $this->assertFalse($info->isSystem()); - $this->assertTrue($info->isHidden()); - - $this->share->setMode($this->root . '/' . $name, FileInfo::MODE_SYSTEM); - $info = $this->share->stat($this->root . '/' . $name); - $this->assertFalse($info->isReadOnly()); - $this->assertFalse($info->isArchived()); - $this->assertTrue($info->isSystem()); - $this->assertFalse($info->isHidden()); - - $this->share->setMode($this->root . '/' . $name, FileInfo::MODE_NORMAL); - $info = $this->share->stat($this->root . '/' . $name); - $this->assertFalse($info->isReadOnly()); - $this->assertFalse($info->isArchived()); - $this->assertFalse($info->isSystem()); - $this->assertFalse($info->isHidden()); - } - - public function pathProvider() { - // / ? < > \ : * | " are illegal characters in path on windows - return array( - array('dir/sub/foo.txt'), - array('bar.txt'), - array("single'quote'/sub/foo.txt"), - array('日本語/url %2F +encode/asd.txt'), - array( - 'a somewhat longer folder than the other with more charaters as the all the other filenames/' . - 'followed by a somewhat long file name after that.txt' - ) - ); - } - - /** - * @dataProvider pathProvider - */ - public function testSubDirs($path) { - $dirs = explode('/', $path); - $name = array_pop($dirs); - $fullPath = ''; - foreach ($dirs as $dir) { - $fullPath .= '/' . $dir; - $this->share->mkdir($this->root . $fullPath); - } - $txtFile = $this->getTextFile(); - $size = filesize($txtFile); - $this->share->put($txtFile, $this->root . $fullPath . '/' . $name); - unlink($txtFile); - $info = $this->share->stat($this->root . $fullPath . '/' . $name); - $this->assertEquals($size, $info->getSize()); - $this->assertFalse($info->isHidden()); - } - - public function testDelAfterStat() { - $name = 'foo.txt'; - $txtFile = $this->getTextFile(); - - $this->share->put($txtFile, $this->root . '/' . $name); - unlink($txtFile); - - $this->share->stat($this->root . '/' . $name); - $this->share->del($this->root . '/foo.txt'); - } - - /** - * @param $name - * @dataProvider nameProvider - */ - public function testDirPaths($name) { - $txtFile = $this->getTextFile(); - $this->share->mkdir($this->root . '/' . $name); - $this->share->put($txtFile, $this->root . '/' . $name . '/' . $name); - unlink($txtFile); - - $content = $this->share->dir($this->root . '/' . $name); - $this->assertCount(1, $content); - $this->assertEquals($name, $content[0]->getName()); - } - - public function testStatRoot() { - $info = $this->share->stat('/'); - $this->assertInstanceOf('\Icewind\SMB\IFileInfo', $info); - } -} diff --git a/apps/files_external/3rdparty/icewind/smb/tests/NativeShare.php b/apps/files_external/3rdparty/icewind/smb/tests/NativeShare.php deleted file mode 100644 index d8e10235c1..0000000000 --- a/apps/files_external/3rdparty/icewind/smb/tests/NativeShare.php +++ /dev/null @@ -1,27 +0,0 @@ - - * This file is licensed under the Licensed under the MIT license: - * http://opensource.org/licenses/MIT - */ - -namespace Icewind\SMB\Test; - -use Icewind\SMB\NativeServer; - -class NativeShare extends AbstractShare { - public function setUp() { - if (!function_exists('smbclient_state_new')) { - $this->markTestSkipped('libsmbclient php extension not installed'); - } - $this->config = json_decode(file_get_contents(__DIR__ . '/config.json')); - $this->server = new NativeServer($this->config->host, $this->config->user, $this->config->password); - $this->share = $this->server->getShare($this->config->share); - if ($this->config->root) { - $this->root = '/' . $this->config->root . '/' . uniqid(); - } else { - $this->root = '/' . uniqid(); - } - $this->share->mkdir($this->root); - } -} diff --git a/apps/files_external/3rdparty/icewind/smb/tests/NativeStream.php b/apps/files_external/3rdparty/icewind/smb/tests/NativeStream.php deleted file mode 100644 index 2d7b62fede..0000000000 --- a/apps/files_external/3rdparty/icewind/smb/tests/NativeStream.php +++ /dev/null @@ -1,143 +0,0 @@ - - * This file is licensed under the Licensed under the MIT license: - * http://opensource.org/licenses/MIT - */ - -namespace Icewind\SMB\Test; - -use Icewind\SMB\NativeServer; - -class NativeStream extends \PHPUnit_Framework_TestCase { - /** - * @var \Icewind\SMB\Server $server - */ - protected $server; - - /** - * @var \Icewind\SMB\NativeShare $share - */ - protected $share; - - /** - * @var string $root - */ - protected $root; - - protected $config; - - public function setUp() { - if (!function_exists('smbclient_state_new')) { - $this->markTestSkipped('libsmbclient php extension not installed'); - } - $this->config = json_decode(file_get_contents(__DIR__ . '/config.json')); - $this->server = new NativeServer($this->config->host, $this->config->user, $this->config->password); - $this->share = $this->server->getShare($this->config->share); - if ($this->config->root) { - $this->root = '/' . $this->config->root . '/' . uniqid(); - } else { - $this->root = '/' . uniqid(); - } - $this->share->mkdir($this->root); - } - - private function getTextFile() { - $text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua'; - $file = tempnam('/tmp', 'smb_test_'); - file_put_contents($file, $text); - return $file; - } - - public function testSeekTell() { - $sourceFile = $this->getTextFile(); - $this->share->put($sourceFile, $this->root . '/foobar'); - $fh = $this->share->read($this->root . '/foobar'); - $content = fread($fh, 3); - $this->assertEquals('Lor', $content); - - fseek($fh, -2, SEEK_CUR); - - $content = fread($fh, 3); - $this->assertEquals('ore', $content); - - fseek($fh, 3, SEEK_SET); - - $content = fread($fh, 3); - $this->assertEquals('em ', $content); - - fseek($fh, -3, SEEK_END); - - $content = fread($fh, 3); - $this->assertEquals('qua', $content); - - fseek($fh, -3, SEEK_END); - $this->assertEquals(120, ftell($fh)); - } - - public function testStat() { - $sourceFile = $this->getTextFile(); - $this->share->put($sourceFile, $this->root . '/foobar'); - $fh = $this->share->read($this->root . '/foobar'); - $stat = fstat($fh); - $this->assertEquals(filesize($sourceFile), $stat['size']); - unlink($sourceFile); - } - - public function testTruncate() { - if (version_compare(phpversion(), '5.4.0', '<')) { - $this->markTestSkipped('php <5.4 doesn\'t support truncate for stream wrappers'); - } - $fh = $this->share->write($this->root . '/foobar'); - fwrite($fh, 'foobar'); - ftruncate($fh, 3); - fclose($fh); - - $fh = $this->share->read($this->root . '/foobar'); - $this->assertEquals('foo', stream_get_contents($fh)); - } - - public function testEOF() { - if (version_compare(phpversion(), '5.4.0', '<')) { - $this->markTestSkipped('php <5.4 doesn\'t support truncate for stream wrappers'); - } - $fh = $this->share->write($this->root . '/foobar'); - fwrite($fh, 'foobar'); - fclose($fh); - - $fh = $this->share->read($this->root . '/foobar'); - fread($fh, 3); - $this->assertFalse(feof($fh)); - fread($fh, 5); - $this->assertTrue(feof($fh)); - } - - public function testLockUnsupported() { - $fh = $this->share->write($this->root . '/foobar'); - $this->assertFalse(flock($fh, LOCK_SH)); - } - - public function testSetOptionUnsupported() { - $fh = $this->share->write($this->root . '/foobar'); - $this->assertFalse(stream_set_blocking($fh, false)); - } - - public function tearDown() { - if ($this->share) { - $this->cleanDir($this->root); - } - unset($this->share); - } - - public function cleanDir($dir) { - $content = $this->share->dir($dir); - foreach ($content as $metadata) { - if ($metadata->isDirectory()) { - $this->cleanDir($metadata->getPath()); - } else { - $this->share->del($metadata->getPath()); - } - } - $this->share->rmdir($dir); - } -} diff --git a/apps/files_external/3rdparty/icewind/smb/tests/Parser.php b/apps/files_external/3rdparty/icewind/smb/tests/Parser.php deleted file mode 100644 index 5caa048a66..0000000000 --- a/apps/files_external/3rdparty/icewind/smb/tests/Parser.php +++ /dev/null @@ -1,103 +0,0 @@ - - * This file is licensed under the Licensed under the MIT license: - * http://opensource.org/licenses/MIT - */ - -namespace Icewind\SMB\Test; - - -use Icewind\SMB\FileInfo; - -class Parser extends \PHPUnit_Framework_TestCase { - public function modeProvider() { - return array( - array('D', FileInfo::MODE_DIRECTORY), - array('A', FileInfo::MODE_ARCHIVE), - array('S', FileInfo::MODE_SYSTEM), - array('H', FileInfo::MODE_HIDDEN), - array('R', FileInfo::MODE_READONLY), - array('N', FileInfo::MODE_NORMAL), - array('RA', FileInfo::MODE_READONLY | FileInfo::MODE_ARCHIVE), - array('RAH', FileInfo::MODE_READONLY | FileInfo::MODE_ARCHIVE | FileInfo::MODE_HIDDEN) - ); - } - - /** - * @param string $timeZone - * @return \Icewind\SMB\TimeZoneProvider - */ - private function getTimeZoneProvider($timeZone) { - $mock = $this->getMockBuilder('\Icewind\SMB\TimeZoneProvider') - ->disableOriginalConstructor() - ->getMock(); - $mock->expects($this->any()) - ->method('get') - ->will($this->returnValue($timeZone)); - return $mock; - } - - /** - * @dataProvider modeProvider - */ - public function testParseMode($string, $mode) { - $parser = new \Icewind\SMB\Parser($this->getTimeZoneProvider('UTC')); - $this->assertEquals($mode, $parser->parseMode($string), 'Failed parsing ' . $string); - } - - public function statProvider() { - return array( - array( - array( - 'altname: test.txt', - 'create_time: Sat Oct 12 07:05:58 PM 2013 CEST', - 'access_time: Tue Oct 15 02:58:48 PM 2013 CEST', - 'write_time: Sat Oct 12 07:05:58 PM 2013 CEST', - 'change_time: Sat Oct 12 07:05:58 PM 2013 CEST', - 'attributes: (80)', - 'stream: [::$DATA], 29634 bytes' - ), - array( - 'mtime' => strtotime('12 Oct 2013 19:05:58 CEST'), - 'mode' => FileInfo::MODE_NORMAL, - 'size' => 29634 - ) - ) - ); - } - - /** - * @dataProvider statProvider - */ - public function testStat($output, $stat) { - $parser = new \Icewind\SMB\Parser($this->getTimeZoneProvider('UTC')); - $this->assertEquals($stat, $parser->parseStat($output)); - } - - public function dirProvider() { - return array( - array( - array( - ' . D 0 Tue Aug 26 19:11:56 2014', - ' .. DR 0 Sun Oct 28 15:24:02 2012', - ' c.pdf N 29634 Sat Oct 12 19:05:58 2013', - '', - ' 62536 blocks of size 8388608. 57113 blocks available' - ), - array( - new FileInfo('/c.pdf', 'c.pdf', 29634, strtotime('12 Oct 2013 19:05:58 CEST'), - FileInfo::MODE_NORMAL) - ) - ) - ); - } - - /** - * @dataProvider dirProvider - */ - public function testDir($output, $dir) { - $parser = new \Icewind\SMB\Parser($this->getTimeZoneProvider('CEST')); - $this->assertEquals($dir, $parser->parseDir($output, '')); - } -} diff --git a/apps/files_external/3rdparty/icewind/smb/tests/Server.php b/apps/files_external/3rdparty/icewind/smb/tests/Server.php deleted file mode 100644 index 9f62886654..0000000000 --- a/apps/files_external/3rdparty/icewind/smb/tests/Server.php +++ /dev/null @@ -1,57 +0,0 @@ - - * This file is licensed under the Licensed under the MIT license: - * http://opensource.org/licenses/MIT - */ - -namespace Icewind\SMB\Test; - -class Server extends \PHPUnit_Framework_TestCase { - /** - * @var \Icewind\SMB\Server $server - */ - private $server; - - private $config; - - public function setUp() { - $this->config = json_decode(file_get_contents(__DIR__ . '/config.json')); - $this->server = new \Icewind\SMB\Server($this->config->host, $this->config->user, $this->config->password); - } - - public function testListShares() { - $shares = $this->server->listShares(); - foreach ($shares as $share) { - if ($share->getName() === $this->config->share) { - return; - } - } - $this->fail('Share "' . $this->config->share . '" not found'); - } - - /** - * @expectedException \Icewind\SMB\Exception\AuthenticationException - */ - public function testWrongUserName() { - $this->markTestSkipped('This fails for no reason on travis'); - $server = new \Icewind\SMB\Server($this->config->host, uniqid(), uniqid()); - $server->listShares(); - } - - /** - * @expectedException \Icewind\SMB\Exception\AuthenticationException - */ - public function testWrongPassword() { - $server = new \Icewind\SMB\Server($this->config->host, $this->config->user, uniqid()); - $server->listShares(); - } - - /** - * @expectedException \Icewind\SMB\Exception\InvalidHostException - */ - public function testWrongHost() { - $server = new \Icewind\SMB\Server(uniqid(), $this->config->user, $this->config->password); - $server->listShares(); - } -} diff --git a/apps/files_external/3rdparty/icewind/smb/tests/Share.php b/apps/files_external/3rdparty/icewind/smb/tests/Share.php deleted file mode 100644 index a629914d74..0000000000 --- a/apps/files_external/3rdparty/icewind/smb/tests/Share.php +++ /dev/null @@ -1,24 +0,0 @@ - - * This file is licensed under the Licensed under the MIT license: - * http://opensource.org/licenses/MIT - */ - -namespace Icewind\SMB\Test; - -use Icewind\SMB\Server as NormalServer; - -class Share extends AbstractShare { - public function setUp() { - $this->config = json_decode(file_get_contents(__DIR__ . '/config.json')); - $this->server = new NormalServer($this->config->host, $this->config->user, $this->config->password); - $this->share = $this->server->getShare($this->config->share); - if ($this->config->root) { - $this->root = '/' . $this->config->root . '/' . uniqid(); - } else { - $this->root = '/' . uniqid(); - } - $this->share->mkdir($this->root); - } -} diff --git a/apps/files_external/3rdparty/icewind/smb/tests/bootstrap.php b/apps/files_external/3rdparty/icewind/smb/tests/bootstrap.php deleted file mode 100644 index dc2e34b183..0000000000 --- a/apps/files_external/3rdparty/icewind/smb/tests/bootstrap.php +++ /dev/null @@ -1,9 +0,0 @@ - - * This file is licensed under the Licensed under the MIT license: - * http://opensource.org/licenses/MIT - */ - -date_default_timezone_set('UTC'); -require_once __DIR__.'/../vendor/autoload.php'; diff --git a/apps/files_external/3rdparty/icewind/smb/tests/config.json b/apps/files_external/3rdparty/icewind/smb/tests/config.json deleted file mode 100644 index 0ecd7e3715..0000000000 --- a/apps/files_external/3rdparty/icewind/smb/tests/config.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "host": "localhost", - "user": "test", - "password": "test", - "share": "test", - "root": "test" -} diff --git a/apps/files_external/3rdparty/icewind/smb/tests/phpunit.xml b/apps/files_external/3rdparty/icewind/smb/tests/phpunit.xml deleted file mode 100644 index 3ab244dd34..0000000000 --- a/apps/files_external/3rdparty/icewind/smb/tests/phpunit.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - ./ - -