aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/3rdparty/composer.json2
-rw-r--r--apps/files_external/3rdparty/composer.lock19
-rw-r--r--apps/files_external/3rdparty/composer/autoload_classmap.php1
-rw-r--r--apps/files_external/3rdparty/composer/autoload_real.php3
-rw-r--r--apps/files_external/3rdparty/composer/autoload_static.php1
-rw-r--r--apps/files_external/3rdparty/composer/installed.json16
-rw-r--r--apps/files_external/3rdparty/icewind/smb/.gitignore3
-rw-r--r--apps/files_external/3rdparty/icewind/smb/README.md2
-rw-r--r--apps/files_external/3rdparty/icewind/smb/composer.json4
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/ACL.php81
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/IFileInfo.php5
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/ISystem.php7
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php74
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Native/NativeShare.php30
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Native/NativeState.php2
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/System.php4
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Wrapped/Connection.php5
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Wrapped/FileInfo.php17
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php10
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php12
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php98
-rw-r--r--apps/files_external/ajax/applicable.php2
-rw-r--r--apps/files_external/l10n/da.js5
-rw-r--r--apps/files_external/l10n/da.json5
-rw-r--r--apps/files_external/l10n/sl.js4
-rw-r--r--apps/files_external/l10n/sl.json4
-rw-r--r--apps/files_external/l10n/sv.js2
-rw-r--r--apps/files_external/l10n/sv.json2
-rw-r--r--apps/files_external/lib/AppInfo/Application.php2
-rw-r--r--apps/files_external/lib/Controller/AjaxController.php6
-rw-r--r--apps/files_external/lib/Controller/ApiController.php4
-rw-r--r--apps/files_external/lib/Controller/GlobalStoragesController.php2
-rw-r--r--apps/files_external/lib/Controller/UserGlobalStoragesController.php6
-rw-r--r--apps/files_external/lib/Controller/UserStoragesController.php2
-rw-r--r--apps/files_external/lib/Lib/Backend/InvalidBackend.php1
-rw-r--r--apps/files_external/lib/Lib/Backend/Swift.php1
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php28
-rw-r--r--apps/files_external/lib/Lib/Storage/FTP.php4
-rw-r--r--apps/files_external/lib/Lib/Storage/SFTP.php12
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php2
-rw-r--r--apps/files_external/lib/Lib/Storage/Swift.php4
-rw-r--r--apps/files_external/lib/Migration/StorageMigrator.php1
-rw-r--r--apps/files_external/lib/config.php8
-rw-r--r--apps/files_external/tests/Auth/Password/GlobalAuth.php20
-rw-r--r--apps/files_external/tests/Command/ApplicableTest.php4
-rw-r--r--apps/files_external/tests/Command/CommandTest.php4
-rw-r--r--apps/files_external/tests/Controller/GlobalStoragesControllerTest.php1
-rw-r--r--apps/files_external/tests/Controller/StoragesControllerTest.php46
-rw-r--r--apps/files_external/tests/Controller/UserStoragesControllerTest.php6
-rw-r--r--apps/files_external/tests/FrontendDefinitionTraitTest.php4
-rw-r--r--apps/files_external/tests/OwnCloudFunctionsTest.php68
-rw-r--r--apps/files_external/tests/PersonalMountTest.php2
-rw-r--r--apps/files_external/tests/Service/BackendServiceTest.php18
-rw-r--r--apps/files_external/tests/Service/StoragesServiceTest.php32
-rw-r--r--apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php10
-rw-r--r--apps/files_external/tests/Service/UserStoragesServiceTest.php2
-rw-r--r--apps/files_external/tests/Storage/FtpTest.php4
-rw-r--r--apps/files_external/tests/Storage/SmbTest.php2
-rw-r--r--apps/files_external/tests/config.php36
59 files changed, 489 insertions, 273 deletions
diff --git a/apps/files_external/3rdparty/composer.json b/apps/files_external/3rdparty/composer.json
index 6c23067c4a5..9cf429eb5c2 100644
--- a/apps/files_external/3rdparty/composer.json
+++ b/apps/files_external/3rdparty/composer.json
@@ -9,6 +9,6 @@
},
"require": {
"icewind/streams": "0.7.1",
- "icewind/smb": "3.1.1"
+ "icewind/smb": "3.2.1"
}
}
diff --git a/apps/files_external/3rdparty/composer.lock b/apps/files_external/3rdparty/composer.lock
index 491b73fa1f4..c486854d6a9 100644
--- a/apps/files_external/3rdparty/composer.lock
+++ b/apps/files_external/3rdparty/composer.lock
@@ -4,29 +4,29 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "5639a09feff2318b1b69e11a10a81e7d",
+ "content-hash": "adc3b3531ee8503b485092e60c569b42",
"packages": [
{
"name": "icewind/smb",
- "version": "v3.1.1",
+ "version": "v3.2.1",
"source": {
"type": "git",
"url": "https://github.com/icewind1991/SMB.git",
- "reference": "26b7b8780342d0e61313b464b880d50a2ea898e2"
+ "reference": "5330edcc579a2dcc4759b8e5779eb5aa3385a878"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/icewind1991/SMB/zipball/26b7b8780342d0e61313b464b880d50a2ea898e2",
- "reference": "26b7b8780342d0e61313b464b880d50a2ea898e2",
+ "url": "https://api.github.com/repos/icewind1991/SMB/zipball/5330edcc579a2dcc4759b8e5779eb5aa3385a878",
+ "reference": "5330edcc579a2dcc4759b8e5779eb5aa3385a878",
"shasum": ""
},
"require": {
"icewind/streams": ">=0.2.0",
- "php": ">=5.6"
+ "php": ">=7.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.13",
- "phpunit/phpunit": "^5.7"
+ "phpunit/phpunit": "^7.0"
},
"type": "library",
"autoload": {
@@ -46,7 +46,7 @@
}
],
"description": "php wrapper for smbclient and libsmbclient-php",
- "time": "2019-03-04T15:02:42+00:00"
+ "time": "2020-03-24T18:19:18+00:00"
},
{
"name": "icewind/streams",
@@ -97,5 +97,6 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
- "platform-dev": []
+ "platform-dev": [],
+ "plugin-api-version": "1.1.0"
}
diff --git a/apps/files_external/3rdparty/composer/autoload_classmap.php b/apps/files_external/3rdparty/composer/autoload_classmap.php
index 9eb83e893bd..5b0c682cbce 100644
--- a/apps/files_external/3rdparty/composer/autoload_classmap.php
+++ b/apps/files_external/3rdparty/composer/autoload_classmap.php
@@ -6,6 +6,7 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = $vendorDir;
return array(
+ 'Icewind\\SMB\\ACL' => $vendorDir . '/icewind/smb/src/ACL.php',
'Icewind\\SMB\\AbstractServer' => $vendorDir . '/icewind/smb/src/AbstractServer.php',
'Icewind\\SMB\\AbstractShare' => $vendorDir . '/icewind/smb/src/AbstractShare.php',
'Icewind\\SMB\\AnonymousAuth' => $vendorDir . '/icewind/smb/src/AnonymousAuth.php',
diff --git a/apps/files_external/3rdparty/composer/autoload_real.php b/apps/files_external/3rdparty/composer/autoload_real.php
index 4ac68127fea..36857d406cd 100644
--- a/apps/files_external/3rdparty/composer/autoload_real.php
+++ b/apps/files_external/3rdparty/composer/autoload_real.php
@@ -13,6 +13,9 @@ class ComposerAutoloaderInit98fe9b281934250b3a93f69a5ce843b3
}
}
+ /**
+ * @return \Composer\Autoload\ClassLoader
+ */
public static function getLoader()
{
if (null !== self::$loader) {
diff --git a/apps/files_external/3rdparty/composer/autoload_static.php b/apps/files_external/3rdparty/composer/autoload_static.php
index eb2329b2b05..b8eb6ebbfe8 100644
--- a/apps/files_external/3rdparty/composer/autoload_static.php
+++ b/apps/files_external/3rdparty/composer/autoload_static.php
@@ -36,6 +36,7 @@ class ComposerStaticInit98fe9b281934250b3a93f69a5ce843b3
);
public static $classMap = array (
+ 'Icewind\\SMB\\ACL' => __DIR__ . '/..' . '/icewind/smb/src/ACL.php',
'Icewind\\SMB\\AbstractServer' => __DIR__ . '/..' . '/icewind/smb/src/AbstractServer.php',
'Icewind\\SMB\\AbstractShare' => __DIR__ . '/..' . '/icewind/smb/src/AbstractShare.php',
'Icewind\\SMB\\AnonymousAuth' => __DIR__ . '/..' . '/icewind/smb/src/AnonymousAuth.php',
diff --git a/apps/files_external/3rdparty/composer/installed.json b/apps/files_external/3rdparty/composer/installed.json
index 18ee9e5431f..e3609f5af4e 100644
--- a/apps/files_external/3rdparty/composer/installed.json
+++ b/apps/files_external/3rdparty/composer/installed.json
@@ -1,28 +1,28 @@
[
{
"name": "icewind/smb",
- "version": "v3.1.1",
- "version_normalized": "3.1.1.0",
+ "version": "v3.2.1",
+ "version_normalized": "3.2.1.0",
"source": {
"type": "git",
"url": "https://github.com/icewind1991/SMB.git",
- "reference": "26b7b8780342d0e61313b464b880d50a2ea898e2"
+ "reference": "5330edcc579a2dcc4759b8e5779eb5aa3385a878"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/icewind1991/SMB/zipball/26b7b8780342d0e61313b464b880d50a2ea898e2",
- "reference": "26b7b8780342d0e61313b464b880d50a2ea898e2",
+ "url": "https://api.github.com/repos/icewind1991/SMB/zipball/5330edcc579a2dcc4759b8e5779eb5aa3385a878",
+ "reference": "5330edcc579a2dcc4759b8e5779eb5aa3385a878",
"shasum": ""
},
"require": {
"icewind/streams": ">=0.2.0",
- "php": ">=5.6"
+ "php": ">=7.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.13",
- "phpunit/phpunit": "^5.7"
+ "phpunit/phpunit": "^7.0"
},
- "time": "2019-03-04T15:02:42+00:00",
+ "time": "2020-03-24T18:19:18+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
diff --git a/apps/files_external/3rdparty/icewind/smb/.gitignore b/apps/files_external/3rdparty/icewind/smb/.gitignore
index 966ac1bcbe1..17e19f04f56 100644
--- a/apps/files_external/3rdparty/icewind/smb/.gitignore
+++ b/apps/files_external/3rdparty/icewind/smb/.gitignore
@@ -2,4 +2,5 @@
vendor
composer.lock
.php_cs.cache
-
+listen.php
+test.php
diff --git a/apps/files_external/3rdparty/icewind/smb/README.md b/apps/files_external/3rdparty/icewind/smb/README.md
index 4c20b1412af..6a35e736acb 100644
--- a/apps/files_external/3rdparty/icewind/smb/README.md
+++ b/apps/files_external/3rdparty/icewind/smb/README.md
@@ -26,7 +26,7 @@ use Icewind\SMB\BasicAuth;
require('vendor/autoload.php');
$serverFactory = new ServerFactory();
-$auth = new BasicAuth('test', 'workgroup', 'test');
+$auth = new BasicAuth('user', 'workgroup', 'password');
$server = $serverFactory->createServer('localhost', $auth);
$share = $server->getShare('test');
diff --git a/apps/files_external/3rdparty/icewind/smb/composer.json b/apps/files_external/3rdparty/icewind/smb/composer.json
index 78375c4df48..8ec551c7340 100644
--- a/apps/files_external/3rdparty/icewind/smb/composer.json
+++ b/apps/files_external/3rdparty/icewind/smb/composer.json
@@ -9,11 +9,11 @@
}
],
"require" : {
- "php": ">=5.6",
+ "php": ">=7.1",
"icewind/streams": ">=0.2.0"
},
"require-dev": {
- "phpunit/phpunit": "^5.7",
+ "phpunit/phpunit": "^7.0",
"friendsofphp/php-cs-fixer": "^2.13"
},
"autoload" : {
diff --git a/apps/files_external/3rdparty/icewind/smb/src/ACL.php b/apps/files_external/3rdparty/icewind/smb/src/ACL.php
new file mode 100644
index 00000000000..bdb77257f17
--- /dev/null
+++ b/apps/files_external/3rdparty/icewind/smb/src/ACL.php
@@ -0,0 +1,81 @@
+<?php declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Icewind\SMB;
+
+class ACL {
+ const TYPE_ALLOW = 0;
+ const TYPE_DENY = 1;
+
+ const MASK_READ = 0x0001;
+ const MASK_WRITE = 0x0002;
+ const MASK_EXECUTE = 0x00020;
+ const MASK_DELETE = 0x10000;
+
+ const FLAG_OBJECT_INHERIT = 0x1;
+ const FLAG_CONTAINER_INHERIT = 0x2;
+
+ private $type;
+ private $flags;
+ private $mask;
+
+ public function __construct(int $type, int $flags, int $mask) {
+ $this->type = $type;
+ $this->flags = $flags;
+ $this->mask = $mask;
+ }
+
+ /**
+ * Check if the acl allows a specific permissions
+ *
+ * Note that this does not take inherited acls into account
+ *
+ * @param int $mask one of the ACL::MASK_* constants
+ * @return bool
+ */
+ public function allows(int $mask): bool {
+ return $this->type === self::TYPE_ALLOW && ($this->mask & $mask) === $mask;
+ }
+
+ /**
+ * Check if the acl allows a specific permissions
+ *
+ * Note that this does not take inherited acls into account
+ *
+ * @param int $mask one of the ACL::MASK_* constants
+ * @return bool
+ */
+ public function denies(int $mask): bool {
+ return $this->type === self::TYPE_DENY && ($this->mask & $mask) === $mask;
+ }
+
+ public function getType(): int {
+ return $this->type;
+ }
+
+ public function getFlags(): int {
+ return $this->flags;
+ }
+
+ public function getMask(): int {
+ return $this->mask;
+ }
+}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/IFileInfo.php b/apps/files_external/3rdparty/icewind/smb/src/IFileInfo.php
index ae8acd3a3db..3411d498d78 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/IFileInfo.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/IFileInfo.php
@@ -65,4 +65,9 @@ interface IFileInfo {
* @return bool
*/
public function isArchived();
+
+ /**
+ * @return ACL[]
+ */
+ public function getAcls(): array;
}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/ISystem.php b/apps/files_external/3rdparty/icewind/smb/src/ISystem.php
index 7740c98d97e..09994610716 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/ISystem.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/ISystem.php
@@ -49,6 +49,13 @@ interface ISystem {
public function getNetPath();
/**
+ * Get the full path to the `smbcacls` binary of false if the binary is not available
+ *
+ * @return string|bool
+ */
+ public function getSmbcAclsPath();
+
+ /**
* Get the full path to the `stdbuf` binary of false if the binary is not available
*
* @return string|bool
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php
index 904318907f2..24344e6f0df 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php
@@ -7,11 +7,10 @@
namespace Icewind\SMB\Native;
+use Icewind\SMB\ACL;
use Icewind\SMB\IFileInfo;
class NativeFileInfo implements IFileInfo {
- const MODE_FILE = 0100000;
-
/**
* @var string
*/
@@ -30,10 +29,7 @@ class NativeFileInfo implements IFileInfo {
/**
* @var array|null
*/
- protected $statCache = null;
-
- /** @var callable|null */
- protected $statCallback = null;
+ protected $attributeCache = null;
/**
* @var int
@@ -44,20 +40,11 @@ class NativeFileInfo implements IFileInfo {
* @param NativeShare $share
* @param string $path
* @param string $name
- * @param array|callable $stat
*/
- public function __construct($share, $path, $name, $stat) {
+ public function __construct($share, $path, $name) {
$this->share = $share;
$this->path = $path;
$this->name = $name;
-
- if (is_array($stat)) {
- $this->statCache = $stat;
- } elseif (is_callable($stat)) {
- $this->statCallback = $stat;
- } else {
- throw new \InvalidArgumentException('$stat needs to be an array or callback');
- }
}
/**
@@ -78,10 +65,20 @@ class NativeFileInfo implements IFileInfo {
* @return array
*/
protected function stat() {
- if (is_null($this->statCache)) {
- $this->statCache = call_user_func($this->statCallback);
+ if (is_null($this->attributeCache)) {
+ $rawAttributes = explode(',', $this->share->getAttribute($this->path, 'system.dos_attr.*'));
+ $this->attributeCache = [];
+ foreach ($rawAttributes as $rawAttribute) {
+ [$name, $value] = explode(':', $rawAttribute);
+ $name = strtolower($name);
+ if ($name == 'mode') {
+ $this->attributeCache[$name] = (int)hexdec(substr($value, 2));
+ } else {
+ $this->attributeCache[$name] = (int)$value;
+ }
+ }
}
- return $this->statCache;
+ return $this->attributeCache;
}
/**
@@ -97,27 +94,22 @@ class NativeFileInfo implements IFileInfo {
*/
public function getMTime() {
$stat = $this->stat();
- return $stat['mtime'];
+ return $stat['change_time'];
}
/**
- * @return bool
+ * @return int
*/
- public function isDirectory() {
- $stat = $this->stat();
- return !($stat['mode'] & self::MODE_FILE);
+ protected function getMode() {
+ return $this->stat()['mode'];
}
/**
- * @return int
+ * @return bool
*/
- protected function getMode() {
- if (!$this->modeCache) {
- $attribute = $this->share->getAttribute($this->path, 'system.dos_attr.mode');
- // parse hex string
- $this->modeCache = (int)hexdec(substr($attribute, 2));
- }
- return $this->modeCache;
+ public function isDirectory() {
+ $mode = $this->getMode();
+ return (bool)($mode & IFileInfo::MODE_DIRECTORY);
}
/**
@@ -151,4 +143,22 @@ class NativeFileInfo implements IFileInfo {
$mode = $this->getMode();
return (bool)($mode & IFileInfo::MODE_ARCHIVE);
}
+
+ /**
+ * @return ACL[]
+ */
+ public function getAcls(): array {
+ $acls = [];
+ $attribute = $this->share->getAttribute($this->path, 'system.nt_sec_desc.acl.*+');
+
+ foreach (explode(',', $attribute) as $acl) {
+ [$user, $permissions] = explode(':', $acl, 2);
+ [$type, $flags, $mask] = explode('/', $permissions);
+ $mask = hexdec($mask);
+
+ $acls[$user] = new ACL($type, $flags, $mask);
+ }
+
+ return $acls;
+ }
}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeShare.php b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeShare.php
index 1a33f4b0d36..26e7adb019d 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeShare.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeShare.php
@@ -94,9 +94,7 @@ class NativeShare extends AbstractShare {
$name = $file['name'];
if ($name !== '.' and $name !== '..') {
$fullPath = $path . '/' . $name;
- $files [] = new NativeFileInfo($this, $fullPath, $name, function () use ($fullPath) {
- return $this->getStat($fullPath);
- });
+ $files [] = new NativeFileInfo($this, $fullPath, $name);
}
}
@@ -109,7 +107,12 @@ class NativeShare extends AbstractShare {
* @return \Icewind\SMB\IFileInfo
*/
public function stat($path) {
- return new NativeFileInfo($this, $path, self::mb_basename($path), $this->getStat($path));
+ $info = new NativeFileInfo($this, $path, self::mb_basename($path));
+
+ // trigger attribute loading
+ $info->getSize();
+
+ return $info;
}
/**
@@ -129,10 +132,6 @@ class NativeShare extends AbstractShare {
return '';
}
- private function getStat($path) {
- return $this->getState()->stat($this->buildUrl($path));
- }
-
/**
* Create a folder on the share
*
@@ -223,6 +222,12 @@ class NativeShare extends AbstractShare {
if (!$target) {
throw new InvalidPathException('Invalid target path: Filename cannot be empty');
}
+
+ $sourceHandle = $this->getState()->open($this->buildUrl($source), 'r');
+ if (!$sourceHandle) {
+ throw new InvalidResourceException('Failed opening remote file "' . $source . '" for reading');
+ }
+
$targetHandle = @fopen($target, 'wb');
if (!$targetHandle) {
$error = error_get_last();
@@ -231,15 +236,10 @@ class NativeShare extends AbstractShare {
} else {
$reason = 'Unknown error';
}
+ $this->getState()->close($sourceHandle);
throw new InvalidResourceException('Failed opening local file "' . $target . '" for writing: ' . $reason);
}
- $sourceHandle = $this->getState()->open($this->buildUrl($source), 'r');
- if (!$sourceHandle) {
- fclose($targetHandle);
- throw new InvalidResourceException('Failed opening remote file "' . $source . '" for reading');
- }
-
while ($data = $this->getState()->read($sourceHandle, NativeReadStream::CHUNK_SIZE)) {
fwrite($targetHandle, $data);
}
@@ -289,7 +289,7 @@ class NativeShare extends AbstractShare {
*/
public function append($source) {
$url = $this->buildUrl($source);
- $handle = $this->getState()->open($url, "a");
+ $handle = $this->getState()->open($url, "a+");
return NativeWriteStream::wrap($this->getState(), $handle, "a", $url);
}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeState.php b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeState.php
index 5ab129cbfd3..0792b2f9d7f 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeState.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeState.php
@@ -9,6 +9,7 @@ namespace Icewind\SMB\Native;
use Icewind\SMB\Exception\AlreadyExistsException;
use Icewind\SMB\Exception\ConnectionRefusedException;
+use Icewind\SMB\Exception\ConnectionResetException;
use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\FileInUseException;
use Icewind\SMB\Exception\ForbiddenException;
@@ -48,6 +49,7 @@ class NativeState {
22 => InvalidArgumentException::class,
28 => OutOfSpaceException::class,
39 => NotEmptyException::class,
+ 104 => ConnectionResetException::class,
110 => TimedOutException::class,
111 => ConnectionRefusedException::class,
112 => HostDownException::class,
diff --git a/apps/files_external/3rdparty/icewind/smb/src/System.php b/apps/files_external/3rdparty/icewind/smb/src/System.php
index 3428dd87cd6..0e41ee032d6 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/System.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/System.php
@@ -41,6 +41,10 @@ class System implements ISystem {
return $this->getBinaryPath('net');
}
+ public function getSmbcAclsPath() {
+ return $this->getBinaryPath('smbcacls');
+ }
+
public function getStdBufPath() {
return $this->getBinaryPath('stdbuf');
}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Connection.php b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Connection.php
index 830f6fb17b0..347b63db110 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Connection.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Connection.php
@@ -117,8 +117,9 @@ class Connection extends RawConnection {
}
public function close($terminate = true) {
- if (is_resource($this->getInputStream())) {
- $this->write('close' . PHP_EOL);
+ if (get_resource_type($this->getInputStream()) === 'stream') {
+ // ignore any errors while trying to send the close command, the process might already be dead
+ @$this->write('close' . PHP_EOL);
}
parent::close($terminate);
}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/FileInfo.php b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/FileInfo.php
index 094e665a935..a310a6bc913 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/FileInfo.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/FileInfo.php
@@ -7,6 +7,7 @@
namespace Icewind\SMB\Wrapped;
+use Icewind\SMB\ACL;
use Icewind\SMB\IFileInfo;
class FileInfo implements IFileInfo {
@@ -36,18 +37,25 @@ class FileInfo implements IFileInfo {
protected $mode;
/**
+ * @var callable
+ */
+ protected $aclCallback;
+
+ /**
* @param string $path
* @param string $name
* @param int $size
* @param int $time
* @param int $mode
+ * @param callable $aclCallback
*/
- public function __construct($path, $name, $size, $time, $mode) {
+ public function __construct($path, $name, $size, $time, $mode, callable $aclCallback) {
$this->path = $path;
$this->name = $name;
$this->size = $size;
$this->time = $time;
$this->mode = $mode;
+ $this->aclCallback = $aclCallback;
}
/**
@@ -112,4 +120,11 @@ class FileInfo implements IFileInfo {
public function isArchived() {
return (bool)($this->mode & IFileInfo::MODE_ARCHIVE);
}
+
+ /**
+ * @return ACL[]
+ */
+ public function getAcls(): array {
+ return ($this->aclCallback)();
+ }
}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php
index 9eee686c0ba..a28432e4319 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php
@@ -33,7 +33,6 @@ class Parser {
*/
private $host;
- // todo replace with static once <5.6 support is dropped
// see error.h
const EXCEPTION_MAP = [
ErrorCodes::LogonFailure => AuthenticationException::class,
@@ -146,12 +145,12 @@ class Parser {
}
return [
'mtime' => strtotime($data['write_time']),
- 'mode' => hexdec(substr($data['attributes'], strpos($data['attributes'], '('), -1)),
+ 'mode' => hexdec(substr($data['attributes'], strpos($data['attributes'], '(') + 1, -1)),
'size' => isset($data['stream']) ? (int)(explode(' ', $data['stream'])[1]) : 0
];
}
- public function parseDir($output, $basePath) {
+ public function parseDir($output, $basePath, callable $aclCallback) {
//last line is used space
array_pop($output);
$regex = '/^\s*(.*?)\s\s\s\s+(?:([NDHARS]*)\s+)?([0-9]+)\s+(.*)$/';
@@ -163,7 +162,10 @@ class Parser {
if ($name !== '.' and $name !== '..') {
$mode = $this->parseMode($mode);
$time = strtotime($time . ' ' . $this->timeZone);
- $content[] = new FileInfo($basePath . '/' . $name, $name, $size, $time, $mode);
+ $path = $basePath . '/' . $name;
+ $content[] = new FileInfo($path, $name, $size, $time, $mode, function () use ($aclCallback, $path) {
+ return $aclCallback($path);
+ });
}
}
}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php
index f29cf60eb66..3a114af5e4f 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php
@@ -173,18 +173,6 @@ class RawConnection {
return;
}
if ($terminate) {
- // if for case that posix_ functions are not available
- if (function_exists('posix_kill')) {
- $status = proc_get_status($this->process);
- $ppid = $status['pid'];
- $pids = preg_split('/\s+/', `ps -o pid --no-heading --ppid $ppid`);
- foreach ($pids as $pid) {
- if (is_numeric($pid)) {
- //9 is the SIGKILL signal
- posix_kill($pid, 9);
- }
- }
- }
proc_terminate($this->process);
}
proc_close($this->process);
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php
index 5a79c49fecf..18ee5c1db97 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php
@@ -8,19 +8,17 @@
namespace Icewind\SMB\Wrapped;
use Icewind\SMB\AbstractShare;
+use Icewind\SMB\ACL;
use Icewind\SMB\Exception\ConnectionException;
use Icewind\SMB\Exception\DependencyException;
use Icewind\SMB\Exception\FileInUseException;
use Icewind\SMB\Exception\InvalidTypeException;
use Icewind\SMB\Exception\NotFoundException;
-use Icewind\SMB\Exception\InvalidRequestException;
use Icewind\SMB\IFileInfo;
use Icewind\SMB\INotifyHandler;
use Icewind\SMB\IServer;
use Icewind\SMB\ISystem;
use Icewind\Streams\CallbackWrapper;
-use Icewind\SMB\Native\NativeShare;
-use Icewind\SMB\Native\NativeServer;
class Share extends AbstractShare {
/**
@@ -55,6 +53,8 @@ class Share extends AbstractShare {
FileInfo::MODE_SYSTEM => 's'
];
+ const EXEC_CMD = 'exec';
+
/**
* @param IServer $server
* @param string $name
@@ -78,7 +78,8 @@ class Share extends AbstractShare {
protected function getConnection() {
$command = sprintf(
- '%s%s -t %s %s %s %s',
+ '%s %s%s -t %s %s %s %s',
+ self::EXEC_CMD,
$this->system->getStdBufPath() ? $this->system->getStdBufPath() . ' -o0 ' : '',
$this->system->getSmbclientPath(),
$this->server->getOptions()->getTimeout(),
@@ -150,7 +151,9 @@ class Share extends AbstractShare {
$this->execute('cd /');
- return $this->parser->parseDir($output, $path);
+ return $this->parser->parseDir($output, $path, function ($path) {
+ return $this->getAcls($path);
+ });
}
/**
@@ -183,7 +186,9 @@ class Share extends AbstractShare {
$this->parseOutput($output, $path);
}
$stat = $this->parser->parseStat($output);
- return new FileInfo($path, basename($path), $stat['size'], $stat['mtime'], $stat['mode']);
+ return new FileInfo($path, basename($path), $stat['size'], $stat['mtime'], $stat['mode'], function () use ($path) {
+ return $this->getAcls($path);
+ });
}
/**
@@ -418,13 +423,13 @@ class Share extends AbstractShare {
* @param string[] $lines
* @param string $path
*
- * @throws NotFoundException
+ * @return bool
* @throws \Icewind\SMB\Exception\AlreadyExistsException
* @throws \Icewind\SMB\Exception\AccessDeniedException
* @throws \Icewind\SMB\Exception\NotEmptyException
* @throws \Icewind\SMB\Exception\InvalidTypeException
* @throws \Icewind\SMB\Exception\Exception
- * @return bool
+ * @throws NotFoundException
*/
protected function parseOutput($lines, $path = '') {
if (count($lines) === 0) {
@@ -467,6 +472,83 @@ class Share extends AbstractShare {
return '"' . $path . '"';
}
+ protected function getAcls($path) {
+ $commandPath = $this->system->getSmbcAclsPath();
+ if (!$commandPath) {
+ return [];
+ }
+
+ $command = sprintf(
+ '%s %s %s %s/%s %s',
+ $commandPath,
+ $this->getAuthFileArgument(),
+ $this->server->getAuth()->getExtraCommandLineArguments(),
+ escapeshellarg('//' . $this->server->getHost()),
+ escapeshellarg($this->name),
+ escapeshellarg($path)
+ );
+ $connection = new RawConnection($command);
+ $connection->writeAuthentication($this->server->getAuth()->getUsername(), $this->server->getAuth()->getPassword());
+ $connection->connect();
+ if (!$connection->isValid()) {
+ throw new ConnectionException($connection->readLine());
+ }
+
+ $rawAcls = $connection->readAll();
+
+ $acls = [];
+ foreach ($rawAcls as $acl) {
+ [$type, $acl] = explode(':', $acl, 2);
+ if ($type !== 'ACL') {
+ continue;
+ }
+ [$user, $permissions] = explode(':', $acl, 2);
+ [$type, $flags, $mask] = explode('/', $permissions);
+
+ $type = $type === 'ALLOWED' ? ACL::TYPE_ALLOW : ACL::TYPE_DENY;
+
+ $flagsInt = 0;
+ foreach (explode('|', $flags) as $flagString) {
+ if ($flagString === 'OI') {
+ $flagsInt += ACL::FLAG_OBJECT_INHERIT;
+ } elseif ($flagString === 'CI') {
+ $flagsInt += ACL::FLAG_CONTAINER_INHERIT;
+ }
+ }
+
+ if (substr($mask, 0, 2) === '0x') {
+ $maskInt = hexdec($mask);
+ } else {
+ $maskInt = 0;
+ foreach (explode('|', $mask) as $maskString) {
+ if ($maskString === 'R') {
+ $maskInt += ACL::MASK_READ;
+ } elseif ($maskString === 'W') {
+ $maskInt += ACL::MASK_WRITE;
+ } elseif ($maskString === 'X') {
+ $maskInt += ACL::MASK_EXECUTE;
+ } elseif ($maskString === 'D') {
+ $maskInt += ACL::MASK_DELETE;
+ } elseif ($maskString === 'READ') {
+ $maskInt += ACL::MASK_READ + ACL::MASK_EXECUTE;
+ } elseif ($maskString === 'CHANGE') {
+ $maskInt += ACL::MASK_READ + ACL::MASK_EXECUTE + ACL::MASK_WRITE + ACL::MASK_DELETE;
+ } elseif ($maskString === 'FULL') {
+ $maskInt += ACL::MASK_READ + ACL::MASK_EXECUTE + ACL::MASK_WRITE + ACL::MASK_DELETE;
+ }
+ }
+ }
+
+ if (isset($acls[$user])) {
+ $existing = $acls[$user];
+ $maskInt += $existing->getMask();
+ }
+ $acls[$user] = new ACL($type, $flagsInt, $maskInt);
+ }
+
+ return $acls;
+ }
+
public function __destruct() {
unset($this->connection);
}
diff --git a/apps/files_external/ajax/applicable.php b/apps/files_external/ajax/applicable.php
index 0a6b9f5af46..bda2c919596 100644
--- a/apps/files_external/ajax/applicable.php
+++ b/apps/files_external/ajax/applicable.php
@@ -51,6 +51,6 @@ foreach (\OC::$server->getUserManager()->searchDisplayName($pattern, $limit, $of
$users[$user->getUID()] = $user->getDisplayName();
}
-$results = array('groups' => $groups, 'users' => $users);
+$results = ['groups' => $groups, 'users' => $users];
\OC_JSON::success($results);
diff --git a/apps/files_external/l10n/da.js b/apps/files_external/l10n/da.js
index 87048d85d25..d6445ca8898 100644
--- a/apps/files_external/l10n/da.js
+++ b/apps/files_external/l10n/da.js
@@ -22,6 +22,7 @@ OC.L10N.register(
"Read only" : "Skrivebeskyttet",
"Delete" : "Slet",
"Admin defined" : "Bestemt af administrator",
+ "Are you sure you want to delete this external storage?" : "Er du sikker på at du vil slette dette eksterne lager?",
"Delete storage?" : "Slet lager?",
"Saved" : "Gemt",
"Saving …" : "Gemmer…",
@@ -73,9 +74,13 @@ OC.L10N.register(
"Log-in credentials, save in database" : "Log-in brugeroplysninger, gem i database",
"Username and password" : "Brugernavn og kodeord",
"Log-in credentials, save in session" : "Log-in brugeroplysninger, gem i session",
+ "Global credentials, user entered" : "Globale brugeroplysninger, angivet af bruger",
"User entered, store in database" : "Bruger indtastet, gem i database",
"RSA public key" : "RSA offentlig nøgle",
"Public key" : "Offentlig nøgle",
+ "RSA private key" : "RSA private key",
+ "Private key" : "Private key",
+ "Kerberos ticket" : "Kerberos billet",
"Amazon S3" : "Amazon S3",
"Bucket" : "Bucket",
"Hostname" : "Værtsnavn",
diff --git a/apps/files_external/l10n/da.json b/apps/files_external/l10n/da.json
index adb0d7540fa..c31ef163089 100644
--- a/apps/files_external/l10n/da.json
+++ b/apps/files_external/l10n/da.json
@@ -20,6 +20,7 @@
"Read only" : "Skrivebeskyttet",
"Delete" : "Slet",
"Admin defined" : "Bestemt af administrator",
+ "Are you sure you want to delete this external storage?" : "Er du sikker på at du vil slette dette eksterne lager?",
"Delete storage?" : "Slet lager?",
"Saved" : "Gemt",
"Saving …" : "Gemmer…",
@@ -71,9 +72,13 @@
"Log-in credentials, save in database" : "Log-in brugeroplysninger, gem i database",
"Username and password" : "Brugernavn og kodeord",
"Log-in credentials, save in session" : "Log-in brugeroplysninger, gem i session",
+ "Global credentials, user entered" : "Globale brugeroplysninger, angivet af bruger",
"User entered, store in database" : "Bruger indtastet, gem i database",
"RSA public key" : "RSA offentlig nøgle",
"Public key" : "Offentlig nøgle",
+ "RSA private key" : "RSA private key",
+ "Private key" : "Private key",
+ "Kerberos ticket" : "Kerberos billet",
"Amazon S3" : "Amazon S3",
"Bucket" : "Bucket",
"Hostname" : "Værtsnavn",
diff --git a/apps/files_external/l10n/sl.js b/apps/files_external/l10n/sl.js
index 33f151d95e3..9c7f46ce1cb 100644
--- a/apps/files_external/l10n/sl.js
+++ b/apps/files_external/l10n/sl.js
@@ -39,6 +39,7 @@ OC.L10N.register(
"Credentials saved" : "Poverila so shranjena",
"Credentials saving failed" : "Shranjevanje poveril je spodletelo",
"Credentials required" : "Zahtevana so poverila",
+ "Storage with ID \"%d\" not found" : "Shrambe z ID »%d« ni mogoče najti.",
"Invalid backend or authentication mechanism class" : "Neveljaven ozadnji program oziroma razred mehanizma overitve",
"Invalid mount point" : "Neveljavna priklopna točka",
"Objectstore forbidden" : "Shranjevanje predmeta je prepovedano",
@@ -49,6 +50,7 @@ OC.L10N.register(
"Unsatisfied authentication mechanism parameters" : "Nezadovoljivi parametri mehanizma overitve",
"Insufficient data: %s" : "Nepopolni podatki: %s",
"%s" : "%s",
+ "Storage with ID \"%d\" is not user editable" : "Shrambe z ID »%d« ni mogoče uporabniško urediti.",
"Access key" : "Ključ za dostop",
"Secret key" : "Skrivni ključ",
"Builtin" : "Vgrajeno",
@@ -116,9 +118,11 @@ OC.L10N.register(
"Authentication" : "Overitev",
"Configuration" : "Nastavitve",
"Available for" : "Na voljo za",
+ "Click to recheck the configuration" : "Kliknite za ponovno preverjanje nastavitev",
"Add storage" : "Dodaj shrambo",
"Advanced settings" : "Napredne nastavitve",
"Allow users to mount external storage" : "Dovoli uporabnikom priklapljanje zunanje shrambe",
+ "Global credentials can be used to authenticate with multiple external storages that have the same credentials." : "Splošna poverila je mogoče uporabiti za overitev z več zunanjimi shrambami, ki uporabljajo enaka poverila.",
"Saving..." : "Poteka shranjevanje ..."
},
"nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);");
diff --git a/apps/files_external/l10n/sl.json b/apps/files_external/l10n/sl.json
index cb1e46c757d..8b533d5c855 100644
--- a/apps/files_external/l10n/sl.json
+++ b/apps/files_external/l10n/sl.json
@@ -37,6 +37,7 @@
"Credentials saved" : "Poverila so shranjena",
"Credentials saving failed" : "Shranjevanje poveril je spodletelo",
"Credentials required" : "Zahtevana so poverila",
+ "Storage with ID \"%d\" not found" : "Shrambe z ID »%d« ni mogoče najti.",
"Invalid backend or authentication mechanism class" : "Neveljaven ozadnji program oziroma razred mehanizma overitve",
"Invalid mount point" : "Neveljavna priklopna točka",
"Objectstore forbidden" : "Shranjevanje predmeta je prepovedano",
@@ -47,6 +48,7 @@
"Unsatisfied authentication mechanism parameters" : "Nezadovoljivi parametri mehanizma overitve",
"Insufficient data: %s" : "Nepopolni podatki: %s",
"%s" : "%s",
+ "Storage with ID \"%d\" is not user editable" : "Shrambe z ID »%d« ni mogoče uporabniško urediti.",
"Access key" : "Ključ za dostop",
"Secret key" : "Skrivni ključ",
"Builtin" : "Vgrajeno",
@@ -114,9 +116,11 @@
"Authentication" : "Overitev",
"Configuration" : "Nastavitve",
"Available for" : "Na voljo za",
+ "Click to recheck the configuration" : "Kliknite za ponovno preverjanje nastavitev",
"Add storage" : "Dodaj shrambo",
"Advanced settings" : "Napredne nastavitve",
"Allow users to mount external storage" : "Dovoli uporabnikom priklapljanje zunanje shrambe",
+ "Global credentials can be used to authenticate with multiple external storages that have the same credentials." : "Splošna poverila je mogoče uporabiti za overitev z več zunanjimi shrambami, ki uporabljajo enaka poverila.",
"Saving..." : "Poteka shranjevanje ..."
},"pluralForm" :"nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);"
} \ No newline at end of file
diff --git a/apps/files_external/l10n/sv.js b/apps/files_external/l10n/sv.js
index 323fd899533..4479ac25469 100644
--- a/apps/files_external/l10n/sv.js
+++ b/apps/files_external/l10n/sv.js
@@ -111,7 +111,7 @@ OC.L10N.register(
"OpenStack Object Storage" : "OpenStack Object Storage",
"Service name" : "Namn på tjänst",
"Request timeout (seconds)" : "Sekunder för anslutningsförsök",
- "The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "cURL-stöd i PHP är inte aktiverat eller har inte installerats. Montering av %s är inte möjlig. Be din systemadministratör om installation.",
+ "The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "cURL-stödet i PHP är inte aktiverat eller installerat. Montering av %s är inte möjlig. Vänligen be din systemadministratör att installera den.",
"The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "FTP-stöd i PHP är inte aktiverat eller har inte installerats. Montering av %s är inte möjlig. Be din systemadministratör om installation.",
"\"%1$s\" is not installed. Mounting of %2$s is not possible. Please ask your system administrator to install it." : "\"%1$s\" är inte installerad. Montering av %2$s är inte möjlig. Be din systemadministratör att installera den.",
"External storage support" : "Stöd för extern lagring",
diff --git a/apps/files_external/l10n/sv.json b/apps/files_external/l10n/sv.json
index 8c3067e6ba2..c634546565c 100644
--- a/apps/files_external/l10n/sv.json
+++ b/apps/files_external/l10n/sv.json
@@ -109,7 +109,7 @@
"OpenStack Object Storage" : "OpenStack Object Storage",
"Service name" : "Namn på tjänst",
"Request timeout (seconds)" : "Sekunder för anslutningsförsök",
- "The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "cURL-stöd i PHP är inte aktiverat eller har inte installerats. Montering av %s är inte möjlig. Be din systemadministratör om installation.",
+ "The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "cURL-stödet i PHP är inte aktiverat eller installerat. Montering av %s är inte möjlig. Vänligen be din systemadministratör att installera den.",
"The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "FTP-stöd i PHP är inte aktiverat eller har inte installerats. Montering av %s är inte möjlig. Be din systemadministratör om installation.",
"\"%1$s\" is not installed. Mounting of %2$s is not possible. Please ask your system administrator to install it." : "\"%1$s\" är inte installerad. Montering av %2$s är inte möjlig. Be din systemadministratör att installera den.",
"External storage support" : "Stöd för extern lagring",
diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php
index 761eeff113f..47f52fbcb87 100644
--- a/apps/files_external/lib/AppInfo/Application.php
+++ b/apps/files_external/lib/AppInfo/Application.php
@@ -62,8 +62,6 @@ use OCA\Files_External\Lib\Config\IAuthMechanismProvider;
use OCA\Files_External\Lib\Config\IBackendProvider;
use OCA\Files_External\Service\BackendService;
use OCP\AppFramework\App;
-use OCP\AppFramework\IAppContainer;
-use OCP\Files\Config\IUserMountCache;
use OCP\IGroup;
use OCP\IUser;
use Symfony\Component\EventDispatcher\GenericEvent;
diff --git a/apps/files_external/lib/Controller/AjaxController.php b/apps/files_external/lib/Controller/AjaxController.php
index 347fa02e1b0..b9e414a410a 100644
--- a/apps/files_external/lib/Controller/AjaxController.php
+++ b/apps/files_external/lib/Controller/AjaxController.php
@@ -88,12 +88,12 @@ class AjaxController extends Controller {
public function getSshKeys($keyLength = 1024) {
$key = $this->generateSshKeys($keyLength);
return new JSONResponse(
- array('data' => array(
+ ['data' => [
'private_key' => $key['privatekey'],
'public_key' => $key['publickey']
- ),
+ ],
'status' => 'success'
- ));
+ ]);
}
/**
diff --git a/apps/files_external/lib/Controller/ApiController.php b/apps/files_external/lib/Controller/ApiController.php
index 1882ea31504..aa0c8ddb6a1 100644
--- a/apps/files_external/lib/Controller/ApiController.php
+++ b/apps/files_external/lib/Controller/ApiController.php
@@ -74,7 +74,7 @@ class ApiController extends OCSController {
$permissions |= \OCP\Constants::PERMISSION_DELETE;
}
- $entry = array(
+ $entry = [
'name' => basename($mountPoint),
'path' => $path,
'type' => 'dir',
@@ -83,7 +83,7 @@ class ApiController extends OCSController {
'permissions' => $permissions,
'id' => $mountConfig['id'],
'class' => $mountConfig['class']
- );
+ ];
return $entry;
}
diff --git a/apps/files_external/lib/Controller/GlobalStoragesController.php b/apps/files_external/lib/Controller/GlobalStoragesController.php
index c8fc4b00ef8..a3c9fbb284c 100644
--- a/apps/files_external/lib/Controller/GlobalStoragesController.php
+++ b/apps/files_external/lib/Controller/GlobalStoragesController.php
@@ -171,7 +171,7 @@ class GlobalStoragesController extends StoragesController {
} catch (NotFoundException $e) {
return new DataResponse(
[
- 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
+ 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
],
Http::STATUS_NOT_FOUND
);
diff --git a/apps/files_external/lib/Controller/UserGlobalStoragesController.php b/apps/files_external/lib/Controller/UserGlobalStoragesController.php
index 8e0dac5a898..a3a258c599a 100644
--- a/apps/files_external/lib/Controller/UserGlobalStoragesController.php
+++ b/apps/files_external/lib/Controller/UserGlobalStoragesController.php
@@ -124,7 +124,7 @@ class UserGlobalStoragesController extends StoragesController {
} catch (NotFoundException $e) {
return new DataResponse(
[
- 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
+ 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
],
Http::STATUS_NOT_FOUND
);
@@ -164,7 +164,7 @@ class UserGlobalStoragesController extends StoragesController {
} else {
return new DataResponse(
[
- 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', array($id))
+ 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', [$id])
],
Http::STATUS_FORBIDDEN
);
@@ -172,7 +172,7 @@ class UserGlobalStoragesController extends StoragesController {
} catch (NotFoundException $e) {
return new DataResponse(
[
- 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
+ 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
],
Http::STATUS_NOT_FOUND
);
diff --git a/apps/files_external/lib/Controller/UserStoragesController.php b/apps/files_external/lib/Controller/UserStoragesController.php
index 46285c4758a..df42198aeb3 100644
--- a/apps/files_external/lib/Controller/UserStoragesController.php
+++ b/apps/files_external/lib/Controller/UserStoragesController.php
@@ -199,7 +199,7 @@ class UserStoragesController extends StoragesController {
} catch (NotFoundException $e) {
return new DataResponse(
[
- 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
+ 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
],
Http::STATUS_NOT_FOUND
);
diff --git a/apps/files_external/lib/Lib/Backend/InvalidBackend.php b/apps/files_external/lib/Lib/Backend/InvalidBackend.php
index 5b574d8cd00..fc9b0992197 100644
--- a/apps/files_external/lib/Lib/Backend/InvalidBackend.php
+++ b/apps/files_external/lib/Lib/Backend/InvalidBackend.php
@@ -24,7 +24,6 @@
namespace OCA\Files_External\Lib\Backend;
-use OCA\Files_External\Lib\Storage\InvalidStorage;
use OCA\Files_External\Lib\StorageConfig;
use OCP\Files\StorageNotAvailableException;
use OCP\IUser;
diff --git a/apps/files_external/lib/Lib/Backend/Swift.php b/apps/files_external/lib/Lib/Backend/Swift.php
index e2d6c6848c4..86238b542b1 100644
--- a/apps/files_external/lib/Lib/Backend/Swift.php
+++ b/apps/files_external/lib/Lib/Backend/Swift.php
@@ -30,7 +30,6 @@ use OCA\Files_External\Lib\Auth\OpenStack\OpenStackV2;
use OCA\Files_External\Lib\Auth\OpenStack\Rackspace;
use OCA\Files_External\Lib\DefinitionParameter;
use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
-use OCA\Files_External\Service\BackendService;
use OCP\IL10N;
class Swift extends Backend {
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index 60e39a4d300..0d7cbacd8b5 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -128,10 +128,10 @@ class AmazonS3 extends \OC\Files\Storage\Common {
private function headObject($key) {
if (!isset($this->objectCache[$key])) {
try {
- $this->objectCache[$key] = $this->getConnection()->headObject(array(
+ $this->objectCache[$key] = $this->getConnection()->headObject([
'Bucket' => $this->bucket,
'Key' => $key
- ));
+ ]);
} catch (S3Exception $e) {
if ($e->getStatusCode() >= 500) {
throw $e;
@@ -191,7 +191,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$stmt = \OC::$server->getDatabaseConnection()->prepare(
'SELECT `numeric_id`, `id` FROM `*PREFIX*storages` WHERE `id` IN (?, ?)'
);
- $stmt->execute(array($oldId, $this->id));
+ $stmt->execute([$oldId, $this->id]);
while ($row = $stmt->fetch()) {
$storages[$row['id']] = $row['numeric_id'];
}
@@ -204,7 +204,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$stmt = \OC::$server->getDatabaseConnection()->prepare(
'UPDATE `*PREFIX*storages` SET `id` = ? WHERE `id` = ?'
);
- $stmt->execute(array($this->id, $oldId));
+ $stmt->execute([$this->id, $oldId]);
}
// only the bucket based id may exist, do nothing
}
@@ -235,12 +235,12 @@ class AmazonS3 extends \OC\Files\Storage\Common {
}
try {
- $this->getConnection()->putObject(array(
+ $this->getConnection()->putObject([
'Bucket' => $this->bucket,
'Key' => $path . '/',
'Body' => '',
'ContentType' => 'httpd/unix-directory'
- ));
+ ]);
$this->testTimeout();
} catch (S3Exception $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
@@ -284,9 +284,9 @@ class AmazonS3 extends \OC\Files\Storage\Common {
}
private function batchDelete($path = null) {
- $params = array(
+ $params = [
'Bucket' => $this->bucket
- );
+ ];
if ($path !== null) {
$params['Prefix'] = $path . '/';
}
@@ -326,7 +326,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
}
try {
- $files = array();
+ $files = [];
$results = $this->getConnection()->getPaginator('ListObjects', [
'Bucket' => $this->bucket,
'Delimiter' => '/',
@@ -550,7 +550,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
public function touch($path, $mtime = null) {
$path = $this->normalizePath($path);
- $metadata = array();
+ $metadata = [];
if (is_null($mtime)) {
$mtime = time();
}
@@ -599,11 +599,11 @@ class AmazonS3 extends \OC\Files\Storage\Common {
if ($this->is_file($path1)) {
try {
- $this->getConnection()->copyObject(array(
+ $this->getConnection()->copyObject([
'Bucket' => $this->bucket,
'Key' => $this->cleanKey($path2),
'CopySource' => S3Client::encodeKey($this->bucket . '/' . $path1)
- ));
+ ]);
$this->testTimeout();
} catch (S3Exception $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
@@ -613,11 +613,11 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$this->remove($path2);
try {
- $this->getConnection()->copyObject(array(
+ $this->getConnection()->copyObject([
'Bucket' => $this->bucket,
'Key' => $path2 . '/',
'CopySource' => S3Client::encodeKey($this->bucket . '/' . $path1 . '/')
- ));
+ ]);
$this->testTimeout();
} catch (S3Exception $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
diff --git a/apps/files_external/lib/Lib/Storage/FTP.php b/apps/files_external/lib/Lib/Storage/FTP.php
index 8f014ce921c..adf7f29a3d6 100644
--- a/apps/files_external/lib/Lib/Storage/FTP.php
+++ b/apps/files_external/lib/Lib/Storage/FTP.php
@@ -109,7 +109,7 @@ class FTP extends StreamWrapper{
case 'a':
case 'ab':
//these are supported by the wrapper
- $context = stream_context_create(array('ftp' => array('overwrite' => true)));
+ $context = stream_context_create(['ftp' => ['overwrite' => true]]);
$handle = fopen($this->constructUrl($path), $mode, false, $context);
return RetryWrapper::wrap($handle);
case 'r+':
@@ -150,7 +150,7 @@ class FTP extends StreamWrapper{
if (function_exists('ftp_login')) {
return true;
} else {
- return array('ftp');
+ return ['ftp'];
}
}
diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php
index 5d83bf253e4..eaead3eea45 100644
--- a/apps/files_external/lib/Lib/Storage/SFTP.php
+++ b/apps/files_external/lib/Lib/Storage/SFTP.php
@@ -251,8 +251,8 @@ class SFTP extends \OC\Files\Storage\Common {
try {
$keyPath = $this->hostKeysPath();
if (file_exists($keyPath)) {
- $hosts = array();
- $keys = array();
+ $hosts = [];
+ $keys = [];
$lines = file($keyPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($lines) {
foreach ($lines as $line) {
@@ -267,7 +267,7 @@ class SFTP extends \OC\Files\Storage\Common {
}
} catch (\Exception $e) {
}
- return array();
+ return [];
}
/**
@@ -307,7 +307,7 @@ class SFTP extends \OC\Files\Storage\Common {
}
$id = md5('sftp:' . $path);
- $dirStream = array();
+ $dirStream = [];
foreach($list as $file) {
if ($file !== '.' && $file !== '..') {
$dirStream[] = $file;
@@ -391,7 +391,7 @@ class SFTP extends \OC\Files\Storage\Common {
case 'x+':
case 'c':
case 'c+':
- $context = stream_context_create(array('sftp' => array('session' => $this->getConnection())));
+ $context = stream_context_create(['sftp' => ['session' => $this->getConnection()]]);
$handle = fopen($this->constructUrl($path), $mode, false, $context);
return RetryWrapper::wrap($handle);
}
@@ -464,7 +464,7 @@ class SFTP extends \OC\Files\Storage\Common {
$mtime = $stat ? $stat['mtime'] : -1;
$size = $stat ? $stat['size'] : 0;
- return array('mtime' => $mtime, 'size' => $size, 'ctime' => -1);
+ return ['mtime' => $mtime, 'size' => $size, 'ctime' => -1];
} catch (\Exception $e) {
return false;
}
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index de9f41ac672..e2b925e07a2 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -472,7 +472,7 @@ class SMB extends Common implements INotifyStorage {
}
try {
- $this->statCache = array();
+ $this->statCache = [];
$content = $this->share->dir($this->buildPath($path));
foreach ($content as $file) {
if ($file->isDirectory()) {
diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php
index 0072f91d4ed..daa222def04 100644
--- a/apps/files_external/lib/Lib/Storage/Swift.php
+++ b/apps/files_external/lib/Lib/Storage/Swift.php
@@ -351,7 +351,7 @@ class Swift extends \OC\Files\Storage\Common {
$mtime = floor($mtime);
}
- $stat = array();
+ $stat = [];
$stat['size'] = (int)$object->contentLength;
$stat['mtime'] = $mtime;
$stat['atime'] = time();
@@ -602,7 +602,7 @@ class Swift extends \OC\Files\Storage\Common {
}
$path = $this->normalizePath($path);
$dh = $this->opendir($path);
- $content = array();
+ $content = [];
while (($file = readdir($dh)) !== false) {
$content[] = $file;
}
diff --git a/apps/files_external/lib/Migration/StorageMigrator.php b/apps/files_external/lib/Migration/StorageMigrator.php
index 8802e7b82b9..5fef0d3ac38 100644
--- a/apps/files_external/lib/Migration/StorageMigrator.php
+++ b/apps/files_external/lib/Migration/StorageMigrator.php
@@ -26,7 +26,6 @@ namespace OCA\Files_External\Migration;
use OCA\Files_External\Service\BackendService;
use OCA\Files_External\Service\DBConfigService;
-use OCA\Files_External\Service\GlobalLegacyStoragesService;
use OCA\Files_External\Service\LegacyStoragesService;
use OCA\Files_External\Service\StoragesService;
use OCA\Files_External\Service\UserLegacyStoragesService;
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index f799fd25f57..a65b3b3a9c2 100644
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -96,7 +96,7 @@ class OC_Mount_Config {
* @deprecated 8.2.0 use UserGlobalStoragesService::getStorages() and UserStoragesService::getStorages()
*/
public static function getAbsoluteMountPoints($uid) {
- $mountPoints = array();
+ $mountPoints = [];
$userGlobalStoragesService = self::$app->getContainer()->query(UserGlobalStoragesService::class);
$userStoragesService = self::$app->getContainer()->query(UserStoragesService::class);
@@ -296,7 +296,7 @@ class OC_Mount_Config {
return $mountPoints;
}
}
- return array();
+ return [];
}
/**
@@ -430,14 +430,14 @@ class OC_Mount_Config {
*/
public static function makeConfigHash($config) {
$data = json_encode(
- array(
+ [
'c' => $config['backend'],
'a' => $config['authMechanism'],
'm' => $config['mountpoint'],
'o' => $config['options'],
'p' => isset($config['priority']) ? $config['priority'] : -1,
'mo' => isset($config['mountOptions']) ? $config['mountOptions'] : [],
- )
+ ]
);
return hash('md5', $data);
}
diff --git a/apps/files_external/tests/Auth/Password/GlobalAuth.php b/apps/files_external/tests/Auth/Password/GlobalAuth.php
index bcfcaedbac1..88569c9cac9 100644
--- a/apps/files_external/tests/Auth/Password/GlobalAuth.php
+++ b/apps/files_external/tests/Auth/Password/GlobalAuth.php
@@ -57,22 +57,22 @@ class GlobalAuthTest extends TestCase {
$storageConfig = $this->createMock(StorageConfig::class);
$storageConfig->expects($this->any())
->method('getType')
- ->will($this->returnValue($type));
+ ->willReturn($type);
$storageConfig->expects($this->any())
->method('getBackendOptions')
- ->will($this->returnCallback(function () use (&$config) {
+ ->willReturnCallback(function () use (&$config) {
return $config;
- }));
+ });
$storageConfig->expects($this->any())
->method('getBackendOption')
- ->will($this->returnCallback(function ($key) use (&$config) {
+ ->willReturnCallback(function ($key) use (&$config) {
return $config[$key];
- }));
+ });
$storageConfig->expects($this->any())
->method('setBackendOption')
- ->will($this->returnCallback(function ($key, $value) use (&$config) {
+ ->willReturnCallback(function ($key, $value) use (&$config) {
$config[$key] = $value;
- }));
+ });
return $storageConfig;
}
@@ -80,7 +80,7 @@ class GlobalAuthTest extends TestCase {
public function testNoCredentials() {
$this->credentialsManager->expects($this->once())
->method('retrieve')
- ->will($this->returnValue(null));
+ ->willReturn(null);
$storage = $this->getStorageConfig(StorageConfig::MOUNT_TYPE_ADMIN);
@@ -91,10 +91,10 @@ class GlobalAuthTest extends TestCase {
public function testSavedCredentials() {
$this->credentialsManager->expects($this->once())
->method('retrieve')
- ->will($this->returnValue([
+ ->willReturn([
'user' => 'a',
'password' => 'b'
- ]));
+ ]);
$storage = $this->getStorageConfig(StorageConfig::MOUNT_TYPE_ADMIN);
diff --git a/apps/files_external/tests/Command/ApplicableTest.php b/apps/files_external/tests/Command/ApplicableTest.php
index 3b889ceaa78..49fae6e0013 100644
--- a/apps/files_external/tests/Command/ApplicableTest.php
+++ b/apps/files_external/tests/Command/ApplicableTest.php
@@ -36,11 +36,11 @@ class ApplicableTest extends CommandTest {
$userManager->expects($this->any())
->method('userExists')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$groupManager->expects($this->any())
->method('groupExists')
- ->will($this->returnValue(true));
+ ->willReturn(true);
return new Applicable($storageService, $userManager, $groupManager);
}
diff --git a/apps/files_external/tests/Command/CommandTest.php b/apps/files_external/tests/Command/CommandTest.php
index 39688a2e321..2e7e377c28e 100644
--- a/apps/files_external/tests/Command/CommandTest.php
+++ b/apps/files_external/tests/Command/CommandTest.php
@@ -53,14 +53,14 @@ abstract class CommandTest extends TestCase {
protected function bindMounts(\PHPUnit_Framework_MockObject_MockObject $mock, array $mounts) {
$mock->expects($this->any())
->method('getStorage')
- ->will($this->returnCallback(function ($id) use ($mounts) {
+ ->willReturnCallback(function ($id) use ($mounts) {
foreach ($mounts as $mount) {
if ($mount->getId() === $id) {
return $mount;
}
}
throw new NotFoundException();
- }));
+ });
}
/**
diff --git a/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php b/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php
index f784a726694..b829525b516 100644
--- a/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php
@@ -28,7 +28,6 @@ namespace OCA\Files_External\Tests\Controller;
use OCA\Files_External\Controller\GlobalStoragesController;
use OCA\Files_External\Service\BackendService;
-use OCP\AppFramework\Http;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
diff --git a/apps/files_external/tests/Controller/StoragesControllerTest.php b/apps/files_external/tests/Controller/StoragesControllerTest.php
index 7dee96e3412..56311a7be4c 100644
--- a/apps/files_external/tests/Controller/StoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/StoragesControllerTest.php
@@ -108,16 +108,16 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->service->expects($this->once())
->method('createStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$this->service->expects($this->once())
->method('addStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$response = $this->controller->create(
'mount',
'\OCA\Files_External\Lib\Storage\SMB',
'\OCA\Files_External\Lib\Auth\NullMechanism',
- array(),
+ [],
[],
[],
[],
@@ -149,17 +149,17 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->service->expects($this->once())
->method('createStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$this->service->expects($this->once())
->method('updateStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$response = $this->controller->update(
1,
'mount',
'\OCA\Files_External\Lib\Storage\SMB',
'\OCA\Files_External\Lib\Auth\NullMechanism',
- array(),
+ [],
[],
[],
[],
@@ -172,11 +172,11 @@ abstract class StoragesControllerTest extends \Test\TestCase {
}
function mountPointNamesProvider() {
- return array(
- array(''),
- array('/'),
- array('//'),
- );
+ return [
+ [''],
+ ['/'],
+ ['//'],
+ ];
}
/**
@@ -191,7 +191,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->service->expects($this->exactly(2))
->method('createStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$this->service->expects($this->never())
->method('addStorage');
$this->service->expects($this->never())
@@ -201,7 +201,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$mountPoint,
'\OCA\Files_External\Lib\Storage\SMB',
'\OCA\Files_External\Lib\Auth\NullMechanism',
- array(),
+ [],
[],
[],
[],
@@ -215,7 +215,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$mountPoint,
'\OCA\Files_External\Lib\Storage\SMB',
'\OCA\Files_External\Lib\Auth\NullMechanism',
- array(),
+ [],
[],
[],
[],
@@ -238,7 +238,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
'mount',
'\OC\Files\Storage\InvalidStorage',
'\OCA\Files_External\Lib\Auth\NullMechanism',
- array(),
+ [],
[],
[],
[],
@@ -252,7 +252,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
'mount',
'\OC\Files\Storage\InvalidStorage',
'\OCA\Files_External\Lib\Auth\NullMechanism',
- array(),
+ [],
[],
[],
[],
@@ -282,7 +282,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->service->expects($this->once())
->method('createStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$this->service->expects($this->once())
->method('updateStorage')
->will($this->throwException(new NotFoundException()));
@@ -292,7 +292,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
'mount',
'\OCA\Files_External\Lib\Storage\SMB',
'\OCA\Files_External\Lib\Auth\NullMechanism',
- array(),
+ [],
[],
[],
[],
@@ -332,7 +332,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->service->expects($this->once())
->method('getStorage')
->with(1)
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$response = $this->controller->show(1);
$this->assertEquals(Http::STATUS_OK, $response->getStatus());
@@ -360,7 +360,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$authMech = $this->getAuthMechMock();
$authMech->method('validateStorage')
- ->will($this->returnValue($authMechValidate));
+ ->willReturn($authMechValidate);
$authMech->method('isVisibleFor')
->willReturn(true);
@@ -372,13 +372,13 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->service->expects($this->once())
->method('createStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
if ($expectSuccess) {
$this->service->expects($this->once())
->method('addStorage')
->with($storageConfig)
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
} else {
$this->service->expects($this->never())
->method('addStorage');
@@ -388,7 +388,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
'mount',
'\OCA\Files_External\Lib\Storage\SMB',
'\OCA\Files_External\Lib\Auth\NullMechanism',
- array(),
+ [],
[],
[],
[],
diff --git a/apps/files_external/tests/Controller/UserStoragesControllerTest.php b/apps/files_external/tests/Controller/UserStoragesControllerTest.php
index 920bb72ab70..5f82121cf7a 100644
--- a/apps/files_external/tests/Controller/UserStoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/UserStoragesControllerTest.php
@@ -76,7 +76,7 @@ class UserStoragesControllerTest extends StoragesControllerTest {
$this->service->expects($this->exactly(2))
->method('createStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$this->service->expects($this->never())
->method('addStorage');
$this->service->expects($this->never())
@@ -86,7 +86,7 @@ class UserStoragesControllerTest extends StoragesControllerTest {
'mount',
'\OCA\Files_External\Lib\Storage\SMB',
'\Auth\Mechanism',
- array(),
+ [],
[],
[],
[],
@@ -100,7 +100,7 @@ class UserStoragesControllerTest extends StoragesControllerTest {
'mount',
'\OCA\Files_External\Lib\Storage\SMB',
'\Auth\Mechanism',
- array(),
+ [],
[],
[],
[],
diff --git a/apps/files_external/tests/FrontendDefinitionTraitTest.php b/apps/files_external/tests/FrontendDefinitionTraitTest.php
index 76a8ab326f0..e6a62991f36 100644
--- a/apps/files_external/tests/FrontendDefinitionTraitTest.php
+++ b/apps/files_external/tests/FrontendDefinitionTraitTest.php
@@ -101,10 +101,10 @@ class FrontendDefinitionTraitTest extends \Test\TestCase {
->willReturn('param');
$param->expects($this->once())
->method('validateValue')
- ->will($this->returnCallback(function(&$value) {
+ ->willReturnCallback(function(&$value) {
$value = 'foobar';
return true;
- }));
+ });
$storageConfig = $this->getMockBuilder(StorageConfig::class)
->disableOriginalConstructor()
diff --git a/apps/files_external/tests/OwnCloudFunctionsTest.php b/apps/files_external/tests/OwnCloudFunctionsTest.php
index d87288edb10..060f8c61a44 100644
--- a/apps/files_external/tests/OwnCloudFunctionsTest.php
+++ b/apps/files_external/tests/OwnCloudFunctionsTest.php
@@ -36,72 +36,72 @@ namespace OCA\Files_External\Tests;
class OwnCloudFunctionsTest extends \Test\TestCase {
function configUrlProvider() {
- return array(
- array(
- array(
+ return [
+ [
+ [
'host' => 'testhost',
'root' => 'testroot',
'secure' => false
- ),
+ ],
'http://testhost/remote.php/webdav/testroot/',
- ),
- array(
- array(
+ ],
+ [
+ [
'host' => 'testhost',
'root' => 'testroot',
'secure' => true
- ),
+ ],
'https://testhost/remote.php/webdav/testroot/',
- ),
- array(
- array(
+ ],
+ [
+ [
'host' => 'http://testhost',
'root' => 'testroot',
'secure' => false
- ),
+ ],
'http://testhost/remote.php/webdav/testroot/',
- ),
- array(
- array(
+ ],
+ [
+ [
'host' => 'https://testhost',
'root' => 'testroot',
'secure' => false
- ),
+ ],
'https://testhost/remote.php/webdav/testroot/',
- ),
- array(
- array(
+ ],
+ [
+ [
'host' => 'https://testhost/testroot',
'root' => '',
'secure' => false
- ),
+ ],
'https://testhost/testroot/remote.php/webdav/',
- ),
- array(
- array(
+ ],
+ [
+ [
'host' => 'https://testhost/testroot',
'root' => 'subdir',
'secure' => false
- ),
+ ],
'https://testhost/testroot/remote.php/webdav/subdir/',
- ),
- array(
- array(
+ ],
+ [
+ [
'host' => 'http://testhost/testroot',
'root' => 'subdir',
'secure' => true
- ),
+ ],
'http://testhost/testroot/remote.php/webdav/subdir/',
- ),
- array(
- array(
+ ],
+ [
+ [
'host' => 'http://testhost/testroot/',
'root' => '/subdir',
'secure' => false
- ),
+ ],
'http://testhost/testroot/remote.php/webdav/subdir/',
- ),
- );
+ ],
+ ];
}
/**
diff --git a/apps/files_external/tests/PersonalMountTest.php b/apps/files_external/tests/PersonalMountTest.php
index 09862257ecb..621894138f4 100644
--- a/apps/files_external/tests/PersonalMountTest.php
+++ b/apps/files_external/tests/PersonalMountTest.php
@@ -40,7 +40,7 @@ class PersonalMountTest extends TestCase {
$storage->expects($this->any())
->method('getId')
- ->will($this->returnValue('dummy'));
+ ->willReturn('dummy');
$mount = new PersonalMount($storageService, 10, $storage, '/foo');
diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php
index bb65d9a6de6..2191060444a 100644
--- a/apps/files_external/tests/Service/BackendServiceTest.php
+++ b/apps/files_external/tests/Service/BackendServiceTest.php
@@ -51,8 +51,8 @@ class BackendServiceTest extends \Test\TestCase {
$backend = $this->getMockBuilder(Backend::class)
->disableOriginalConstructor()
->getMock();
- $backend->method('getIdentifier')->will($this->returnValue('identifier:'.$class));
- $backend->method('getIdentifierAliases')->will($this->returnValue(['identifier:'.$class]));
+ $backend->method('getIdentifier')->willReturn('identifier:'.$class);
+ $backend->method('getIdentifierAliases')->willReturn(['identifier:'.$class]);
return $backend;
}
@@ -65,8 +65,8 @@ class BackendServiceTest extends \Test\TestCase {
$backend = $this->getMockBuilder(AuthMechanism::class)
->disableOriginalConstructor()
->getMock();
- $backend->method('getIdentifier')->will($this->returnValue('identifier:'.$class));
- $backend->method('getIdentifierAliases')->will($this->returnValue(['identifier:'.$class]));
+ $backend->method('getIdentifier')->willReturn('identifier:'.$class);
+ $backend->method('getIdentifierAliases')->willReturn(['identifier:'.$class]);
return $backend;
}
@@ -167,10 +167,10 @@ class BackendServiceTest extends \Test\TestCase {
public function testUserMountingBackends() {
$this->config->expects($this->exactly(2))
->method('getAppValue')
- ->will($this->returnValueMap([
+ ->willReturnMap([
['files_external', 'allow_user_mounting', 'yes', 'yes'],
['files_external', 'user_mounting_backends', '', 'identifier:\User\Mount\Allowed,identifier_alias']
- ]));
+ ]);
$service = new BackendService($this->config);
@@ -201,15 +201,15 @@ class BackendServiceTest extends \Test\TestCase {
$backendAvailable = $this->getBackendMock('\Backend\Available');
$backendAvailable->expects($this->once())
->method('checkDependencies')
- ->will($this->returnValue([]));
+ ->willReturn([]);
$backendNotAvailable = $this->getBackendMock('\Backend\NotAvailable');
$backendNotAvailable->expects($this->once())
->method('checkDependencies')
- ->will($this->returnValue([
+ ->willReturn([
$this->getMockBuilder('\OCA\Files_External\Lib\MissingDependency')
->disableOriginalConstructor()
->getMock()
- ]));
+ ]);
$service->registerBackend($backendAvailable);
$service->registerBackend($backendNotAvailable);
diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php
index a598739b97e..dd35ee8f92c 100644
--- a/apps/files_external/tests/Service/StoragesServiceTest.php
+++ b/apps/files_external/tests/Service/StoragesServiceTest.php
@@ -95,7 +95,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();
$this->dbConfig = new CleaningDBConfig(\OC::$server->getDatabaseConnection(), \OC::$server->getCrypto());
- self::$hookCalls = array();
+ self::$hookCalls = [];
$config = \OC::$server->getConfig();
$this->dataDir = $config->getSystemValue(
'datadirectory',
@@ -117,20 +117,20 @@ abstract class StoragesServiceTest extends \Test\TestCase {
'identifier:\OCA\Files_External\Lib\Auth\NullMechanism' => $this->getAuthMechMock(),
];
$this->backendService->method('getAuthMechanism')
- ->will($this->returnCallback(function ($class) use ($authMechanisms) {
+ ->willReturnCallback(function ($class) use ($authMechanisms) {
if (isset($authMechanisms[$class])) {
return $authMechanisms[$class];
}
return null;
- }));
+ });
$this->backendService->method('getAuthMechanismsByScheme')
- ->will($this->returnCallback(function ($schemes) use ($authMechanisms) {
+ ->willReturnCallback(function ($schemes) use ($authMechanisms) {
return array_filter($authMechanisms, function ($authMech) use ($schemes) {
return in_array($authMech->getScheme(), $schemes, true);
});
- }));
+ });
$this->backendService->method('getAuthMechanisms')
- ->will($this->returnValue($authMechanisms));
+ ->willReturn($authMechanisms);
$sftpBackend = $this->getBackendMock('\OCA\Files_External\Lib\Backend\SFTP', '\OCA\Files_External\Lib\Storage\SFTP');
$backends = [
@@ -142,14 +142,14 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$backends['identifier:\OCA\Files_External\Lib\Backend\SFTP']->method('getLegacyAuthMechanism')
->willReturn($authMechanisms['identifier:\Other\Auth\Mechanism']);
$this->backendService->method('getBackend')
- ->will($this->returnCallback(function ($backendClass) use ($backends) {
+ ->willReturnCallback(function ($backendClass) use ($backends) {
if (isset($backends[$backendClass])) {
return $backends[$backendClass];
}
return null;
- }));
+ });
$this->backendService->method('getBackends')
- ->will($this->returnValue($backends));
+ ->willReturn($backends);
\OCP\Util::connectHook(
Filesystem::CLASSNAME,
@@ -162,11 +162,11 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$containerMock = $this->createMock(IAppContainer::class);
$containerMock->method('query')
- ->will($this->returnCallback(function ($name) {
+ ->willReturnCallback(function ($name) {
if ($name === 'OCA\Files_External\Service\BackendService') {
return $this->backendService;
}
- }));
+ });
\OC_Mount_Config::$app = $this->getMockBuilder('\OCA\Files_External\Appinfo\Application')
->disableOriginalConstructor()
@@ -177,7 +177,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
protected function tearDown(): void {
\OC_Mount_Config::$skipTest = false;
- self::$hookCalls = array();
+ self::$hookCalls = [];
if ($this->dbConfig) {
$this->dbConfig->clean();
}
@@ -448,17 +448,17 @@ abstract class StoragesServiceTest extends \Test\TestCase {
}
public static function createHookCallback($params) {
- self::$hookCalls[] = array(
+ self::$hookCalls[] = [
'signal' => Filesystem::signal_create_mount,
'params' => $params
- );
+ ];
}
public static function deleteHookCallback($params) {
- self::$hookCalls[] = array(
+ self::$hookCalls[] = [
'signal' => Filesystem::signal_delete_mount,
'params' => $params
- );
+ ];
}
/**
diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
index ef8dc8a250e..ebdc2e01d52 100644
--- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
@@ -71,11 +71,11 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
$userSession
->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->groupManager->method('isInGroup')
- ->will($this->returnCallback(function ($userId, $groupId) {
+ ->willReturnCallback(function ($userId, $groupId) {
if ($userId === self::USER_ID) {
switch ($groupId) {
case self::GROUP_ID:
@@ -84,15 +84,15 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
}
}
return false;
- }));
+ });
$this->groupManager->method('getUserGroupIds')
- ->will($this->returnCallback(function (IUser $user) {
+ ->willReturnCallback(function (IUser $user) {
if ($user->getUID() === self::USER_ID) {
return [self::GROUP_ID, self::GROUP_ID2];
} else {
return [];
}
- }));
+ });
$this->service = new UserGlobalStoragesService(
$this->backendService,
diff --git a/apps/files_external/tests/Service/UserStoragesServiceTest.php b/apps/files_external/tests/Service/UserStoragesServiceTest.php
index 62f9f6b9d6c..cc000c28a80 100644
--- a/apps/files_external/tests/Service/UserStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/UserStoragesServiceTest.php
@@ -64,7 +64,7 @@ class UserStoragesServiceTest extends StoragesServiceTest {
$userSession
->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$this->service = new UserStoragesService($this->backendService, $this->dbConfig, $userSession, $this->mountCache);
}
diff --git a/apps/files_external/tests/Storage/FtpTest.php b/apps/files_external/tests/Storage/FtpTest.php
index 65a1566ec1e..6b9ce2d5b31 100644
--- a/apps/files_external/tests/Storage/FtpTest.php
+++ b/apps/files_external/tests/Storage/FtpTest.php
@@ -63,11 +63,11 @@ class FtpTest extends \Test\Files\Storage\Storage {
}
public function testConstructUrl(){
- $config = array ( 'host' => 'localhost',
+ $config = [ 'host' => 'localhost',
'user' => 'ftp',
'password' => 'ftp',
'root' => '/',
- 'secure' => false );
+ 'secure' => false ];
$instance = new FTP($config);
$this->assertEquals('ftp://ftp:ftp@localhost/', $instance->constructUrl(''));
diff --git a/apps/files_external/tests/Storage/SmbTest.php b/apps/files_external/tests/Storage/SmbTest.php
index 2af9d00ebe9..87a5668be49 100644
--- a/apps/files_external/tests/Storage/SmbTest.php
+++ b/apps/files_external/tests/Storage/SmbTest.php
@@ -73,7 +73,7 @@ class SmbTest extends \Test\Files\Storage\Storage {
public function directoryProvider() {
// doesn't support leading/trailing spaces
- return array(array('folder'));
+ return [['folder']];
}
public function testRenameWithSpaces() {
diff --git a/apps/files_external/tests/config.php b/apps/files_external/tests/config.php
index a080b33e7fe..d6d3731c5a5 100644
--- a/apps/files_external/tests/config.php
+++ b/apps/files_external/tests/config.php
@@ -33,15 +33,15 @@ if (file_exists($privateConfigFile)) {
}
// this is now more a template now for your private configurations
-return array(
- 'ftp'=>array(
+return [
+ 'ftp'=>[
'run'=>false,
'host'=>'localhost',
'user'=>'test',
'password'=>'test',
'root'=>'/test',
- ),
- 'webdav'=>array(
+ ],
+ 'webdav'=>[
'run'=>false,
'host'=>'localhost',
'user'=>'test',
@@ -51,15 +51,15 @@ return array(
// (only in tests)
// set to higher value for lighttpd webdav
'wait'=> 0
- ),
- 'owncloud'=>array(
+ ],
+ 'owncloud'=>[
'run'=>false,
'host'=>'localhost/owncloud',
'user'=>'test',
'password'=>'test',
'root'=>'',
- ),
- 'swift' => array(
+ ],
+ 'swift' => [
'run' => false,
'user' => 'test',
'bucket' => 'test',
@@ -70,16 +70,16 @@ return array(
//'service_name' => 'swift', //should be 'swift' for OpenStack Object Storage and 'cloudFiles' for Rackspace Cloud Files (default value)
//'url' => 'https://identity.api.rackspacecloud.com/v2.0/', //to be used with Rackspace Cloud Files and OpenStack Object Storage
//'timeout' => 5 // timeout of HTTP requests in seconds
- ),
- 'smb'=>array(
+ ],
+ 'smb'=>[
'run'=>false,
'user'=>'test',
'password'=>'test',
'host'=>'localhost',
'share'=>'/test',
'root'=>'/test/',
- ),
- 'amazons3'=>array(
+ ],
+ 'amazons3'=>[
'run'=>false,
'key'=>'test',
'secret'=>'test',
@@ -90,20 +90,20 @@ return array(
//'region' => 'eu-west-1',
//'test'=>'true',
//'timeout'=>20
- ),
- 'sftp' => array (
+ ],
+ 'sftp' => [
'run'=>false,
'host'=>'localhost',
'user'=>'test',
'password'=>'test',
'root'=>'/test'
- ),
- 'sftp_key' => array (
+ ],
+ 'sftp_key' => [
'run'=>false,
'host'=>'localhost',
'user'=>'test',
'public_key'=>'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDJPTvz3OLonF2KSGEKP/nd4CPmRYvemG2T4rIiNYjDj0U5y+2sKEWbjiUlQl2bsqYuVoJ+/UNJlGQbbZ08kQirFeo1GoWBzqioaTjUJfbLN6TzVVKXxR9YIVmH7Ajg2iEeGCndGgbmnPfj+kF9TR9IH8vMVvtubQwf7uEwB0ALhw== phpseclib-generated-key',
'private_key'=>'test',
'root'=>'/test'
- ),
-);
+ ],
+];