summaryrefslogtreecommitdiffstats
path: root/apps/files_external/3rdparty/icewind
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/3rdparty/icewind')
-rw-r--r--apps/files_external/3rdparty/icewind/smb/.travis.yml20
-rwxr-xr-xapps/files_external/3rdparty/icewind/smb/install_libsmbclient.sh8
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/NativeServer.php7
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/NativeShare.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Server.php33
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Share.php12
-rw-r--r--apps/files_external/3rdparty/icewind/smb/tests/AbstractShare.php539
-rw-r--r--apps/files_external/3rdparty/icewind/smb/tests/NativeShare.php27
-rw-r--r--apps/files_external/3rdparty/icewind/smb/tests/NativeStream.php143
-rw-r--r--apps/files_external/3rdparty/icewind/smb/tests/Parser.php103
-rw-r--r--apps/files_external/3rdparty/icewind/smb/tests/Server.php57
-rw-r--r--apps/files_external/3rdparty/icewind/smb/tests/Share.php24
-rw-r--r--apps/files_external/3rdparty/icewind/smb/tests/bootstrap.php9
-rw-r--r--apps/files_external/3rdparty/icewind/smb/tests/config.json7
-rw-r--r--apps/files_external/3rdparty/icewind/smb/tests/phpunit.xml6
15 files changed, 66 insertions, 940 deletions
diff --git a/apps/files_external/3rdparty/icewind/smb/.travis.yml b/apps/files_external/3rdparty/icewind/smb/.travis.yml
index c1ac3727d08..bb2a875c393 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 00000000000..63544e3ee1f
--- /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 4628e3ec108..ce8e6d636a9 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 c84e9611667..ecef8c744c2 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 f7227d4baef..5c07d1c517d 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/Server.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/Server.php
@@ -30,6 +30,11 @@ class Server {
protected $password;
/**
+ * @var string $workgroup
+ */
+ protected $workgroup;
+
+ /**
* Check if the smbclient php extension is available
*
* @return bool
@@ -45,11 +50,29 @@ 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
*/
public function getAuthString() {
@@ -78,13 +101,21 @@ class Server {
}
/**
+ * @return string
+ */
+ public function getWorkgroup() {
+ return $this->workgroup;
+ }
+
+ /**
* @return \Icewind\SMB\IShare[]
*
* @throws \Icewind\SMB\Exception\AuthenticationException
* @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 7c24f9f2e90..8657e698af3 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 f8ccb7119ed..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/tests/AbstractShare.php
+++ /dev/null
@@ -1,539 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * 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 d8e10235c12..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/tests/NativeShare.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * 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 2d7b62fedeb..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/tests/NativeStream.php
+++ /dev/null
@@ -1,143 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * 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 5caa048a664..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/tests/Parser.php
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * 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 9f62886654f..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/tests/Server.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * 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 a629914d748..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/tests/Share.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * 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 dc2e34b183e..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/tests/bootstrap.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * 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 0ecd7e3715d..00000000000
--- 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 3ab244dd34f..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/tests/phpunit.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<phpunit bootstrap="bootstrap.php">
- <testsuite name='SMB'>
- <directory suffix='.php'>./</directory>
- </testsuite>
-</phpunit>