summaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-06-26 12:55:05 +0200
committerLukas Reschke <lukas@owncloud.com>2016-06-26 12:55:05 +0200
commit7a9d60d87eb8e4414e5fe05830b088d426ff810d (patch)
tree0fc97a7eacfd071475afd8bc6d4372babacb5740 /apps/files_external
parent5387b942c44e05b87ba2a0fd54168f5278a31344 (diff)
parent52eab2a61a5d27b64fcd0440b91f854c052933a9 (diff)
downloadnextcloud-server-7a9d60d87eb8e4414e5fe05830b088d426ff810d.tar.gz
nextcloud-server-7a9d60d87eb8e4414e5fe05830b088d426ff810d.zip
Merge remote-tracking branch 'upstream/master' into master-upstream-sync
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/l10n/lb.js1
-rw-r--r--apps/files_external/l10n/lb.json1
-rw-r--r--apps/files_external/l10n/sv.js1
-rw-r--r--apps/files_external/l10n/sv.json1
-rw-r--r--apps/files_external/lib/Command/Export.php6
-rw-r--r--apps/files_external/lib/Command/ListCommand.php48
-rw-r--r--apps/files_external/lib/Service/DBConfigService.php12
-rw-r--r--apps/files_external/lib/Service/GlobalStoragesService.php19
-rw-r--r--apps/files_external/tests/Service/DBConfigServiceTest.php10
-rwxr-xr-xapps/files_external/tests/env/start-swift-ceph.sh5
10 files changed, 93 insertions, 11 deletions
diff --git a/apps/files_external/l10n/lb.js b/apps/files_external/l10n/lb.js
index 598458c731f..50bb06ff7f9 100644
--- a/apps/files_external/l10n/lb.js
+++ b/apps/files_external/l10n/lb.js
@@ -6,6 +6,7 @@ OC.L10N.register(
"Username" : "Benotzernumm",
"Password" : "Passwuert",
"Save" : "Späicheren",
+ "None" : "Keng",
"Port" : "Port",
"Region" : "Regioun",
"URL" : "URL",
diff --git a/apps/files_external/l10n/lb.json b/apps/files_external/l10n/lb.json
index 265d8ffda96..9f7aa84bb1a 100644
--- a/apps/files_external/l10n/lb.json
+++ b/apps/files_external/l10n/lb.json
@@ -4,6 +4,7 @@
"Username" : "Benotzernumm",
"Password" : "Passwuert",
"Save" : "Späicheren",
+ "None" : "Keng",
"Port" : "Port",
"Region" : "Regioun",
"URL" : "URL",
diff --git a/apps/files_external/l10n/sv.js b/apps/files_external/l10n/sv.js
index dfa978f202a..3df7763a5fe 100644
--- a/apps/files_external/l10n/sv.js
+++ b/apps/files_external/l10n/sv.js
@@ -1,6 +1,7 @@
OC.L10N.register(
"files_external",
{
+ "Fetching request tokens failed. Verify that your app key and secret are correct." : "Fel vid hämtning av åtkomst-token. Verifiera att din app-nyckel och hemlighet stämmer.",
"Step 1 failed. Exception: %s" : "Steg 1 flaerade. Undantag: %s",
"Step 2 failed. Exception: %s" : "Steg 2 falerade. Undantag: %s",
"External storage" : "Extern lagring",
diff --git a/apps/files_external/l10n/sv.json b/apps/files_external/l10n/sv.json
index 528588bd702..1070a322e92 100644
--- a/apps/files_external/l10n/sv.json
+++ b/apps/files_external/l10n/sv.json
@@ -1,4 +1,5 @@
{ "translations": {
+ "Fetching request tokens failed. Verify that your app key and secret are correct." : "Fel vid hämtning av åtkomst-token. Verifiera att din app-nyckel och hemlighet stämmer.",
"Step 1 failed. Exception: %s" : "Steg 1 flaerade. Undantag: %s",
"Step 2 failed. Exception: %s" : "Steg 2 falerade. Undantag: %s",
"External storage" : "Extern lagring",
diff --git a/apps/files_external/lib/Command/Export.php b/apps/files_external/lib/Command/Export.php
index 09c5ea8a9df..89655c1efc7 100644
--- a/apps/files_external/lib/Command/Export.php
+++ b/apps/files_external/lib/Command/Export.php
@@ -41,6 +41,11 @@ class Export extends ListCommand {
'user_id',
InputArgument::OPTIONAL,
'user id to export the personal mounts for, if no user is provided admin mounts will be exported'
+ )->addOption(
+ 'all',
+ 'a',
+ InputOption::VALUE_NONE,
+ 'show both system wide mounts and all personal mounts'
);
}
@@ -48,6 +53,7 @@ class Export extends ListCommand {
$listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
$listInput = new ArrayInput([], $listCommand->getDefinition());
$listInput->setArgument('user_id', $input->getArgument('user_id'));
+ $listInput->setOption('all', $input->getOption('all'));
$listInput->setOption('output', 'json_pretty');
$listInput->setOption('show-password', true);
$listInput->setOption('full', true);
diff --git a/apps/files_external/lib/Command/ListCommand.php b/apps/files_external/lib/Command/ListCommand.php
index 26133ea5ed5..e29a5f58f40 100644
--- a/apps/files_external/lib/Command/ListCommand.php
+++ b/apps/files_external/lib/Command/ListCommand.php
@@ -56,6 +56,8 @@ class ListCommand extends Base {
*/
protected $userManager;
+ const ALL = -1;
+
function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) {
parent::__construct();
$this->globalService = $globalService;
@@ -67,7 +69,7 @@ class ListCommand extends Base {
protected function configure() {
$this
->setName('files_external:list')
- ->setDescription('List configured mounts')
+ ->setDescription('List configured admin or personal mounts')
->addArgument(
'user_id',
InputArgument::OPTIONAL,
@@ -82,16 +84,27 @@ class ListCommand extends Base {
null,
InputOption::VALUE_NONE,
'don\'t truncate long values in table output'
+ )->addOption(
+ 'all',
+ 'a',
+ InputOption::VALUE_NONE,
+ 'show both system wide mounts and all personal mounts'
);
parent::configure();
}
protected function execute(InputInterface $input, OutputInterface $output) {
- $userId = $input->getArgument('user_id');
- $storageService = $this->getStorageService($userId);
+ if ($input->getOption('all')) {
+ /** @var $mounts StorageConfig[] */
+ $mounts = $this->globalService->getStorageForAllUsers();
+ $userId = self::ALL;
+ } else {
+ $userId = $input->getArgument('user_id');
+ $storageService = $this->getStorageService($userId);
- /** @var $mounts StorageConfig[] */
- $mounts = $storageService->getAllStorages();
+ /** @var $mounts StorageConfig[] */
+ $mounts = $storageService->getAllStorages();
+ }
$this->listMounts($userId, $mounts, $input, $output);
}
@@ -102,13 +115,15 @@ class ListCommand extends Base {
* @param InputInterface $input
* @param OutputInterface $output
*/
- public function listMounts($userId, array $mounts, InputInterface $input, OutputInterface $output){
+ public function listMounts($userId, array $mounts, InputInterface $input, OutputInterface $output) {
$outputType = $input->getOption('output');
if (count($mounts) === 0) {
if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) {
$output->writeln('[]');
} else {
- if ($userId) {
+ if ($userId === self::ALL) {
+ $output->writeln("<info>No mounts configured</info>");
+ } else if ($userId) {
$output->writeln("<info>No mounts configured by $userId</info>");
} else {
$output->writeln("<info>No admin mounts configured</info>");
@@ -119,10 +134,13 @@ class ListCommand extends Base {
$headers = ['Mount ID', 'Mount Point', 'Storage', 'Authentication Type', 'Configuration', 'Options'];
- if (!$userId) {
+ if (!$userId || $userId === self::ALL) {
$headers[] = 'Applicable Users';
$headers[] = 'Applicable Groups';
}
+ if ($userId === self::ALL) {
+ $headers[] = 'Type';
+ }
if (!$input->getOption('show-password')) {
$hideKeys = ['password', 'refresh_token', 'token', 'client_secret', 'public_key', 'private_key'];
@@ -150,10 +168,13 @@ class ListCommand extends Base {
$config->getBackendOptions(),
$config->getMountOptions()
];
- if (!$userId) {
+ if (!$userId || $userId === self::ALL) {
$values[] = $config->getApplicableUsers();
$values[] = $config->getApplicableGroups();
}
+ if ($userId === self::ALL) {
+ $values[] = $config->getType() === StorageConfig::MOUNT_TYPE_ADMIN ? 'admin' : 'personal';
+ }
return array_combine($keys, $values);
}, $mounts);
@@ -167,7 +188,9 @@ class ListCommand extends Base {
$defaultMountOptions = [
'encrypt' => true,
'previews' => true,
- 'filesystem_check_changes' => 1
+ 'filesystem_check_changes' => 1,
+ 'enable_sharing' => false,
+ 'encoding_compatibility' => false
];
$rows = array_map(function (StorageConfig $config) use ($userId, $defaultMountOptions, $full) {
$storageConfig = $config->getBackendOptions();
@@ -213,7 +236,7 @@ class ListCommand extends Base {
$optionsString
];
- if (!$userId) {
+ if (!$userId || $userId === self::ALL) {
$applicableUsers = implode(', ', $config->getApplicableUsers());
$applicableGroups = implode(', ', $config->getApplicableGroups());
if ($applicableUsers === '' && $applicableGroups === '') {
@@ -222,6 +245,9 @@ class ListCommand extends Base {
$values[] = $applicableUsers;
$values[] = $applicableGroups;
}
+ if ($userId === self::ALL) {
+ $values[] = $config->getType() === StorageConfig::MOUNT_TYPE_ADMIN ? 'Admin' : 'Personal';
+ }
return $values;
}, $mounts);
diff --git a/apps/files_external/lib/Service/DBConfigService.php b/apps/files_external/lib/Service/DBConfigService.php
index 9f7061eb938..3e38f4aed94 100644
--- a/apps/files_external/lib/Service/DBConfigService.php
+++ b/apps/files_external/lib/Service/DBConfigService.php
@@ -77,6 +77,18 @@ class DBConfigService {
}
/**
+ * Get all configured mounts
+ *
+ * @return array
+ */
+ public function getAllMounts() {
+ $builder = $this->connection->getQueryBuilder();
+ $query = $builder->select(['mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'type'])
+ ->from('external_mounts');
+ return $this->getMountsFromQuery($query);
+ }
+
+ /**
* Get admin defined mounts
*
* @return array
diff --git a/apps/files_external/lib/Service/GlobalStoragesService.php b/apps/files_external/lib/Service/GlobalStoragesService.php
index 96d7aa46e8d..39d3da5d803 100644
--- a/apps/files_external/lib/Service/GlobalStoragesService.php
+++ b/apps/files_external/lib/Service/GlobalStoragesService.php
@@ -162,4 +162,23 @@ class GlobalStoragesService extends StoragesService {
protected function isApplicable(StorageConfig $config) {
return true;
}
+
+ /**
+ * Get all configured admin and personal mounts
+ *
+ * @return array map of storage id to storage config
+ */
+ public function getStorageForAllUsers() {
+ $mounts = $this->dbConfig->getAllMounts();
+ $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts);
+ $configs = array_filter($configs, function ($config) {
+ return $config instanceof StorageConfig;
+ });
+
+ $keys = array_map(function (StorageConfig $config) {
+ return $config->getId();
+ }, $configs);
+
+ return array_combine($keys, $configs);
+ }
}
diff --git a/apps/files_external/tests/Service/DBConfigServiceTest.php b/apps/files_external/tests/Service/DBConfigServiceTest.php
index b088a7078d1..3cfa33f0bc8 100644
--- a/apps/files_external/tests/Service/DBConfigServiceTest.php
+++ b/apps/files_external/tests/Service/DBConfigServiceTest.php
@@ -282,4 +282,14 @@ class DBConfigServiceTest extends TestCase {
$this->assertCount(1, $mounts);
$this->assertEquals($id1, $mounts[0]['mount_id']);
}
+
+ public function testGetAllMounts() {
+ $id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
+ $id2 = $this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_PERSONAl);
+
+ $mounts = $this->dbConfig->getAllMounts();
+ $this->assertCount(2, $mounts);
+ $this->assertEquals($id1, $mounts[0]['mount_id']);
+ $this->assertEquals($id2, $mounts[1]['mount_id']);
+ }
}
diff --git a/apps/files_external/tests/env/start-swift-ceph.sh b/apps/files_external/tests/env/start-swift-ceph.sh
index ba17b8f42dd..b73fa899a6d 100755
--- a/apps/files_external/tests/env/start-swift-ceph.sh
+++ b/apps/files_external/tests/env/start-swift-ceph.sh
@@ -74,6 +74,11 @@ if [[ $ready != 'READY=1' ]]; then
docker logs $container
exit 1
fi
+if ! "$thisFolder"/env/wait-for-connection ${host} 80 600; then
+ echo "[ERROR] Waited 600 seconds, no response" >&2
+ docker logs $container
+ exit 1
+fi
echo "Waiting another 15 seconds"
sleep 15