summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/encryption/lib/migration.php6
-rw-r--r--apps/encryption/tests/lib/MigrationTest.php34
-rw-r--r--apps/files/appinfo/application.php9
-rw-r--r--apps/files/appinfo/routes.php9
-rw-r--r--apps/files/lib/activity.php51
-rw-r--r--apps/files/lib/capabilities.php37
-rw-r--r--apps/files/tests/activitytest.php45
-rw-r--r--apps/files_external/appinfo/application.php2
-rw-r--r--apps/files_external/appinfo/routes.php2
-rw-r--r--apps/files_sharing/appinfo/application.php9
-rw-r--r--apps/files_sharing/appinfo/routes.php5
-rw-r--r--apps/files_sharing/lib/activity.php2
-rw-r--r--apps/files_sharing/lib/capabilities.php32
-rw-r--r--apps/files_sharing/tests/capabilities.php7
-rw-r--r--apps/files_trashbin/appinfo/application.php37
-rw-r--r--apps/files_trashbin/appinfo/routes.php11
-rw-r--r--apps/files_trashbin/command/cleanup.php2
-rw-r--r--apps/files_trashbin/lib/capabilities.php22
-rw-r--r--apps/files_trashbin/tests/command/cleanuptest.php2
-rw-r--r--apps/files_versions/appinfo/application.php37
-rw-r--r--apps/files_versions/appinfo/routes.php8
-rw-r--r--apps/files_versions/lib/capabilities.php25
-rw-r--r--config/config.sample.php8
-rw-r--r--core/js/setupchecks.js10
-rw-r--r--core/js/tests/specs/setupchecksSpec.js81
-rw-r--r--lib/private/activitymanager.php196
-rw-r--r--lib/private/app.php10
-rw-r--r--lib/private/appframework/dependencyinjection/dicontainer.php15
-rw-r--r--lib/private/appframework/http/request.php5
-rw-r--r--lib/private/appframework/utility/simplecontainer.php2
-rw-r--r--lib/private/capabilitiesmanager.php64
-rw-r--r--lib/private/db/querybuilder/querybuilder.php42
-rw-r--r--lib/private/files/view.php9
-rw-r--r--lib/private/installer.php4
-rw-r--r--lib/private/ocs/cloud.php9
-rw-r--r--lib/private/ocs/corecapabilities.php56
-rw-r--r--lib/private/route/router.php6
-rw-r--r--lib/private/server.php18
-rw-r--r--lib/private/share/share.php4
-rw-r--r--lib/public/activity/iextension.php9
-rw-r--r--lib/public/activity/imanager.php8
-rw-r--r--lib/public/appframework/http/contentsecuritypolicy.php1
-rw-r--r--lib/public/appframework/iappcontainer.php7
-rw-r--r--lib/public/capabilities/icapability.php46
-rw-r--r--lib/public/db/querybuilder/iquerybuilder.php9
-rw-r--r--lib/public/iservercontainer.php1
-rw-r--r--lib/repair/cleantags.php12
-rw-r--r--lib/repair/filletags.php2
-rw-r--r--settings/controller/checksetupcontroller.php39
-rw-r--r--tests/lib/activitymanager.php43
-rw-r--r--tests/lib/appframework/controller/ControllerTest.php2
-rw-r--r--tests/lib/appframework/http/ContentSecurityPolicyTest.php106
-rw-r--r--tests/lib/appframework/http/DataResponseTest.php2
-rw-r--r--tests/lib/appframework/http/ResponseTest.php2
-rw-r--r--tests/lib/appframework/routing/RoutingTest.php30
-rw-r--r--tests/lib/appframework/utility/SimpleContainerTest.php31
-rw-r--r--tests/lib/capabilitiesmanager.php164
-rw-r--r--tests/lib/db/querybuilder/querybuildertest.php98
-rw-r--r--tests/lib/files/view.php4
-rw-r--r--tests/lib/repair/cleantags.php34
-rw-r--r--tests/lib/server.php4
-rw-r--r--tests/lib/share/share.php4
-rw-r--r--tests/settings/controller/CheckSetupControllerTest.php92
63 files changed, 1301 insertions, 382 deletions
diff --git a/apps/encryption/lib/migration.php b/apps/encryption/lib/migration.php
index d22c571fd40..5396a7db627 100644
--- a/apps/encryption/lib/migration.php
+++ b/apps/encryption/lib/migration.php
@@ -72,7 +72,7 @@ class Migration {
// only update during the first run
if ($this->installedVersion !== '-1') {
$query = $this->connection->getQueryBuilder();
- $query->update('*PREFIX*filecache')
+ $query->update('filecache')
->set('size', 'unencrypted_size')
->where($query->expr()->eq('encrypted', $query->createParameter('encrypted')))
->setParameter('encrypted', 1);
@@ -163,7 +163,7 @@ class Migration {
$oldAppValues = $this->connection->getQueryBuilder();
$oldAppValues->select('*')
- ->from('*PREFIX*appconfig')
+ ->from('appconfig')
->where($oldAppValues->expr()->eq('appid', $oldAppValues->createParameter('appid')))
->setParameter('appid', 'files_encryption');
$appSettings = $oldAppValues->execute();
@@ -178,7 +178,7 @@ class Migration {
$oldPreferences = $this->connection->getQueryBuilder();
$oldPreferences->select('*')
- ->from('*PREFIX*preferences')
+ ->from('preferences')
->where($oldPreferences->expr()->eq('appid', $oldPreferences->createParameter('appid')))
->setParameter('appid', 'files_encryption');
$preferenceSettings = $oldPreferences->execute();
diff --git a/apps/encryption/tests/lib/MigrationTest.php b/apps/encryption/tests/lib/MigrationTest.php
index 5bc3b89b5b9..bb1f0a310a2 100644
--- a/apps/encryption/tests/lib/MigrationTest.php
+++ b/apps/encryption/tests/lib/MigrationTest.php
@@ -291,12 +291,12 @@ class MigrationTest extends \Test\TestCase {
/** @var \OCP\IDBConnection $connection */
$connection = \OC::$server->getDatabaseConnection();
$query = $connection->getQueryBuilder();
- $query->delete('*PREFIX*appconfig')
+ $query->delete('appconfig')
->where($query->expr()->eq('appid', $query->createParameter('appid')))
->setParameter('appid', 'encryption');
$query->execute();
$query = $connection->getQueryBuilder();
- $query->delete('*PREFIX*preferences')
+ $query->delete('preferences')
->where($query->expr()->eq('appid', $query->createParameter('appid')))
->setParameter('appid', 'encryption');
$query->execute();
@@ -309,10 +309,10 @@ class MigrationTest extends \Test\TestCase {
$this->invokePrivate($m, 'installedVersion', ['0.7']);
$m->updateDB();
- $this->verifyDB('*PREFIX*appconfig', 'files_encryption', 0);
- $this->verifyDB('*PREFIX*preferences', 'files_encryption', 0);
- $this->verifyDB('*PREFIX*appconfig', 'encryption', 3);
- $this->verifyDB('*PREFIX*preferences', 'encryption', 1);
+ $this->verifyDB('appconfig', 'files_encryption', 0);
+ $this->verifyDB('preferences', 'files_encryption', 0);
+ $this->verifyDB('appconfig', 'encryption', 3);
+ $this->verifyDB('preferences', 'encryption', 1);
}
@@ -329,17 +329,17 @@ class MigrationTest extends \Test\TestCase {
$this->invokePrivate($m, 'installedVersion', ['0.7']);
$m->updateDB();
- $this->verifyDB('*PREFIX*appconfig', 'files_encryption', 0);
- $this->verifyDB('*PREFIX*preferences', 'files_encryption', 0);
- $this->verifyDB('*PREFIX*appconfig', 'encryption', 3);
- $this->verifyDB('*PREFIX*preferences', 'encryption', 1);
+ $this->verifyDB('appconfig', 'files_encryption', 0);
+ $this->verifyDB('preferences', 'files_encryption', 0);
+ $this->verifyDB('appconfig', 'encryption', 3);
+ $this->verifyDB('preferences', 'encryption', 1);
// check if the existing values where overwritten correctly
/** @var \OC\DB\Connection $connection */
$connection = \OC::$server->getDatabaseConnection();
$query = $connection->getQueryBuilder();
$query->select('configvalue')
- ->from('*PREFIX*appconfig')
+ ->from('appconfig')
->where($query->expr()->andX(
$query->expr()->eq('appid', $query->createParameter('appid')),
$query->expr()->eq('configkey', $query->createParameter('configkey'))
@@ -353,7 +353,7 @@ class MigrationTest extends \Test\TestCase {
$query = $connection->getQueryBuilder();
$query->select('configvalue')
- ->from('*PREFIX*preferences')
+ ->from('preferences')
->where($query->expr()->andX(
$query->expr()->eq('appid', $query->createParameter('appid')),
$query->expr()->eq('configkey', $query->createParameter('configkey')),
@@ -399,7 +399,7 @@ class MigrationTest extends \Test\TestCase {
$connection = \OC::$server->getDatabaseConnection();
$query = $connection->getQueryBuilder();
$query->select('*')
- ->from('*PREFIX*filecache');
+ ->from('filecache');
$result = $query->execute();
$entries = $result->fetchAll();
foreach($entries as $entry) {
@@ -417,15 +417,15 @@ class MigrationTest extends \Test\TestCase {
/** @var \OCP\IDBConnection $connection */
$connection = \OC::$server->getDatabaseConnection();
$query = $connection->getQueryBuilder();
- $query->delete('*PREFIX*filecache');
+ $query->delete('filecache');
$query->execute();
$query = $connection->getQueryBuilder();
$result = $query->select('fileid')
- ->from('*PREFIX*filecache')
+ ->from('filecache')
->setMaxResults(1)->execute()->fetchAll();
$this->assertEmpty($result);
$query = $connection->getQueryBuilder();
- $query->insert('*PREFIX*filecache')
+ $query->insert('filecache')
->values(
array(
'storage' => $query->createParameter('storage'),
@@ -447,7 +447,7 @@ class MigrationTest extends \Test\TestCase {
}
$query = $connection->getQueryBuilder();
$result = $query->select('fileid')
- ->from('*PREFIX*filecache')
+ ->from('filecache')
->execute()->fetchAll();
$this->assertSame(19, count($result));
}
diff --git a/apps/files/appinfo/application.php b/apps/files/appinfo/application.php
index c8aaf375d96..6ba77e09556 100644
--- a/apps/files/appinfo/application.php
+++ b/apps/files/appinfo/application.php
@@ -1,6 +1,5 @@
<?php
/**
- * @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Tobias Kaminsky <tobias@kaminsky.me>
* @author Vincent Petry <pvince81@owncloud.com>
@@ -21,8 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
-namespace OCA\Files\Appinfo;
+namespace OCA\Files\AppInfo;
use OCA\Files\Controller\ApiController;
use OCP\AppFramework\App;
@@ -68,5 +66,10 @@ class Application extends App {
$homeFolder
);
});
+
+ /*
+ * Register capabilities
+ */
+ $container->registerCapability('OCA\Files\Capabilities');
}
}
diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php
index 5aa52f17a29..d1b8954d5ce 100644
--- a/apps/files/appinfo/routes.php
+++ b/apps/files/appinfo/routes.php
@@ -1,9 +1,9 @@
<?php
/**
* @author Bart Visscher <bartv@thisnet.nl>
- * @author Joas Schilling <nickvergessen@owncloud.com>
* @author Lukas Reschke <lukas@owncloud.com>
* @author Morris Jobke <hey@morrisjobke.de>
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Tobias Kaminsky <tobias@kaminsky.me>
* @author Tom Needham <tom@owncloud.com>
* @author Vincent Petry <pvince81@owncloud.com>
@@ -24,8 +24,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
-namespace OCA\Files\Appinfo;
+namespace OCA\Files\AppInfo;
$application = new Application();
$application->registerRoutes(
@@ -82,6 +81,4 @@ $this->create('files_ajax_upload', 'ajax/upload.php')
$this->create('download', 'download{file}')
->requirements(array('file' => '.*'))
->actionInclude('files/download.php');
-
-// Register with the capabilities API
-\OCP\API::register('get', '/cloud/capabilities', array('OCA\Files\Capabilities', 'getCapabilities'), 'files', \OCP\API::USER_AUTH);
+
diff --git a/apps/files/lib/activity.php b/apps/files/lib/activity.php
index fff49ea4ea5..bf80d0cfd7c 100644
--- a/apps/files/lib/activity.php
+++ b/apps/files/lib/activity.php
@@ -30,6 +30,7 @@ use OCP\IL10N;
use OCP\IURLGenerator;
class Activity implements IExtension {
+ const APP_FILES = 'files';
const FILTER_FILES = 'files';
const FILTER_FAVORITES = 'files_favorites';
@@ -78,7 +79,7 @@ class Activity implements IExtension {
* @return IL10N
*/
protected function getL10N($languageCode = null) {
- return $this->languageFactory->get('files', $languageCode);
+ return $this->languageFactory->get(self::APP_FILES, $languageCode);
}
/**
@@ -86,14 +87,21 @@ class Activity implements IExtension {
* If no additional types are to be added false is to be returned
*
* @param string $languageCode
- * @return array|false
+ * @return array|false Array "stringID of the type" => "translated string description for the setting"
+ * or Array "stringID of the type" => [
+ * 'desc' => "translated string description for the setting"
+ * 'methods' => [self::METHOD_*],
+ * ]
*/
public function getNotificationTypes($languageCode) {
$l = $this->getL10N($languageCode);
return [
self::TYPE_SHARE_CREATED => (string) $l->t('A new file or folder has been <strong>created</strong>'),
self::TYPE_SHARE_CHANGED => (string) $l->t('A file or folder has been <strong>changed</strong>'),
- self::TYPE_FAVORITES => (string) $l->t('Limit notifications about creation and changes to your <strong>favorite files</strong> <em>(Stream only)</em>'),
+ self::TYPE_FAVORITES => [
+ 'desc' => (string) $l->t('Limit notifications about creation and changes to your <strong>favorite files</strong> <em>(Stream only)</em>'),
+ 'methods' => [self::METHOD_STREAM],
+ ],
self::TYPE_SHARE_DELETED => (string) $l->t('A file or folder has been <strong>deleted</strong>'),
self::TYPE_SHARE_RESTORED => (string) $l->t('A file or folder has been <strong>restored</strong>'),
];
@@ -107,7 +115,7 @@ class Activity implements IExtension {
* @return array|false
*/
public function getDefaultTypes($method) {
- if ($method === 'stream') {
+ if ($method === self::METHOD_STREAM) {
$settings = array();
$settings[] = self::TYPE_SHARE_CREATED;
$settings[] = self::TYPE_SHARE_CHANGED;
@@ -132,29 +140,30 @@ class Activity implements IExtension {
* @return string|false
*/
public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode) {
- if ($app !== 'files') {
+ if ($app !== self::APP_FILES) {
return false;
}
+ $l = $this->getL10N($languageCode);
switch ($text) {
case 'created_self':
- return (string) $this->l->t('You created %1$s', $params);
+ return (string) $l->t('You created %1$s', $params);
case 'created_by':
- return (string) $this->l->t('%2$s created %1$s', $params);
+ return (string) $l->t('%2$s created %1$s', $params);
case 'created_public':
- return (string) $this->l->t('%1$s was created in a public folder', $params);
+ return (string) $l->t('%1$s was created in a public folder', $params);
case 'changed_self':
- return (string) $this->l->t('You changed %1$s', $params);
+ return (string) $l->t('You changed %1$s', $params);
case 'changed_by':
- return (string) $this->l->t('%2$s changed %1$s', $params);
+ return (string) $l->t('%2$s changed %1$s', $params);
case 'deleted_self':
- return (string) $this->l->t('You deleted %1$s', $params);
+ return (string) $l->t('You deleted %1$s', $params);
case 'deleted_by':
- return (string) $this->l->t('%2$s deleted %1$s', $params);
+ return (string) $l->t('%2$s deleted %1$s', $params);
case 'restored_self':
- return (string) $this->l->t('You restored %1$s', $params);
+ return (string) $l->t('You restored %1$s', $params);
case 'restored_by':
- return (string) $this->l->t('%2$s restored %1$s', $params);
+ return (string) $l->t('%2$s restored %1$s', $params);
default:
return false;
@@ -173,7 +182,7 @@ class Activity implements IExtension {
* @return array|false
*/
function getSpecialParameterList($app, $text) {
- if ($app === 'files') {
+ if ($app === self::APP_FILES) {
switch ($text) {
case 'created_self':
case 'created_by':
@@ -223,7 +232,7 @@ class Activity implements IExtension {
* @return integer|false
*/
public function getGroupParameter($activity) {
- if ($activity['app'] === 'files') {
+ if ($activity['app'] === self::APP_FILES) {
switch ($activity['subject']) {
case 'created_self':
case 'created_by':
@@ -309,7 +318,7 @@ class Activity implements IExtension {
$user = $this->activityManager->getCurrentUserId();
// Display actions from all files
if ($filter === self::FILTER_FILES) {
- return ['`app` = ?', ['files']];
+ return ['`app` = ?', [self::APP_FILES]];
}
if (!$user) {
@@ -323,7 +332,7 @@ class Activity implements IExtension {
$favorites = $this->helper->getFavoriteFilePaths($user);
} catch (\RuntimeException $e) {
// Too many favorites, can not put them into one query anymore...
- return ['`app` = ?', ['files']];
+ return ['`app` = ?', [self::APP_FILES]];
}
/*
@@ -331,7 +340,7 @@ class Activity implements IExtension {
* or `file` is a favorite or in a favorite folder
*/
$parameters = $fileQueryList = [];
- $parameters[] = 'files';
+ $parameters[] = self::APP_FILES;
$fileQueryList[] = '(`type` <> ? AND `type` <> ?)';
$parameters[] = self::TYPE_SHARE_CREATED;
@@ -346,7 +355,7 @@ class Activity implements IExtension {
$parameters[] = $favorite . '/%';
}
- $parameters[] = 'files';
+ $parameters[] = self::APP_FILES;
return [
' CASE WHEN `app` = ? THEN (' . implode(' OR ', $fileQueryList) . ') ELSE `app` <> ? END ',
@@ -363,6 +372,6 @@ class Activity implements IExtension {
* @return bool
*/
protected function userSettingFavoritesOnly($user) {
- return (bool) $this->config->getUserValue($user, 'activity', 'notify_stream_' . self::TYPE_FAVORITES, false);
+ return (bool) $this->config->getUserValue($user, 'activity', 'notify_' . self::METHOD_STREAM . '_' . self::TYPE_FAVORITES, false);
}
}
diff --git a/apps/files/lib/capabilities.php b/apps/files/lib/capabilities.php
index 05d12864dca..2e19283e4d6 100644
--- a/apps/files/lib/capabilities.php
+++ b/apps/files/lib/capabilities.php
@@ -1,7 +1,7 @@
<?php
/**
* @author Christopher Schäpers <kondou@ts.unde.re>
- * @author Morris Jobke <hey@morrisjobke.de>
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Tom Needham <tom@owncloud.com>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
@@ -20,19 +20,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
-namespace OCA\Files;
-class Capabilities {
-
- public static function getCapabilities() {
- return new \OC_OCS_Result(array(
- 'capabilities' => array(
- 'files' => array(
- 'bigfilechunking' => true,
- ),
- ),
- ));
+namespace OCA\Files;
+
+use OCP\Capabilities\ICapability;
+
+/**
+ * Class Capabilities
+ *
+ * @package OCA\Files
+ */
+class Capabilities implements ICapability {
+
+ /**
+ * Return this classes capabilities
+ *
+ * @return array
+ */
+ public function getCapabilities() {
+ return [
+ 'files' => [
+ 'bigfilechunking' => true,
+ ],
+ ];
}
-
}
diff --git a/apps/files/tests/activitytest.php b/apps/files/tests/activitytest.php
index 4ab8ad11eae..cdb1d21bcd8 100644
--- a/apps/files/tests/activitytest.php
+++ b/apps/files/tests/activitytest.php
@@ -42,6 +42,9 @@ class ActivityTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject */
protected $activityHelper;
+ /** @var \PHPUnit_Framework_MockObject_MockObject */
+ protected $l10nFactory;
+
/** @var \OCA\Files\Activity */
protected $activityExtension;
@@ -67,8 +70,28 @@ class ActivityTest extends TestCase {
$this->config
);
+ $this->l10nFactory = $this->getMockBuilder('OC\L10N\Factory')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $deL10n = $this->getMockBuilder('OC_L10N')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $deL10n->expects($this->any())
+ ->method('t')
+ ->willReturnCallback(function ($argument) {
+ return 'translate(' . $argument . ')';
+ });
+
+ $this->l10nFactory->expects($this->any())
+ ->method('get')
+ ->willReturnMap([
+ ['files', null, new \OC_L10N('files', 'en')],
+ ['files', 'en', new \OC_L10N('files', 'en')],
+ ['files', 'de', $deL10n],
+ ]);
+
$this->activityExtension = $activityExtension = new Activity(
- new \OC\L10N\Factory(),
+ $this->l10nFactory,
$this->getMockBuilder('OCP\IURLGenerator')->disableOriginalConstructor()->getMock(),
$this->activityManager,
$this->activityHelper,
@@ -111,6 +134,26 @@ class ActivityTest extends TestCase {
$this->activityExtension->translate('files_sharing', '', [], false, false, 'en'),
'Asserting that no translations are set for files_sharing'
);
+
+ // Test english
+ $this->assertNotFalse(
+ $this->activityExtension->translate('files', 'deleted_self', ['file'], false, false, 'en'),
+ 'Asserting that translations are set for files.deleted_self'
+ );
+ $this->assertStringStartsWith(
+ 'You deleted ',
+ $this->activityExtension->translate('files', 'deleted_self', ['file'], false, false, 'en')
+ );
+
+ // Test translation
+ $this->assertNotFalse(
+ $this->activityExtension->translate('files', 'deleted_self', ['file'], false, false, 'de'),
+ 'Asserting that translations are set for files.deleted_self'
+ );
+ $this->assertStringStartsWith(
+ 'translate(You deleted ',
+ $this->activityExtension->translate('files', 'deleted_self', ['file'], false, false, 'de')
+ );
}
public function testGetSpecialParameterList() {
diff --git a/apps/files_external/appinfo/application.php b/apps/files_external/appinfo/application.php
index 62d4d142ba6..d77a302466c 100644
--- a/apps/files_external/appinfo/application.php
+++ b/apps/files_external/appinfo/application.php
@@ -21,7 +21,7 @@
*
*/
-namespace OCA\Files_External\Appinfo;
+namespace OCA\Files_External\AppInfo;
use \OCA\Files_External\Controller\AjaxController;
use \OCP\AppFramework\App;
diff --git a/apps/files_external/appinfo/routes.php b/apps/files_external/appinfo/routes.php
index 97eb1353b1e..bc4b0e98c91 100644
--- a/apps/files_external/appinfo/routes.php
+++ b/apps/files_external/appinfo/routes.php
@@ -23,7 +23,7 @@
*
*/
-namespace OCA\Files_External\Appinfo;
+namespace OCA\Files_External\AppInfo;
/**
* @var $this \OC\Route\Router
diff --git a/apps/files_sharing/appinfo/application.php b/apps/files_sharing/appinfo/application.php
index b9c2844d78c..2fe9019d54e 100644
--- a/apps/files_sharing/appinfo/application.php
+++ b/apps/files_sharing/appinfo/application.php
@@ -2,6 +2,7 @@
/**
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <icewind@owncloud.com>
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
@@ -20,7 +21,7 @@
*
*/
-namespace OCA\Files_Sharing\Appinfo;
+namespace OCA\Files_Sharing\AppInfo;
use OCA\Files_Sharing\Helper;
use OCA\Files_Sharing\MountProvider;
@@ -31,6 +32,7 @@ use OCA\Files_Sharing\Controllers\ExternalSharesController;
use OCA\Files_Sharing\Controllers\ShareController;
use OCA\Files_Sharing\Middleware\SharingCheckMiddleware;
use \OCP\IContainer;
+use OCA\Files_Sharing\Capabilities;
class Application extends App {
public function __construct(array $urlParams = array()) {
@@ -122,6 +124,11 @@ class Application extends App {
$server->getConfig()
);
});
+
+ /*
+ * Register capabilities
+ */
+ $container->registerCapability('OCA\Files_Sharing\Capabilities');
}
public function registerMountProviders() {
diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php
index 21d21a83441..1e99267a43a 100644
--- a/apps/files_sharing/appinfo/routes.php
+++ b/apps/files_sharing/appinfo/routes.php
@@ -97,8 +97,3 @@ API::register('delete',
array('\OCA\Files_Sharing\API\Remote', 'declineShare'),
'files_sharing');
-// Register with the capabilities API
-API::register('get',
- '/cloud/capabilities',
- array('OCA\Files_Sharing\Capabilities', 'getCapabilities'),
- 'files_sharing', API::USER_AUTH);
diff --git a/apps/files_sharing/lib/activity.php b/apps/files_sharing/lib/activity.php
index e531674ddc2..204c0a037b9 100644
--- a/apps/files_sharing/lib/activity.php
+++ b/apps/files_sharing/lib/activity.php
@@ -106,7 +106,7 @@ class Activity implements IExtension {
self::TYPE_REMOTE_SHARE,
];
- if ($method === 'stream') {
+ if ($method === self::METHOD_STREAM) {
$defaultTypes[] = self::TYPE_PUBLIC_LINKS;
}
diff --git a/apps/files_sharing/lib/capabilities.php b/apps/files_sharing/lib/capabilities.php
index ac6454c3433..ef69a40078b 100644
--- a/apps/files_sharing/lib/capabilities.php
+++ b/apps/files_sharing/lib/capabilities.php
@@ -20,6 +20,7 @@
*/
namespace OCA\Files_Sharing;
+use OCP\Capabilities\ICapability;
use \OCP\IConfig;
/**
@@ -27,32 +28,21 @@ use \OCP\IConfig;
*
* @package OCA\Files_Sharing
*/
-class Capabilities {
+class Capabilities implements ICapability {
/** @var IConfig */
private $config;
- /**
- * @param IConfig $config
- */
public function __construct(IConfig $config) {
$this->config = $config;
}
/**
- * @return \OC_OCS_Result
- */
- public static function getCapabilities() {
- $config = \OC::$server->getConfig();
- $cap = new Capabilities($config);
- return $cap->getCaps();
- }
-
-
- /**
- * @return \OC_OCS_Result
+ * Return this classes capabilities
+ *
+ * @return array
*/
- public function getCaps() {
+ public function getCapabilities() {
$res = [];
$public = [];
@@ -76,12 +66,8 @@ class Capabilities {
$res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes';
-
- return new \OC_OCS_Result([
- 'capabilities' => [
- 'files_sharing' => $res
- ],
- ]);
+ return [
+ 'files_sharing' => $res,
+ ];
}
-
}
diff --git a/apps/files_sharing/tests/capabilities.php b/apps/files_sharing/tests/capabilities.php
index a7c487bf589..b0f6390b013 100644
--- a/apps/files_sharing/tests/capabilities.php
+++ b/apps/files_sharing/tests/capabilities.php
@@ -36,9 +36,8 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
* @return string[]
*/
private function getFilesSharingPart(array $data) {
- $this->assertArrayHasKey('capabilities', $data);
- $this->assertArrayHasKey('files_sharing', $data['capabilities']);
- return $data['capabilities']['files_sharing'];
+ $this->assertArrayHasKey('files_sharing', $data);
+ return $data['files_sharing'];
}
/**
@@ -53,7 +52,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
$stub = $this->getMockBuilder('\OCP\IConfig')->disableOriginalConstructor()->getMock();
$stub->method('getAppValue')->will($this->returnValueMap($map));
$cap = new Capabilities($stub);
- $result = $this->getFilesSharingPart($cap->getCaps()->getData());
+ $result = $this->getFilesSharingPart($cap->getCapabilities());
return $result;
}
diff --git a/apps/files_trashbin/appinfo/application.php b/apps/files_trashbin/appinfo/application.php
new file mode 100644
index 00000000000..8d76d40f639
--- /dev/null
+++ b/apps/files_trashbin/appinfo/application.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Files_Trashbin\AppInfo;
+
+use OCP\AppFramework\App;
+
+class Application extends App {
+ public function __construct(array $urlParams = array()) {
+ parent::__construct('files_trashbin', $urlParams);
+
+ $container = $this->getContainer();
+
+ /*
+ * Register capabilities
+ */
+ $container->registerCapability('OCA\Files_Trashbin\Capabilities');
+ }
+}
diff --git a/apps/files_trashbin/appinfo/routes.php b/apps/files_trashbin/appinfo/routes.php
index 99a03d6b969..cf3d7b77ec2 100644
--- a/apps/files_trashbin/appinfo/routes.php
+++ b/apps/files_trashbin/appinfo/routes.php
@@ -1,9 +1,8 @@
<?php
/**
* @author Georg Ehrke <georg@owncloud.com>
- * @author Joas Schilling <nickvergessen@owncloud.com>
* @author Lukas Reschke <lukas@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Vincent Petry <pvince81@owncloud.com>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
@@ -22,6 +21,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
+namespace OCA\Files_Trashbin\AppInfo;
+
+$application = new Application();
+
$this->create('core_ajax_trashbin_preview', 'ajax/preview.php')
->actionInclude('files_trashbin/ajax/preview.php');
$this->create('files_trashbin_ajax_delete', 'ajax/delete.php')
@@ -33,6 +37,3 @@ $this->create('files_trashbin_ajax_list', 'ajax/list.php')
$this->create('files_trashbin_ajax_undelete', 'ajax/undelete.php')
->actionInclude('files_trashbin/ajax/undelete.php');
-
-// Register with the capabilities API
-\OCP\API::register('get', '/cloud/capabilities', array('OCA\Files_Trashbin\Capabilities', 'getCapabilities'), 'files_trashbin', \OCP\API::USER_AUTH);
diff --git a/apps/files_trashbin/command/cleanup.php b/apps/files_trashbin/command/cleanup.php
index 0cc94912339..60717abac18 100644
--- a/apps/files_trashbin/command/cleanup.php
+++ b/apps/files_trashbin/command/cleanup.php
@@ -108,7 +108,7 @@ class CleanUp extends Command {
if ($this->rootFolder->nodeExists('/' . $uid . '/files_trashbin')) {
$this->rootFolder->get('/' . $uid . '/files_trashbin')->delete();
$query = $this->dbConnection->getQueryBuilder();
- $query->delete('*PREFIX*files_trash')
+ $query->delete('files_trash')
->where($query->expr()->eq('user', $query->createParameter('uid')))
->setParameter('uid', $uid);
$query->execute();
diff --git a/apps/files_trashbin/lib/capabilities.php b/apps/files_trashbin/lib/capabilities.php
index 89b268489b5..c991cc8be65 100644
--- a/apps/files_trashbin/lib/capabilities.php
+++ b/apps/files_trashbin/lib/capabilities.php
@@ -2,6 +2,7 @@
/**
* @author Lukas Reschke <lukas@owncloud.com>
* @author Morris Jobke <hey@morrisjobke.de>
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
@@ -22,25 +23,26 @@
namespace OCA\Files_Trashbin;
+use OCP\Capabilities\ICapability;
/**
* Class Capabilities
*
* @package OCA\Files_Trashbin
*/
-class Capabilities {
+class Capabilities implements ICapability {
/**
- * @return \OC_OCS_Result
+ * Return this classes capabilities
+ *
+ * @return array
*/
- public static function getCapabilities() {
- return new \OC_OCS_Result(array(
- 'capabilities' => array(
- 'files' => array(
- 'undelete' => true,
- ),
- ),
- ));
+ public function getCapabilities() {
+ return [
+ 'files' => [
+ 'undelete' => true
+ ]
+ ];
}
}
diff --git a/apps/files_trashbin/tests/command/cleanuptest.php b/apps/files_trashbin/tests/command/cleanuptest.php
index a7400e901fa..d4cccee448e 100644
--- a/apps/files_trashbin/tests/command/cleanuptest.php
+++ b/apps/files_trashbin/tests/command/cleanuptest.php
@@ -43,7 +43,7 @@ class CleanUpTest extends TestCase {
protected $dbConnection;
/** @var string */
- protected $trashTable = '*PREFIX*files_trash';
+ protected $trashTable = 'files_trash';
/** @var string */
protected $user0 = 'user0';
diff --git a/apps/files_versions/appinfo/application.php b/apps/files_versions/appinfo/application.php
new file mode 100644
index 00000000000..bab36b48510
--- /dev/null
+++ b/apps/files_versions/appinfo/application.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Files_Versions\AppInfo;
+
+use OCP\AppFramework\App;
+
+class Application extends App {
+ public function __construct(array $urlParams = array()) {
+ parent::__construct('files_versions', $urlParams);
+
+ $container = $this->getContainer();
+
+ /*
+ * Register capabilities
+ */
+ $container->registerCapability('OCA\Files_Versions\Capabilities');
+ }
+}
diff --git a/apps/files_versions/appinfo/routes.php b/apps/files_versions/appinfo/routes.php
index 5dbed1f93eb..9bab86d9224 100644
--- a/apps/files_versions/appinfo/routes.php
+++ b/apps/files_versions/appinfo/routes.php
@@ -1,10 +1,10 @@
<?php
/**
* @author Björn Schießle <schiessle@owncloud.com>
- * @author Joas Schilling <nickvergessen@owncloud.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Lukas Reschke <lukas@owncloud.com>
* @author Morris Jobke <hey@morrisjobke.de>
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Tom Needham <tom@owncloud.com>
*
@@ -25,6 +25,10 @@
*
*/
+namespace OCA\Files_Versions\AppInfo;
+
+$application = new Application();
+
/** @var $this \OCP\Route\IRouter */
$this->create('core_ajax_versions_preview', '/preview')->action(
function() {
@@ -38,5 +42,3 @@ $this->create('files_versions_ajax_getVersions', 'ajax/getVersions.php')
$this->create('files_versions_ajax_rollbackVersion', 'ajax/rollbackVersion.php')
->actionInclude('files_versions/ajax/rollbackVersion.php');
-// Register with the capabilities API
-\OCP\API::register('get', '/cloud/capabilities', array('OCA\Files_Versions\Capabilities', 'getCapabilities'), 'files_versions', \OCP\API::USER_AUTH);
diff --git a/apps/files_versions/lib/capabilities.php b/apps/files_versions/lib/capabilities.php
index aea31b25240..11b98038f46 100644
--- a/apps/files_versions/lib/capabilities.php
+++ b/apps/files_versions/lib/capabilities.php
@@ -2,6 +2,7 @@
/**
* @author Christopher Schäpers <kondou@ts.unde.re>
* @author Morris Jobke <hey@morrisjobke.de>
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Tom Needham <tom@owncloud.com>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
@@ -23,16 +24,20 @@
namespace OCA\Files_Versions;
-class Capabilities {
+use OCP\Capabilities\ICapability;
+
+class Capabilities implements ICapability {
- public static function getCapabilities() {
- return new \OC_OCS_Result(array(
- 'capabilities' => array(
- 'files' => array(
- 'versioning' => true,
- ),
- ),
- ));
+ /**
+ * Return this classes capabilities
+ *
+ * @return array
+ */
+ public function getCapabilities() {
+ return [
+ 'files' => [
+ 'versioning' => true
+ ]
+ ];
}
-
}
diff --git a/config/config.sample.php b/config/config.sample.php
index 3b5632087f6..5c362e94250 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -1017,7 +1017,13 @@ $CONFIG = array(
/**
* Headers that should be trusted as client IP address in combination with
- * `trusted_proxies`
+ * `trusted_proxies`. If the HTTP header looks like 'X-Forwarded-For', then use
+ * 'HTTP_X_FORWARDED_FOR' here.
+ *
+ * If set incorrectly, a client can spoof their IP address as visible to
+ * ownCloud, bypassing access controls and making logs useless!
+ *
+ * Defaults to 'HTTP_X_FORWARED_FOR' if unset
*/
'forwarded_for_headers' => array('HTTP_X_FORWARDED', 'HTTP_FORWARDED_FOR'),
diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js
index 35f24b188fa..fd192e6563b 100644
--- a/core/js/setupchecks.js
+++ b/core/js/setupchecks.js
@@ -72,6 +72,16 @@
if(data.isUsedTlsLibOutdated) {
messages.push(data.isUsedTlsLibOutdated);
}
+ if(data.phpSupported && data.phpSupported.eol) {
+ messages.push(
+ t('core', 'Your PHP version ({version}) is no longer <a href="{phpLink}">supported by PHP</a>. We encourage you to upgrade your PHP version to take advantage of performance and security updates provided by PHP.', {version: data.phpSupported.version, phpLink: 'https://secure.php.net/supported-versions.php'})
+ );
+ }
+ if(!data.forwardedForHeadersWorking) {
+ messages.push(
+ t('core', 'The reverse proxy headers configuration is incorrect, or you are accessing ownCloud from a trusted proxy. If you are not accessing ownCloud from a trusted proxy, this is a security issue and can allow an attacker to spoof their IP address as visible to ownCloud. Further information can be found in our <a href="{docLink}">documentation</a>.', {docLink: data.reverseProxyDocs})
+ );
+ }
} else {
messages.push(t('core', 'Error occurred while checking server setup'));
}
diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js
index ec8a732b4a1..d0efcf4b284 100644
--- a/core/js/tests/specs/setupchecksSpec.js
+++ b/core/js/tests/specs/setupchecksSpec.js
@@ -66,7 +66,12 @@ describe('OC.SetupChecks tests', function() {
{
'Content-Type': 'application/json'
},
- JSON.stringify({isUrandomAvailable: true, serverHasInternetConnection: false, memcacheDocs: 'https://doc.owncloud.org/server/go.php?to=admin-performance'})
+ JSON.stringify({
+ isUrandomAvailable: true,
+ serverHasInternetConnection: false,
+ memcacheDocs: 'https://doc.owncloud.org/server/go.php?to=admin-performance',
+ forwardedForHeadersWorking: true
+ })
);
async.done(function( data, s, x ){
@@ -83,7 +88,13 @@ describe('OC.SetupChecks tests', function() {
{
'Content-Type': 'application/json'
},
- JSON.stringify({isUrandomAvailable: true, serverHasInternetConnection: false, dataDirectoryProtected: false, memcacheDocs: 'https://doc.owncloud.org/server/go.php?to=admin-performance'})
+ JSON.stringify({
+ isUrandomAvailable: true,
+ serverHasInternetConnection: false,
+ dataDirectoryProtected: false,
+ memcacheDocs: 'https://doc.owncloud.org/server/go.php?to=admin-performance',
+ forwardedForHeadersWorking: true
+ })
);
async.done(function( data, s, x ){
@@ -100,7 +111,13 @@ describe('OC.SetupChecks tests', function() {
{
'Content-Type': 'application/json',
},
- JSON.stringify({isUrandomAvailable: true, serverHasInternetConnection: false, dataDirectoryProtected: false, isMemcacheConfigured: true})
+ JSON.stringify({
+ isUrandomAvailable: true,
+ serverHasInternetConnection: false,
+ dataDirectoryProtected: false,
+ isMemcacheConfigured: true,
+ forwardedForHeadersWorking: true
+ })
);
async.done(function( data, s, x ){
@@ -117,7 +134,14 @@ describe('OC.SetupChecks tests', function() {
{
'Content-Type': 'application/json',
},
- JSON.stringify({isUrandomAvailable: false, securityDocs: 'https://docs.owncloud.org/myDocs.html', serverHasInternetConnection: true, dataDirectoryProtected: true, isMemcacheConfigured: true})
+ JSON.stringify({
+ isUrandomAvailable: false,
+ securityDocs: 'https://docs.owncloud.org/myDocs.html',
+ serverHasInternetConnection: true,
+ dataDirectoryProtected: true,
+ isMemcacheConfigured: true,
+ forwardedForHeadersWorking: true
+ })
);
async.done(function( data, s, x ){
@@ -126,6 +150,30 @@ describe('OC.SetupChecks tests', function() {
});
});
+ it('should return an error if the forwarded for headers are not working', function(done) {
+ var async = OC.SetupChecks.checkSetup();
+
+ suite.server.requests[0].respond(
+ 200,
+ {
+ 'Content-Type': 'application/json',
+ },
+ JSON.stringify({
+ isUrandomAvailable: true,
+ serverHasInternetConnection: true,
+ dataDirectoryProtected: true,
+ isMemcacheConfigured: true,
+ forwardedForHeadersWorking: false,
+ reverseProxyDocs: 'https://docs.owncloud.org/foo/bar.html'
+ })
+ );
+
+ async.done(function( data, s, x ){
+ expect(data).toEqual(['The reverse proxy headers configuration is incorrect, or you are accessing ownCloud from a trusted proxy. If you are not accessing ownCloud from a trusted proxy, this is a security issue and can allow an attacker to spoof their IP address as visible to ownCloud. Further information can be found in our <a href="https://docs.owncloud.org/foo/bar.html">documentation</a>.']);
+ done();
+ });
+ });
+
it('should return an error if the response has no statuscode 200', function(done) {
var async = OC.SetupChecks.checkSetup();
@@ -142,6 +190,31 @@ describe('OC.SetupChecks tests', function() {
done();
});
});
+
+ it('should return an error if the php version is no longer supported', function(done) {
+ var async = OC.SetupChecks.checkSetup();
+
+ suite.server.requests[0].respond(
+ 200,
+ {
+ 'Content-Type': 'application/json',
+ },
+ JSON.stringify({
+ isUrandomAvailable: true,
+ securityDocs: 'https://docs.owncloud.org/myDocs.html',
+ serverHasInternetConnection: true,
+ dataDirectoryProtected: true,
+ isMemcacheConfigured: true,
+ forwardedForHeadersWorking: true,
+ phpSupported: {eol: true, version: '5.4.0'}
+ })
+ );
+
+ async.done(function( data, s, x ){
+ expect(data).toEqual(['Your PHP version (5.4.0) is no longer <a href="https://secure.php.net/supported-versions.php">supported by PHP</a>. We encourage you to upgrade your PHP version to take advantage of performance and security updates provided by PHP.']);
+ done();
+ });
+ });
});
describe('checkGeneric', function() {
diff --git a/lib/private/activitymanager.php b/lib/private/activitymanager.php
index 7b1d5d29f2e..938335a87e1 100644
--- a/lib/private/activitymanager.php
+++ b/lib/private/activitymanager.php
@@ -56,14 +56,16 @@ class ActivityManager implements IManager {
$this->config = $config;
}
- /**
- * @var \Closure[]
- */
+ /** @var \Closure[] */
+ private $consumersClosures = array();
+
+ /** @var IConsumer[] */
private $consumers = array();
- /**
- * @var \Closure[]
- */
+ /** @var \Closure[] */
+ private $extensionsClosures = array();
+
+ /** @var IExtension[] */
private $extensions = array();
/** @var array list of filters "name" => "is valid" */
@@ -80,6 +82,48 @@ class ActivityManager implements IManager {
protected $specialParameters = array();
/**
+ * @return \OCP\Activity\IConsumer[]
+ */
+ protected function getConsumers() {
+ if (!empty($this->consumers)) {
+ return $this->consumers;
+ }
+
+ $this->consumers = [];
+ foreach($this->consumersClosures as $consumer) {
+ $c = $consumer();
+ if ($c instanceof IConsumer) {
+ $this->consumers[] = $c;
+ } else {
+ throw new \InvalidArgumentException('The given consumer does not implement the \OCP\Activity\IConsumer interface');
+ }
+ }
+
+ return $this->consumers;
+ }
+
+ /**
+ * @return \OCP\Activity\IExtension[]
+ */
+ protected function getExtensions() {
+ if (!empty($this->extensions)) {
+ return $this->extensions;
+ }
+
+ $this->extensions = [];
+ foreach($this->extensionsClosures as $extension) {
+ $e = $extension();
+ if ($e instanceof IExtension) {
+ $this->extensions[] = $e;
+ } else {
+ throw new \InvalidArgumentException('The given extension does not implement the \OCP\Activity\IExtension interface');
+ }
+ }
+
+ return $this->extensions;
+ }
+
+ /**
* @param $app
* @param $subject
* @param $subjectParams
@@ -93,10 +137,8 @@ class ActivityManager implements IManager {
* @return mixed
*/
function publishActivity($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority) {
- foreach($this->consumers as $consumer) {
- $c = $consumer();
- if ($c instanceof IConsumer) {
- try {
+ foreach($this->getConsumers() as $c) {
+ try {
$c->receive(
$app,
$subject,
@@ -108,11 +150,9 @@ class ActivityManager implements IManager {
$affectedUser,
$type,
$priority);
- } catch (\Exception $ex) {
- // TODO: log the exception
- }
+ } catch (\Exception $ex) {
+ // TODO: log the exception
}
-
}
}
@@ -125,7 +165,8 @@ class ActivityManager implements IManager {
* @param \Closure $callable
*/
function registerConsumer(\Closure $callable) {
- array_push($this->consumers, $callable);
+ array_push($this->consumersClosures, $callable);
+ $this->consumers = [];
}
/**
@@ -138,7 +179,8 @@ class ActivityManager implements IManager {
* @return void
*/
function registerExtension(\Closure $callable) {
- array_push($this->extensions, $callable);
+ array_push($this->extensionsClosures, $callable);
+ $this->extensions = [];
}
/**
@@ -149,13 +191,10 @@ class ActivityManager implements IManager {
*/
function getNotificationTypes($languageCode) {
$notificationTypes = array();
- foreach($this->extensions as $extension) {
- $c = $extension();
- if ($c instanceof IExtension) {
- $result = $c->getNotificationTypes($languageCode);
- if (is_array($result)) {
- $notificationTypes = array_merge($notificationTypes, $result);
- }
+ foreach ($this->getExtensions() as $c) {
+ $result = $c->getNotificationTypes($languageCode);
+ if (is_array($result)) {
+ $notificationTypes = array_merge($notificationTypes, $result);
}
}
@@ -168,13 +207,10 @@ class ActivityManager implements IManager {
*/
function getDefaultTypes($method) {
$defaultTypes = array();
- foreach($this->extensions as $extension) {
- $c = $extension();
- if ($c instanceof IExtension) {
- $types = $c->getDefaultTypes($method);
- if (is_array($types)) {
- $defaultTypes = array_merge($types, $defaultTypes);
- }
+ foreach ($this->getExtensions() as $c) {
+ $types = $c->getDefaultTypes($method);
+ if (is_array($types)) {
+ $defaultTypes = array_merge($types, $defaultTypes);
}
}
return $defaultTypes;
@@ -189,14 +225,11 @@ class ActivityManager implements IManager {
return $this->typeIcons[$type];
}
- foreach($this->extensions as $extension) {
- $c = $extension();
- if ($c instanceof IExtension) {
- $icon = $c->getTypeIcon($type);
- if (is_string($icon)) {
- $this->typeIcons[$type] = $icon;
- return $icon;
- }
+ foreach ($this->getExtensions() as $c) {
+ $icon = $c->getTypeIcon($type);
+ if (is_string($icon)) {
+ $this->typeIcons[$type] = $icon;
+ return $icon;
}
}
@@ -214,13 +247,10 @@ class ActivityManager implements IManager {
* @return string|false
*/
function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode) {
- foreach($this->extensions as $extension) {
- $c = $extension();
- if ($c instanceof IExtension) {
- $translation = $c->translate($app, $text, $params, $stripPath, $highlightParams, $languageCode);
- if (is_string($translation)) {
- return $translation;
- }
+ foreach ($this->getExtensions() as $c) {
+ $translation = $c->translate($app, $text, $params, $stripPath, $highlightParams, $languageCode);
+ if (is_string($translation)) {
+ return $translation;
}
}
@@ -241,14 +271,11 @@ class ActivityManager implements IManager {
$this->specialParameters[$app] = array();
}
- foreach($this->extensions as $extension) {
- $c = $extension();
- if ($c instanceof IExtension) {
- $specialParameter = $c->getSpecialParameterList($app, $text);
- if (is_array($specialParameter)) {
- $this->specialParameters[$app][$text] = $specialParameter;
- return $specialParameter;
- }
+ foreach ($this->getExtensions() as $c) {
+ $specialParameter = $c->getSpecialParameterList($app, $text);
+ if (is_array($specialParameter)) {
+ $this->specialParameters[$app][$text] = $specialParameter;
+ return $specialParameter;
}
}
@@ -261,13 +288,10 @@ class ActivityManager implements IManager {
* @return integer|false
*/
function getGroupParameter($activity) {
- foreach($this->extensions as $extension) {
- $c = $extension();
- if ($c instanceof IExtension) {
- $parameter = $c->getGroupParameter($activity);
- if ($parameter !== false) {
- return $parameter;
- }
+ foreach ($this->getExtensions() as $c) {
+ $parameter = $c->getGroupParameter($activity);
+ if ($parameter !== false) {
+ return $parameter;
}
}
@@ -282,14 +306,11 @@ class ActivityManager implements IManager {
'apps' => array(),
'top' => array(),
);
- foreach($this->extensions as $extension) {
- $c = $extension();
- if ($c instanceof IExtension) {
- $additionalEntries = $c->getNavigation();
- if (is_array($additionalEntries)) {
- $entries['apps'] = array_merge($entries['apps'], $additionalEntries['apps']);
- $entries['top'] = array_merge($entries['top'], $additionalEntries['top']);
- }
+ foreach ($this->getExtensions() as $c) {
+ $additionalEntries = $c->getNavigation();
+ if (is_array($additionalEntries)) {
+ $entries['apps'] = array_merge($entries['apps'], $additionalEntries['apps']);
+ $entries['top'] = array_merge($entries['top'], $additionalEntries['top']);
}
}
@@ -305,13 +326,10 @@ class ActivityManager implements IManager {
return $this->validFilters[$filterValue];
}
- foreach($this->extensions as $extension) {
- $c = $extension();
- if ($c instanceof IExtension) {
- if ($c->isFilterValid($filterValue) === true) {
- $this->validFilters[$filterValue] = true;
- return true;
- }
+ foreach ($this->getExtensions() as $c) {
+ if ($c->isFilterValid($filterValue) === true) {
+ $this->validFilters[$filterValue] = true;
+ return true;
}
}
@@ -329,13 +347,10 @@ class ActivityManager implements IManager {
return $types;
}
- foreach($this->extensions as $extension) {
- $c = $extension();
- if ($c instanceof IExtension) {
- $result = $c->filterNotificationTypes($types, $filter);
- if (is_array($result)) {
- $types = $result;
- }
+ foreach ($this->getExtensions() as $c) {
+ $result = $c->filterNotificationTypes($types, $filter);
+ if (is_array($result)) {
+ $types = $result;
}
}
return $types;
@@ -353,16 +368,13 @@ class ActivityManager implements IManager {
$conditions = array();
$parameters = array();
- foreach($this->extensions as $extension) {
- $c = $extension();
- if ($c instanceof IExtension) {
- $result = $c->getQueryForFilter($filter);
- if (is_array($result)) {
- list($condition, $parameter) = $result;
- if ($condition && is_array($parameter)) {
- $conditions[] = $condition;
- $parameters = array_merge($parameters, $parameter);
- }
+ foreach ($this->getExtensions() as $c) {
+ $result = $c->getQueryForFilter($filter);
+ if (is_array($result)) {
+ list($condition, $parameter) = $result;
+ if ($condition && is_array($parameter)) {
+ $conditions[] = $condition;
+ $parameters = array_merge($parameters, $parameter);
}
}
}
diff --git a/lib/private/app.php b/lib/private/app.php
index 74b21b2b107..e51fe73cb19 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -74,6 +74,16 @@ class OC_App {
}
/**
+ * Check if an app is loaded
+ *
+ * @param string $app
+ * @return bool
+ */
+ public static function isAppLoaded($app) {
+ return in_array($app, self::$loadedApps, true);
+ }
+
+ /**
* loads all apps
*
* @param array $types
diff --git a/lib/private/appframework/dependencyinjection/dicontainer.php b/lib/private/appframework/dependencyinjection/dicontainer.php
index 927b6d43302..544da74a010 100644
--- a/lib/private/appframework/dependencyinjection/dicontainer.php
+++ b/lib/private/appframework/dependencyinjection/dicontainer.php
@@ -57,6 +57,7 @@ class DIContainer extends SimpleContainer implements IAppContainer {
* @param string $appName the name of the app
*/
public function __construct($appName, $urlParams = array()){
+ parent::__construct();
$this['AppName'] = $appName;
$this['urlParams'] = $urlParams;
@@ -96,6 +97,10 @@ class DIContainer extends SimpleContainer implements IAppContainer {
return $this->getServer()->getMemCacheFactory();
});
+ $this->registerService('OC\\CapabilitiesManager', function($c) {
+ return $this->getServer()->getCapabilitiesManager();
+ });
+
$this->registerService('OCP\\IConfig', function($c) {
return $this->getServer()->getConfig();
});
@@ -390,5 +395,15 @@ class DIContainer extends SimpleContainer implements IAppContainer {
\OCP\Util::writeLog($this->getAppName(), $message, $level);
}
+ /**
+ * Register a capability
+ *
+ * @param string $serviceName e.g. 'OCA\Files\Capabilities'
+ */
+ public function registerCapability($serviceName) {
+ $this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) {
+ return $this->query($serviceName);
+ });
+ }
}
diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php
index 43f01dfde3f..aaad286e843 100644
--- a/lib/private/appframework/http/request.php
+++ b/lib/private/appframework/http/request.php
@@ -452,7 +452,10 @@ class Request implements \ArrayAccess, \Countable, IRequest {
$trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
if(is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) {
- $forwardedForHeaders = $this->config->getSystemValue('forwarded_for_headers', []);
+ $forwardedForHeaders = $this->config->getSystemValue('forwarded_for_headers', [
+ 'HTTP_X_FORWARDED_FOR'
+ // only have one default, so we cannot ship an insecure product out of the box
+ ]);
foreach($forwardedForHeaders as $header) {
if(isset($this->server[$header])) {
diff --git a/lib/private/appframework/utility/simplecontainer.php b/lib/private/appframework/utility/simplecontainer.php
index c1fc96d1975..efe1b0812a6 100644
--- a/lib/private/appframework/utility/simplecontainer.php
+++ b/lib/private/appframework/utility/simplecontainer.php
@@ -148,7 +148,7 @@ class SimpleContainer extends Container implements IContainer {
public function registerAlias($alias, $target) {
$this->registerService($alias, function (IContainer $container) use ($target) {
return $container->query($target);
- });
+ }, false);
}
}
diff --git a/lib/private/capabilitiesmanager.php b/lib/private/capabilitiesmanager.php
new file mode 100644
index 00000000000..74154f2c631
--- /dev/null
+++ b/lib/private/capabilitiesmanager.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+namespace OC;
+
+
+use OCP\Capabilities\ICapability;
+
+class CapabilitiesManager {
+
+ /**
+ * @var \Closure[]
+ */
+ private $capabilities = array();
+
+ /**
+ * Get an array of al the capabilities that are registered at this manager
+ *
+ * @throws \InvalidArgumentException
+ * @return array
+ */
+ public function getCapabilities() {
+ $capabilities = [];
+ foreach($this->capabilities as $capability) {
+ $c = $capability();
+ if ($c instanceof ICapability) {
+ $capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
+ } else {
+ throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface');
+ }
+ }
+
+ return $capabilities;
+ }
+
+ /**
+ * In order to improve lazy loading a closure can be registered which will be called in case
+ * capabilities are actually requested
+ *
+ * $callable has to return an instance of OCP\Capabilities\ICapability
+ *
+ * @param \Closure $callable
+ */
+ public function registerCapability(\Closure $callable) {
+ array_push($this->capabilities, $callable);
+ }
+}
diff --git a/lib/private/db/querybuilder/querybuilder.php b/lib/private/db/querybuilder/querybuilder.php
index 1a1408876f1..1d97faf77cc 100644
--- a/lib/private/db/querybuilder/querybuilder.php
+++ b/lib/private/db/querybuilder/querybuilder.php
@@ -37,6 +37,9 @@ class QueryBuilder implements IQueryBuilder {
/** @var QuoteHelper */
private $helper;
+ /** @var bool */
+ private $automaticTablePrefix = true;
+
/**
* Initializes a new QueryBuilder.
*
@@ -49,6 +52,17 @@ class QueryBuilder implements IQueryBuilder {
}
/**
+ * Enable/disable automatic prefixing of table names with the oc_ prefix
+ *
+ * @param bool $enabled If set to true table names will be prefixed with the
+ * owncloud database prefix automatically.
+ * @since 8.2.0
+ */
+ public function automaticTablePrefix($enabled) {
+ $this->automaticTablePrefix = (bool) $enabled;
+ }
+
+ /**
* Gets an ExpressionBuilder used for object-oriented construction of query expressions.
* This producer method is intended for convenient inline usage. Example:
*
@@ -329,7 +343,7 @@ class QueryBuilder implements IQueryBuilder {
*/
public function delete($delete = null, $alias = null) {
$this->queryBuilder->delete(
- $this->helper->quoteColumnName($delete),
+ $this->getTableName($delete),
$alias
);
@@ -354,7 +368,7 @@ class QueryBuilder implements IQueryBuilder {
*/
public function update($update = null, $alias = null) {
$this->queryBuilder->update(
- $this->helper->quoteColumnName($update),
+ $this->getTableName($update),
$alias
);
@@ -382,7 +396,7 @@ class QueryBuilder implements IQueryBuilder {
*/
public function insert($insert = null) {
$this->queryBuilder->insert(
- $this->helper->quoteColumnName($insert)
+ $this->getTableName($insert)
);
return $this;
@@ -405,7 +419,7 @@ class QueryBuilder implements IQueryBuilder {
*/
public function from($from, $alias = null) {
$this->queryBuilder->from(
- $this->helper->quoteColumnName($from),
+ $this->getTableName($from),
$alias
);
@@ -432,7 +446,7 @@ class QueryBuilder implements IQueryBuilder {
public function join($fromAlias, $join, $alias, $condition = null) {
$this->queryBuilder->join(
$fromAlias,
- $this->helper->quoteColumnName($join),
+ $this->getTableName($join),
$alias,
$condition
);
@@ -460,7 +474,7 @@ class QueryBuilder implements IQueryBuilder {
public function innerJoin($fromAlias, $join, $alias, $condition = null) {
$this->queryBuilder->innerJoin(
$fromAlias,
- $this->helper->quoteColumnName($join),
+ $this->getTableName($join),
$alias,
$condition
);
@@ -488,7 +502,7 @@ class QueryBuilder implements IQueryBuilder {
public function leftJoin($fromAlias, $join, $alias, $condition = null) {
$this->queryBuilder->leftJoin(
$fromAlias,
- $this->helper->quoteColumnName($join),
+ $this->getTableName($join),
$alias,
$condition
);
@@ -516,7 +530,7 @@ class QueryBuilder implements IQueryBuilder {
public function rightJoin($fromAlias, $join, $alias, $condition = null) {
$this->queryBuilder->rightJoin(
$fromAlias,
- $this->helper->quoteColumnName($join),
+ $this->getTableName($join),
$alias,
$condition
);
@@ -984,4 +998,16 @@ class QueryBuilder implements IQueryBuilder {
public function createFunction($call) {
return new QueryFunction($call);
}
+
+ /**
+ * @param string $table
+ * @return string
+ */
+ private function getTableName($table) {
+ if ($this->automaticTablePrefix === false || strpos($table, '*PREFIX*') === 0) {
+ return $this->helper->quoteColumnName($table);
+ }
+
+ return $this->helper->quoteColumnName('*PREFIX*' . $table);
+ }
}
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index dc6e8aaa719..9afa9d40b20 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -642,10 +642,10 @@ class View {
}
$run = true;
- if ($this->shouldEmitHooks() && (Cache\Scanner::isPartialFile($path1) && !Cache\Scanner::isPartialFile($path2))) {
+ if ($this->shouldEmitHooks($path1) && (Cache\Scanner::isPartialFile($path1) && !Cache\Scanner::isPartialFile($path2))) {
// if it was a rename from a part file to a regular file it was a write and not a rename operation
$this->emit_file_hooks_pre($exists, $path2, $run);
- } elseif ($this->shouldEmitHooks()) {
+ } elseif ($this->shouldEmitHooks($path1)) {
\OC_Hook::emit(
Filesystem::CLASSNAME, Filesystem::signal_rename,
array(
@@ -1087,6 +1087,11 @@ class View {
return true;
}
$fullPath = $this->getAbsolutePath($path);
+
+ if ($fullPath === $defaultRoot) {
+ return true;
+ }
+
return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
}
diff --git a/lib/private/installer.php b/lib/private/installer.php
index 37af8d0edcb..392dc1c0817 100644
--- a/lib/private/installer.php
+++ b/lib/private/installer.php
@@ -107,6 +107,10 @@ class OC_Installer{
}
$extractDir .= '/' . $info['id'];
+ if(!file_exists($extractDir)) {
+ OC_Helper::rmdirr($basedir);
+ throw new \Exception($l->t("Archive does not contain a directory named %s", $info['id']));
+ }
OC_Helper::copyr($extractDir, $basedir);
//remove temporary files
diff --git a/lib/private/ocs/cloud.php b/lib/private/ocs/cloud.php
index f662bde2858..8f4f1769e9c 100644
--- a/lib/private/ocs/cloud.php
+++ b/lib/private/ocs/cloud.php
@@ -3,6 +3,7 @@
* @author Bart Visscher <bartv@thisnet.nl>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin McCorkell <rmccorkell@karoshi.org.uk>
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Tom Needham <tom@owncloud.com>
*
@@ -36,12 +37,8 @@ class OC_OCS_Cloud {
'edition' => OC_Util::getEditionString(),
);
- $result['capabilities'] = array(
- 'core' => array(
- 'pollinterval' => OC_Config::getValue('pollinterval', 60),
- ),
- );
-
+ $result['capabilities'] = \OC::$server->getCapabilitiesManager()->getCapabilities();
+
return new OC_OCS_Result($result);
}
diff --git a/lib/private/ocs/corecapabilities.php b/lib/private/ocs/corecapabilities.php
new file mode 100644
index 00000000000..6b620ab0a84
--- /dev/null
+++ b/lib/private/ocs/corecapabilities.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OC\OCS;
+
+use OCP\Capabilities\ICapability;
+use OCP\IConfig;
+
+/**
+ * Class Capabilities
+ *
+ * @package OC\OCS
+ */
+class CoreCapabilities implements ICapability {
+
+ /** @var IConfig */
+ private $config;
+
+ /**
+ * @param IConfig $config
+ */
+ public function __construct(IConfig $config) {
+ $this->config = $config;
+ }
+
+ /**
+ * Return this classes capabilities
+ *
+ * @return array
+ */
+ public function getCapabilities() {
+ return [
+ 'core' => [
+ 'pollinterval' => $this->config->getSystemValue('pollinterval', 60)
+ ]
+ ];
+ }
+}
diff --git a/lib/private/route/router.php b/lib/private/route/router.php
index 48992366092..33669452f2d 100644
--- a/lib/private/route/router.php
+++ b/lib/private/route/router.php
@@ -150,6 +150,12 @@ class Router implements IRouter {
\OC::$server->getEventLogger()->start('loadroutes' . $requestedApp, 'Loading Routes');
foreach ($routingFiles as $app => $file) {
if (!isset($this->loadedApps[$app])) {
+ if (!\OC_App::isAppLoaded($app)) {
+ // app MUST be loaded before app routes
+ // try again next time loadRoutes() is called
+ $this->loaded = false;
+ continue;
+ }
$this->loadedApps[$app] = true;
$this->useCollection($app);
$this->requireRouteFile($file, $app);
diff --git a/lib/private/server.php b/lib/private/server.php
index 12981fe7f19..618431ff2d4 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -75,6 +75,7 @@ class Server extends SimpleContainer implements IServerContainer {
* @param string $webRoot
*/
public function __construct($webRoot) {
+ parent::__construct();
$this->webRoot = $webRoot;
$this->registerService('ContactsManager', function ($c) {
@@ -449,6 +450,14 @@ class Server extends SimpleContainer implements IServerContainer {
$c->getURLGenerator(),
\OC::$configDir);
});
+ $this->registerService('CapabilitiesManager', function (Server $c) {
+ $manager = new \OC\CapabilitiesManager();
+ $manager->registerCapability(function() use ($c) {
+ return new \OC\OCS\CoreCapabilities($c->getConfig());
+ });
+ return $manager;
+ });
+
}
/**
@@ -945,4 +954,13 @@ class Server extends SimpleContainer implements IServerContainer {
public function getMimeTypeDetector() {
return $this->query('MimeTypeDetector');
}
+
+ /**
+ * Get the manager of all the capabilities
+ *
+ * @return \OC\CapabilitiesManager
+ */
+ public function getCapabilitiesManager() {
+ return $this->query('CapabilitiesManager');
+ }
}
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 40fcc59f219..9aea4677b5b 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -1218,7 +1218,7 @@ class Share extends Constants {
$qb = $connection->getQueryBuilder();
$qb->select('uid_owner')
- ->from('*PREFIX*share')
+ ->from('share')
->where($qb->expr()->eq('id', $qb->createParameter('shareId')))
->setParameter(':shareId', $shareId);
$result = $qb->execute();
@@ -1269,7 +1269,7 @@ class Share extends Constants {
self::verifyPassword($password);
$qb = $connection->getQueryBuilder();
- $qb->update('*PREFIX*share')
+ $qb->update('share')
->set('share_with', $qb->createParameter('pass'))
->where($qb->expr()->eq('id', $qb->createParameter('shareId')))
->setParameter(':pass', is_null($password) ? null : \OC::$server->getHasher()->hash($password))
diff --git a/lib/public/activity/iextension.php b/lib/public/activity/iextension.php
index 19d1d2e83a0..5d9fe3329ef 100644
--- a/lib/public/activity/iextension.php
+++ b/lib/public/activity/iextension.php
@@ -38,6 +38,8 @@ namespace OCP\Activity;
* @since 8.0.0
*/
interface IExtension {
+ const METHOD_STREAM = 'stream';
+ const METHOD_MAIL = 'email';
const PRIORITY_VERYLOW = 10;
const PRIORITY_LOW = 20;
@@ -50,8 +52,13 @@ interface IExtension {
* If no additional types are to be added false is to be returned
*
* @param string $languageCode
- * @return array|false
+ * @return array|false Array "stringID of the type" => "translated string description for the setting"
+ * or Array "stringID of the type" => [
+ * 'desc' => "translated string description for the setting"
+ * 'methods' => [self::METHOD_*],
+ * ]
* @since 8.0.0
+ * @changed 8.2.0 - Added support to allow limiting notifications to certain methods
*/
public function getNotificationTypes($languageCode);
diff --git a/lib/public/activity/imanager.php b/lib/public/activity/imanager.php
index cadb37da03b..0f5dccd8ba1 100644
--- a/lib/public/activity/imanager.php
+++ b/lib/public/activity/imanager.php
@@ -81,9 +81,15 @@ interface IManager {
/**
* Will return additional notification types as specified by other apps
+ *
* @param string $languageCode
- * @return array
+ * @return array Array "stringID of the type" => "translated string description for the setting"
+ * or Array "stringID of the type" => [
+ * 'desc' => "translated string description for the setting"
+ * 'methods' => [\OCP\Activity\IExtension::METHOD_*],
+ * ]
* @since 8.0.0
+ * @changed 8.2.0 - Added support to allow limiting notifications to certain methods
*/
function getNotificationTypes($languageCode);
diff --git a/lib/public/appframework/http/contentsecuritypolicy.php b/lib/public/appframework/http/contentsecuritypolicy.php
index 9c7218dc8ba..ee36f7aac17 100644
--- a/lib/public/appframework/http/contentsecuritypolicy.php
+++ b/lib/public/appframework/http/contentsecuritypolicy.php
@@ -63,6 +63,7 @@ class ContentSecurityPolicy {
/** @var array Domains from which images can get loaded */
private $allowedImageDomains = [
'\'self\'',
+ 'data:',
];
/** @var array Domains to which connections can be done */
private $allowedConnectDomains = [
diff --git a/lib/public/appframework/iappcontainer.php b/lib/public/appframework/iappcontainer.php
index 64b1082aa97..7338dbd858d 100644
--- a/lib/public/appframework/iappcontainer.php
+++ b/lib/public/appframework/iappcontainer.php
@@ -86,4 +86,11 @@ interface IAppContainer extends IContainer {
*/
function log($message, $level);
+ /**
+ * Register a capability
+ *
+ * @param string $serviceName e.g. 'OCA\Files\Capabilities'
+ * @since 8.2.0
+ */
+ public function registerCapability($serviceName);
}
diff --git a/lib/public/capabilities/icapability.php b/lib/public/capabilities/icapability.php
new file mode 100644
index 00000000000..71a56128d26
--- /dev/null
+++ b/lib/public/capabilities/icapability.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCP\Capabilities;
+
+/**
+ * Minimal interface that has to be implemented for a class to be considered
+ * a capability.
+ *
+ * In an application use:
+ * $this->getContainer()->registerCapability('OCA\MY_APP\Capabilities');
+ * To register capabilities.
+ *
+ * The class 'OCA\MY_APP\Capabilities' must then implement ICapability
+ *
+ * @since 8.2.0
+ */
+interface ICapability {
+
+ /**
+ * Function an app uses to return the capabilities
+ *
+ * @return array Array containing the apps capabilities
+ * @since 8.2.0
+ */
+ public function getCapabilities();
+}
+
diff --git a/lib/public/db/querybuilder/iquerybuilder.php b/lib/public/db/querybuilder/iquerybuilder.php
index 09d5d199bef..3fc07af1a47 100644
--- a/lib/public/db/querybuilder/iquerybuilder.php
+++ b/lib/public/db/querybuilder/iquerybuilder.php
@@ -27,6 +27,15 @@ namespace OCP\DB\QueryBuilder;
*/
interface IQueryBuilder {
/**
+ * Enable/disable automatic prefixing of table names with the oc_ prefix
+ *
+ * @param bool $enabled If set to true table names will be prefixed with the
+ * owncloud database prefix automatically.
+ * @since 8.2.0
+ */
+ public function automaticTablePrefix($enabled);
+
+ /**
* Gets an ExpressionBuilder used for object-oriented construction of query expressions.
* This producer method is intended for convenient inline usage. Example:
*
diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php
index f3165db33da..ab1729da255 100644
--- a/lib/public/iservercontainer.php
+++ b/lib/public/iservercontainer.php
@@ -438,4 +438,5 @@ interface IServerContainer {
* @since 8.2.0
*/
public function getMimeTypeDetector();
+
}
diff --git a/lib/repair/cleantags.php b/lib/repair/cleantags.php
index 2bda1047081..d16a49fbca7 100644
--- a/lib/repair/cleantags.php
+++ b/lib/repair/cleantags.php
@@ -65,8 +65,8 @@ class CleanTags extends BasicEmitter implements RepairStep {
protected function deleteOrphanFileEntries() {
$this->deleteOrphanEntries(
'%d tags for delete files have been removed.',
- '*PREFIX*vcategory_to_object', 'objid',
- '*PREFIX*filecache', 'fileid', 'path_hash'
+ 'vcategory_to_object', 'objid',
+ 'filecache', 'fileid', 'path_hash'
);
}
@@ -76,8 +76,8 @@ class CleanTags extends BasicEmitter implements RepairStep {
protected function deleteOrphanTagEntries() {
$this->deleteOrphanEntries(
'%d tag entries for deleted tags have been removed.',
- '*PREFIX*vcategory_to_object', 'categoryid',
- '*PREFIX*vcategory', 'id', 'uid'
+ 'vcategory_to_object', 'categoryid',
+ 'vcategory', 'id', 'uid'
);
}
@@ -87,8 +87,8 @@ class CleanTags extends BasicEmitter implements RepairStep {
protected function deleteOrphanCategoryEntries() {
$this->deleteOrphanEntries(
'%d tags with no entries have been removed.',
- '*PREFIX*vcategory', 'id',
- '*PREFIX*vcategory_to_object', 'categoryid', 'type'
+ 'vcategory', 'id',
+ 'vcategory_to_object', 'categoryid', 'type'
);
}
diff --git a/lib/repair/filletags.php b/lib/repair/filletags.php
index f1bb2c896c4..40072209982 100644
--- a/lib/repair/filletags.php
+++ b/lib/repair/filletags.php
@@ -42,7 +42,7 @@ class FillETags extends BasicEmitter implements \OC\RepairStep {
public function run() {
$qb = $this->connection->getQueryBuilder();
- $qb->update('*PREFIX*filecache')
+ $qb->update('filecache')
->set('etag', $qb->expr()->literal('xxx'))
->where($qb->expr()->eq('etag', $qb->expr()->literal('')))
->orWhere($qb->expr()->isNull('etag'));
diff --git a/settings/controller/checksetupcontroller.php b/settings/controller/checksetupcontroller.php
index f849e3ed565..33f94fe4238 100644
--- a/settings/controller/checksetupcontroller.php
+++ b/settings/controller/checksetupcontroller.php
@@ -128,7 +128,7 @@ class CheckSetupController extends Controller {
/**
* Check if the used SSL lib is outdated. Older OpenSSL and NSS versions do
* have multiple bugs which likely lead to problems in combination with
- * functionalities required by ownCloud such as SNI.
+ * functionality required by ownCloud such as SNI.
*
* @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546
* @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172
@@ -175,6 +175,40 @@ class CheckSetupController extends Controller {
return '';
}
+
+ /*
+ * Whether the php version is still supported (at time of release)
+ * according to: https://secure.php.net/supported-versions.php
+ *
+ * @return array
+ */
+ private function isPhpSupported() {
+ $eol = false;
+
+ //PHP 5.4 is EOL on 14 Sep 2015
+ if (version_compare(PHP_VERSION, '5.5.0') === -1) {
+ $eol = true;
+ }
+
+ return ['eol' => $eol, 'version' => PHP_VERSION];
+ }
+
+ /*
+ * Check if the reverse proxy configuration is working as expected
+ *
+ * @return bool
+ */
+ private function forwardedForHeadersWorking() {
+ $trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
+ $remoteAddress = $this->request->getRemoteAddress();
+
+ if (is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) {
+ return false;
+ }
+
+ // either not enabled or working correctly
+ return true;
+ }
/**
* @return DataResponse
@@ -189,6 +223,9 @@ class CheckSetupController extends Controller {
'isUrandomAvailable' => $this->isUrandomAvailable(),
'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
+ 'phpSupported' => $this->isPhpSupported(),
+ 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(),
+ 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
]
);
}
diff --git a/tests/lib/activitymanager.php b/tests/lib/activitymanager.php
index a35daeaf494..28caf575948 100644
--- a/tests/lib/activitymanager.php
+++ b/tests/lib/activitymanager.php
@@ -41,6 +41,9 @@ class Test_ActivityManager extends \Test\TestCase {
$this->config
);
+ $this->activityManager->registerConsumer(function() {
+ return new NoOpConsumer();
+ });
$this->activityManager->registerExtension(function() {
return new NoOpExtension();
});
@@ -49,6 +52,40 @@ class Test_ActivityManager extends \Test\TestCase {
});
}
+ public function testGetConsumers() {
+ $consumers = $this->invokePrivate($this->activityManager, 'getConsumers');
+
+ $this->assertNotEmpty($consumers);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testGetConsumersInvalidConsumer() {
+ $this->activityManager->registerConsumer(function() {
+ return new StdClass();
+ });
+
+ $this->invokePrivate($this->activityManager, 'getConsumers');
+ }
+
+ public function testGetExtensions() {
+ $extensions = $this->invokePrivate($this->activityManager, 'getExtensions');
+
+ $this->assertNotEmpty($extensions);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testGetExtensionsInvalidExtension() {
+ $this->activityManager->registerExtension(function() {
+ return new StdClass();
+ });
+
+ $this->invokePrivate($this->activityManager, 'getExtensions');
+ }
+
public function testNotificationTypes() {
$result = $this->activityManager->getNotificationTypes('en');
$this->assertTrue(is_array($result));
@@ -328,3 +365,9 @@ class NoOpExtension implements \OCP\Activity\IExtension {
return false;
}
}
+
+class NoOpConsumer implements \OCP\Activity\IConsumer {
+
+ public function receive($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority) {
+ }
+}
diff --git a/tests/lib/appframework/controller/ControllerTest.php b/tests/lib/appframework/controller/ControllerTest.php
index ccc373f4d59..0d7716da411 100644
--- a/tests/lib/appframework/controller/ControllerTest.php
+++ b/tests/lib/appframework/controller/ControllerTest.php
@@ -177,7 +177,7 @@ class ControllerTest extends \Test\TestCase {
'test' => 'something',
'Cache-Control' => 'no-cache, must-revalidate',
'Content-Type' => 'application/json; charset=utf-8',
- 'Content-Security-Policy' => "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'",
+ 'Content-Security-Policy' => "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'",
];
$response = $this->controller->customDataResponse(array('hi'));
diff --git a/tests/lib/appframework/http/ContentSecurityPolicyTest.php b/tests/lib/appframework/http/ContentSecurityPolicyTest.php
index 18d71df483f..082c032a420 100644
--- a/tests/lib/appframework/http/ContentSecurityPolicyTest.php
+++ b/tests/lib/appframework/http/ContentSecurityPolicyTest.php
@@ -28,19 +28,19 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDefault() {
- $defaultPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $defaultPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->assertSame($defaultPolicy, $this->contentSecurityPolicy->buildPolicy());
}
public function testGetPolicyScriptDomainValid() {
- $expectedPolicy = "default-src 'none';script-src 'self' www.owncloud.com 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' www.owncloud.com 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedScriptDomain('www.owncloud.com');
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
public function testGetPolicyScriptDomainValidMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' www.owncloud.com www.owncloud.org 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' www.owncloud.com www.owncloud.org 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedScriptDomain('www.owncloud.com');
$this->contentSecurityPolicy->addAllowedScriptDomain('www.owncloud.org');
@@ -48,7 +48,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowScriptDomain() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedScriptDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowScriptDomain('www.owncloud.com');
@@ -56,7 +56,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowScriptDomainMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' www.owncloud.com 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' www.owncloud.com 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedScriptDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowScriptDomain('www.owncloud.org');
@@ -64,7 +64,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowScriptDomainMultipleStacked() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedScriptDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowScriptDomain('www.owncloud.org')->disallowScriptDomain('www.owncloud.com');
@@ -72,14 +72,14 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyScriptAllowInline() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-inline' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-inline' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->allowInlineScript(true);
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
public function testGetPolicyScriptAllowInlineWithDomain() {
- $expectedPolicy = "default-src 'none';script-src 'self' www.owncloud.com 'unsafe-inline' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' www.owncloud.com 'unsafe-inline' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedScriptDomain('www.owncloud.com');
$this->contentSecurityPolicy->allowInlineScript(true);
@@ -87,7 +87,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyScriptDisallowInlineAndEval() {
- $expectedPolicy = "default-src 'none';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->allowInlineScript(false);
$this->contentSecurityPolicy->allowEvalScript(false);
@@ -95,14 +95,14 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyStyleDomainValid() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' www.owncloud.com 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' www.owncloud.com 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedStyleDomain('www.owncloud.com');
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
public function testGetPolicyStyleDomainValidMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' www.owncloud.com www.owncloud.org 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' www.owncloud.com www.owncloud.org 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedStyleDomain('www.owncloud.com');
$this->contentSecurityPolicy->addAllowedStyleDomain('www.owncloud.org');
@@ -110,7 +110,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowStyleDomain() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedStyleDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowStyleDomain('www.owncloud.com');
@@ -118,7 +118,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowStyleDomainMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' www.owncloud.com 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' www.owncloud.com 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedStyleDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowStyleDomain('www.owncloud.org');
@@ -126,7 +126,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowStyleDomainMultipleStacked() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedStyleDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowStyleDomain('www.owncloud.org')->disallowStyleDomain('www.owncloud.com');
@@ -134,35 +134,35 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyStyleAllowInline() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->allowInlineStyle(true);
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
public function testGetPolicyStyleAllowInlineWithDomain() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' www.owncloud.com 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' www.owncloud.com 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedStyleDomain('www.owncloud.com');
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
public function testGetPolicyStyleDisallowInline() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->allowInlineStyle(false);
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
public function testGetPolicyImageDomainValid() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' www.owncloud.com;font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data: www.owncloud.com;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedImageDomain('www.owncloud.com');
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
public function testGetPolicyImageDomainValidMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' www.owncloud.com www.owncloud.org;font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data: www.owncloud.com www.owncloud.org;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedImageDomain('www.owncloud.com');
$this->contentSecurityPolicy->addAllowedImageDomain('www.owncloud.org');
@@ -170,7 +170,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowImageDomain() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedImageDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowImageDomain('www.owncloud.com');
@@ -178,7 +178,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowImageDomainMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' www.owncloud.com;font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data: www.owncloud.com;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedImageDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowImageDomain('www.owncloud.org');
@@ -186,7 +186,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowImageDomainMultipleStakes() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedImageDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowImageDomain('www.owncloud.org')->disallowImageDomain('www.owncloud.com');
@@ -194,14 +194,14 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyFontDomainValid() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self' www.owncloud.com;connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self' www.owncloud.com;connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedFontDomain('www.owncloud.com');
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
public function testGetPolicyFontDomainValidMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self' www.owncloud.com www.owncloud.org;connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self' www.owncloud.com www.owncloud.org;connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedFontDomain('www.owncloud.com');
$this->contentSecurityPolicy->addAllowedFontDomain('www.owncloud.org');
@@ -209,7 +209,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowFontDomain() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedFontDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowFontDomain('www.owncloud.com');
@@ -217,7 +217,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowFontDomainMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self' www.owncloud.com;connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self' www.owncloud.com;connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedFontDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowFontDomain('www.owncloud.org');
@@ -225,7 +225,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowFontDomainMultipleStakes() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedFontDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowFontDomain('www.owncloud.org')->disallowFontDomain('www.owncloud.com');
@@ -233,14 +233,14 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyConnectDomainValid() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self' www.owncloud.com;media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self' www.owncloud.com;media-src 'self'";
$this->contentSecurityPolicy->addAllowedConnectDomain('www.owncloud.com');
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
public function testGetPolicyConnectDomainValidMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self' www.owncloud.com www.owncloud.org;media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self' www.owncloud.com www.owncloud.org;media-src 'self'";
$this->contentSecurityPolicy->addAllowedConnectDomain('www.owncloud.com');
$this->contentSecurityPolicy->addAllowedConnectDomain('www.owncloud.org');
@@ -248,7 +248,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowConnectDomain() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedConnectDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowConnectDomain('www.owncloud.com');
@@ -256,7 +256,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowConnectDomainMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self' www.owncloud.com;media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self' www.owncloud.com;media-src 'self'";
$this->contentSecurityPolicy->addAllowedConnectDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowConnectDomain('www.owncloud.org');
@@ -264,7 +264,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowConnectDomainMultipleStakes() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedConnectDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowConnectDomain('www.owncloud.org')->disallowConnectDomain('www.owncloud.com');
@@ -272,14 +272,14 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyMediaDomainValid() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self' www.owncloud.com";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self' www.owncloud.com";
$this->contentSecurityPolicy->addAllowedMediaDomain('www.owncloud.com');
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
public function testGetPolicyMediaDomainValidMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self' www.owncloud.com www.owncloud.org";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self' www.owncloud.com www.owncloud.org";
$this->contentSecurityPolicy->addAllowedMediaDomain('www.owncloud.com');
$this->contentSecurityPolicy->addAllowedMediaDomain('www.owncloud.org');
@@ -287,7 +287,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowMediaDomain() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedMediaDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowMediaDomain('www.owncloud.com');
@@ -295,7 +295,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowMediaDomainMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self' www.owncloud.com";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self' www.owncloud.com";
$this->contentSecurityPolicy->addAllowedMediaDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowMediaDomain('www.owncloud.org');
@@ -303,7 +303,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowMediaDomainMultipleStakes() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedMediaDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowMediaDomain('www.owncloud.org')->disallowMediaDomain('www.owncloud.com');
@@ -311,14 +311,14 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyObjectDomainValid() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self';object-src www.owncloud.com";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self';object-src www.owncloud.com";
$this->contentSecurityPolicy->addAllowedObjectDomain('www.owncloud.com');
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
public function testGetPolicyObjectDomainValidMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self';object-src www.owncloud.com www.owncloud.org";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self';object-src www.owncloud.com www.owncloud.org";
$this->contentSecurityPolicy->addAllowedObjectDomain('www.owncloud.com');
$this->contentSecurityPolicy->addAllowedObjectDomain('www.owncloud.org');
@@ -326,7 +326,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowObjectDomain() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedObjectDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowObjectDomain('www.owncloud.com');
@@ -334,7 +334,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowObjectDomainMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self';object-src www.owncloud.com";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self';object-src www.owncloud.com";
$this->contentSecurityPolicy->addAllowedObjectDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowObjectDomain('www.owncloud.org');
@@ -342,7 +342,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowObjectDomainMultipleStakes() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedObjectDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowObjectDomain('www.owncloud.org')->disallowObjectDomain('www.owncloud.com');
@@ -350,14 +350,14 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetAllowedFrameDomain() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self';frame-src www.owncloud.com";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self';frame-src www.owncloud.com";
$this->contentSecurityPolicy->addAllowedFrameDomain('www.owncloud.com');
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
public function testGetPolicyFrameDomainValidMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self';frame-src www.owncloud.com www.owncloud.org";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self';frame-src www.owncloud.com www.owncloud.org";
$this->contentSecurityPolicy->addAllowedFrameDomain('www.owncloud.com');
$this->contentSecurityPolicy->addAllowedFrameDomain('www.owncloud.org');
@@ -365,7 +365,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowFrameDomain() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedFrameDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowFrameDomain('www.owncloud.com');
@@ -373,7 +373,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowFrameDomainMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self';frame-src www.owncloud.com";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self';frame-src www.owncloud.com";
$this->contentSecurityPolicy->addAllowedFrameDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowFrameDomain('www.owncloud.org');
@@ -381,7 +381,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowFrameDomainMultipleStakes() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedFrameDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowFrameDomain('www.owncloud.org')->disallowFrameDomain('www.owncloud.com');
@@ -389,14 +389,14 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetAllowedChildSrcDomain() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self';child-src child.owncloud.com";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self';child-src child.owncloud.com";
$this->contentSecurityPolicy->addAllowedChildSrcDomain('child.owncloud.com');
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
public function testGetPolicyChildSrcValidMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self';child-src child.owncloud.com child.owncloud.org";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self';child-src child.owncloud.com child.owncloud.org";
$this->contentSecurityPolicy->addAllowedChildSrcDomain('child.owncloud.com');
$this->contentSecurityPolicy->addAllowedChildSrcDomain('child.owncloud.org');
@@ -404,7 +404,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowChildSrcDomain() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedChildSrcDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowChildSrcDomain('www.owncloud.com');
@@ -412,7 +412,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowChildSrcDomainMultiple() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self';child-src www.owncloud.com";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self';child-src www.owncloud.com";
$this->contentSecurityPolicy->addAllowedChildSrcDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowChildSrcDomain('www.owncloud.org');
@@ -420,7 +420,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testGetPolicyDisallowChildSrcDomainMultipleStakes() {
- $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expectedPolicy = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->contentSecurityPolicy->addAllowedChildSrcDomain('www.owncloud.com');
$this->contentSecurityPolicy->disallowChildSrcDomain('www.owncloud.org')->disallowChildSrcDomain('www.owncloud.com');
@@ -428,7 +428,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
}
public function testConfigureStacked() {
- $expectedPolicy = "default-src 'none';script-src 'self' script.owncloud.org;style-src 'self' style.owncloud.org;img-src 'self' img.owncloud.org;font-src 'self' font.owncloud.org;connect-src 'self' connect.owncloud.org;media-src 'self' media.owncloud.org;object-src objects.owncloud.org;frame-src frame.owncloud.org;child-src child.owncloud.org";
+ $expectedPolicy = "default-src 'none';script-src 'self' script.owncloud.org;style-src 'self' style.owncloud.org;img-src 'self' data: img.owncloud.org;font-src 'self' font.owncloud.org;connect-src 'self' connect.owncloud.org;media-src 'self' media.owncloud.org;object-src objects.owncloud.org;frame-src frame.owncloud.org;child-src child.owncloud.org";
$this->contentSecurityPolicy->allowInlineStyle(false)
->allowEvalScript(false)
diff --git a/tests/lib/appframework/http/DataResponseTest.php b/tests/lib/appframework/http/DataResponseTest.php
index ca0582e10e5..2b7817c28e9 100644
--- a/tests/lib/appframework/http/DataResponseTest.php
+++ b/tests/lib/appframework/http/DataResponseTest.php
@@ -68,7 +68,7 @@ class DataResponseTest extends \Test\TestCase {
$expectedHeaders = [
'Cache-Control' => 'no-cache, must-revalidate',
- 'Content-Security-Policy' => "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'",
+ 'Content-Security-Policy' => "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'",
];
$expectedHeaders = array_merge($expectedHeaders, $headers);
diff --git a/tests/lib/appframework/http/ResponseTest.php b/tests/lib/appframework/http/ResponseTest.php
index c8b79fbd8b6..61dd95e5948 100644
--- a/tests/lib/appframework/http/ResponseTest.php
+++ b/tests/lib/appframework/http/ResponseTest.php
@@ -58,7 +58,7 @@ class ResponseTest extends \Test\TestCase {
$this->childResponse->setHeaders($expected);
$headers = $this->childResponse->getHeaders();
- $expected['Content-Security-Policy'] = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self';connect-src 'self';media-src 'self'";
+ $expected['Content-Security-Policy'] = "default-src 'none';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data:;font-src 'self';connect-src 'self';media-src 'self'";
$this->assertEquals($expected, $headers);
}
diff --git a/tests/lib/appframework/routing/RoutingTest.php b/tests/lib/appframework/routing/RoutingTest.php
index 4ee3ed58807..51c191fdfb7 100644
--- a/tests/lib/appframework/routing/RoutingTest.php
+++ b/tests/lib/appframework/routing/RoutingTest.php
@@ -120,7 +120,8 @@ class RoutingTest extends \Test\TestCase
}
// route mocks
- $route = $this->mockRoute($verb, $controllerName, $actionName, $requirements, $defaults);
+ $container = new DIContainer('app1');
+ $route = $this->mockRoute($container, $verb, $controllerName, $actionName, $requirements, $defaults);
// router mock
$router = $this->getMock("\OC\Route\Router", array('create'));
@@ -133,7 +134,6 @@ class RoutingTest extends \Test\TestCase
->will($this->returnValue($route));
// load route configuration
- $container = new DIContainer('app1');
$config = new RouteConfig($container, $router, $routes);
$config->register();
@@ -151,11 +151,12 @@ class RoutingTest extends \Test\TestCase
$router = $this->getMock("\OC\Route\Router", array('create'));
// route mocks
- $indexRoute = $this->mockRoute('GET', $controllerName, 'index');
- $showRoute = $this->mockRoute('GET', $controllerName, 'show');
- $createRoute = $this->mockRoute('POST', $controllerName, 'create');
- $updateRoute = $this->mockRoute('PUT', $controllerName, 'update');
- $destroyRoute = $this->mockRoute('DELETE', $controllerName, 'destroy');
+ $container = new DIContainer('app1');
+ $indexRoute = $this->mockRoute($container, 'GET', $controllerName, 'index');
+ $showRoute = $this->mockRoute($container, 'GET', $controllerName, 'show');
+ $createRoute = $this->mockRoute($container, 'POST', $controllerName, 'create');
+ $updateRoute = $this->mockRoute($container, 'PUT', $controllerName, 'update');
+ $destroyRoute = $this->mockRoute($container, 'DELETE', $controllerName, 'destroy');
$urlWithParam = $url . '/{' . $paramName . '}';
@@ -191,21 +192,28 @@ class RoutingTest extends \Test\TestCase
->will($this->returnValue($destroyRoute));
// load route configuration
- $container = new DIContainer('app1');
$config = new RouteConfig($container, $router, $yaml);
$config->register();
}
/**
+ * @param DIContainer $container
* @param string $verb
* @param string $controllerName
* @param string $actionName
+ * @param array $requirements
+ * @param array $defaults
* @return \PHPUnit_Framework_MockObject_MockObject
*/
- private function mockRoute($verb, $controllerName, $actionName, array $requirements=array(), array $defaults=array())
- {
- $container = new DIContainer('app1');
+ private function mockRoute(
+ DIContainer $container,
+ $verb,
+ $controllerName,
+ $actionName,
+ array $requirements=array(),
+ array $defaults=array()
+ ) {
$route = $this->getMock("\OC\Route\Route", array('method', 'action', 'requirements', 'defaults'), array(), '', false);
$route
->expects($this->exactly(1))
diff --git a/tests/lib/appframework/utility/SimpleContainerTest.php b/tests/lib/appframework/utility/SimpleContainerTest.php
index 7ff579a85fc..8217749aed4 100644
--- a/tests/lib/appframework/utility/SimpleContainerTest.php
+++ b/tests/lib/appframework/utility/SimpleContainerTest.php
@@ -159,10 +159,15 @@ class SimpleContainerTest extends \Test\TestCase {
public function testRegisterAliasService() {
$this->container->registerService('test', function() {
- return 'abc';
- });
+ return new \StdClass;
+ }, true);
$this->container->registerAlias('test1', 'test');
- $this->assertEquals('abc', $this->container->query('test1'));
+ $this->assertSame(
+ $this->container->query('test'), $this->container->query('test'));
+ $this->assertSame(
+ $this->container->query('test1'), $this->container->query('test1'));
+ $this->assertSame(
+ $this->container->query('test'), $this->container->query('test1'));
}
/**
@@ -174,5 +179,25 @@ class SimpleContainerTest extends \Test\TestCase {
);
}
+ public function testRegisterFactory() {
+ $this->container->registerService('test', function() {
+ return new \StdClass();
+ }, false);
+ $this->assertNotSame(
+ $this->container->query('test'), $this->container->query('test'));
+ }
+
+ public function testRegisterAliasFactory() {
+ $this->container->registerService('test', function() {
+ return new \StdClass();
+ }, false);
+ $this->container->registerAlias('test1', 'test');
+ $this->assertNotSame(
+ $this->container->query('test'), $this->container->query('test'));
+ $this->assertNotSame(
+ $this->container->query('test1'), $this->container->query('test1'));
+ $this->assertNotSame(
+ $this->container->query('test'), $this->container->query('test1'));
+ }
}
diff --git a/tests/lib/capabilitiesmanager.php b/tests/lib/capabilitiesmanager.php
new file mode 100644
index 00000000000..b5dac80ee51
--- /dev/null
+++ b/tests/lib/capabilitiesmanager.php
@@ -0,0 +1,164 @@
+<?php
+/**
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace Test;
+
+use OC\CapabilitiesManager;
+
+class CapabilitiesManagerTest extends TestCase {
+
+ /**
+ * Test no capabilities
+ */
+ public function testNoCapabilities() {
+ $manager = new \OC\CapabilitiesManager();
+ $res = $manager->getCapabilities();
+ $this->assertEmpty($res);
+ }
+
+ /**
+ * Test a valid capabilitie
+ */
+ public function testValidCapability() {
+ $manager = new \OC\CapabilitiesManager();
+
+ $manager->registerCapability(function() {
+ return new SimpleCapability();
+ });
+
+ $res = $manager->getCapabilities();
+ $this->assertEquals(['foo' => 1], $res);
+ }
+
+ /**
+ * Test that we need something that implents ICapability
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage The given Capability (Test\NoCapability) does not implement the ICapability interface
+ */
+ public function testNoICapability() {
+ $manager = new \OC\CapabilitiesManager();
+
+ $manager->registerCapability(function() {
+ return new NoCapability();
+ });
+
+ $res = $manager->getCapabilities();
+ $this->assertEquals([], $res);
+ }
+
+ /**
+ * Test a bunch of merged Capabilities
+ */
+ public function testMergedCapabilities() {
+ $manager = new \OC\CapabilitiesManager();
+
+ $manager->registerCapability(function() {
+ return new SimpleCapability();
+ });
+ $manager->registerCapability(function() {
+ return new SimpleCapability2();
+ });
+ $manager->registerCapability(function() {
+ return new SimpleCapability3();
+ });
+
+ $res = $manager->getCapabilities();
+ $expected = [
+ 'foo' => 1,
+ 'bar' => [
+ 'x' => 1,
+ 'y' => 2
+ ]
+ ];
+
+ $this->assertEquals($expected, $res);
+ }
+
+ /**
+ * Test deep identical capabilities
+ */
+ public function testDeepIdenticalCapabilities() {
+ $manager = new \OC\CapabilitiesManager();
+
+ $manager->registerCapability(function() {
+ return new DeepCapability();
+ });
+ $manager->registerCapability(function() {
+ return new DeepCapability();
+ });
+
+ $res = $manager->getCapabilities();
+ $expected = [
+ 'foo' => [
+ 'bar' => [
+ 'baz' => true
+ ]
+ ]
+ ];
+
+ $this->assertEquals($expected, $res);
+ }
+}
+
+class SimpleCapability implements \OCP\Capabilities\ICapability {
+ public function getCapabilities() {
+ return [
+ 'foo' => 1
+ ];
+ }
+}
+
+class SimpleCapability2 implements \OCP\Capabilities\ICapability {
+ public function getCapabilities() {
+ return [
+ 'bar' => ['x' => 1]
+ ];
+ }
+}
+
+class SimpleCapability3 implements \OCP\Capabilities\ICapability {
+ public function getCapabilities() {
+ return [
+ 'bar' => ['y' => 2]
+ ];
+ }
+}
+
+class NoCapability {
+ public function getCapabilities() {
+ return [
+ 'baz' => 'z'
+ ];
+ }
+}
+
+class DeepCapability implements \OCP\Capabilities\ICapability {
+ public function getCapabilities() {
+ return [
+ 'foo' => [
+ 'bar' => [
+ 'baz' => true
+ ]
+ ]
+ ];
+ }
+}
+
diff --git a/tests/lib/db/querybuilder/querybuildertest.php b/tests/lib/db/querybuilder/querybuildertest.php
index 02e516b7386..75e62ba944e 100644
--- a/tests/lib/db/querybuilder/querybuildertest.php
+++ b/tests/lib/db/querybuilder/querybuildertest.php
@@ -253,8 +253,8 @@ class QueryBuilderTest extends \Test\TestCase {
public function dataDelete() {
return [
- ['data', null, ['table' => '`data`', 'alias' => null], '`data`'],
- ['data', 't', ['table' => '`data`', 'alias' => 't'], '`data` t'],
+ ['data', null, ['table' => '`*PREFIX*data`', 'alias' => null], '`*PREFIX*data`'],
+ ['data', 't', ['table' => '`*PREFIX*data`', 'alias' => 't'], '`*PREFIX*data` t'],
];
}
@@ -282,8 +282,8 @@ class QueryBuilderTest extends \Test\TestCase {
public function dataUpdate() {
return [
- ['data', null, ['table' => '`data`', 'alias' => null], '`data`'],
- ['data', 't', ['table' => '`data`', 'alias' => 't'], '`data` t'],
+ ['data', null, ['table' => '`*PREFIX*data`', 'alias' => null], '`*PREFIX*data`'],
+ ['data', 't', ['table' => '`*PREFIX*data`', 'alias' => 't'], '`*PREFIX*data` t'],
];
}
@@ -311,7 +311,7 @@ class QueryBuilderTest extends \Test\TestCase {
public function dataInsert() {
return [
- ['data', ['table' => '`data`'], '`data`'],
+ ['data', ['table' => '`*PREFIX*data`'], '`*PREFIX*data`'],
];
}
@@ -338,16 +338,16 @@ class QueryBuilderTest extends \Test\TestCase {
public function dataFrom() {
return [
- ['data', null, null, null, [['table' => '`data`', 'alias' => null]], '`data`'],
- ['data', 't', null, null, [['table' => '`data`', 'alias' => 't']], '`data` t'],
+ ['data', null, null, null, [['table' => '`*PREFIX*data`', 'alias' => null]], '`*PREFIX*data`'],
+ ['data', 't', null, null, [['table' => '`*PREFIX*data`', 'alias' => 't']], '`*PREFIX*data` t'],
['data1', null, 'data2', null, [
- ['table' => '`data1`', 'alias' => null],
- ['table' => '`data2`', 'alias' => null]
- ], '`data1`, `data2`'],
+ ['table' => '`*PREFIX*data1`', 'alias' => null],
+ ['table' => '`*PREFIX*data2`', 'alias' => null]
+ ], '`*PREFIX*data1`, `*PREFIX*data2`'],
['data', 't1', 'data', 't2', [
- ['table' => '`data`', 'alias' => 't1'],
- ['table' => '`data`', 'alias' => 't2']
- ], '`data` t1, `data` t2'],
+ ['table' => '`*PREFIX*data`', 'alias' => 't1'],
+ ['table' => '`*PREFIX*data`', 'alias' => 't2']
+ ], '`*PREFIX*data` t1, `*PREFIX*data` t2'],
];
}
@@ -382,18 +382,18 @@ class QueryBuilderTest extends \Test\TestCase {
return [
[
'd1', 'data2', null, null,
- ['d1' => [['joinType' => 'inner', 'joinTable' => '`data2`', 'joinAlias' => null, 'joinCondition' => null]]],
- '`data1` d1 INNER JOIN `data2` ON '
+ ['d1' => [['joinType' => 'inner', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => null, 'joinCondition' => null]]],
+ '`*PREFIX*data1` d1 INNER JOIN `*PREFIX*data2` ON '
],
[
'd1', 'data2', 'd2', null,
- ['d1' => [['joinType' => 'inner', 'joinTable' => '`data2`', 'joinAlias' => 'd2', 'joinCondition' => null]]],
- '`data1` d1 INNER JOIN `data2` d2 ON '
+ ['d1' => [['joinType' => 'inner', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => 'd2', 'joinCondition' => null]]],
+ '`*PREFIX*data1` d1 INNER JOIN `*PREFIX*data2` d2 ON '
],
[
'd1', 'data2', 'd2', 'd1.`field1` = d2.`field2`',
- ['d1' => [['joinType' => 'inner', 'joinTable' => '`data2`', 'joinAlias' => 'd2', 'joinCondition' => 'd1.`field1` = d2.`field2`']]],
- '`data1` d1 INNER JOIN `data2` d2 ON d1.`field1` = d2.`field2`'
+ ['d1' => [['joinType' => 'inner', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => 'd2', 'joinCondition' => 'd1.`field1` = d2.`field2`']]],
+ '`*PREFIX*data1` d1 INNER JOIN `*PREFIX*data2` d2 ON d1.`field1` = d2.`field2`'
],
];
@@ -463,18 +463,18 @@ class QueryBuilderTest extends \Test\TestCase {
return [
[
'd1', 'data2', null, null,
- ['d1' => [['joinType' => 'left', 'joinTable' => '`data2`', 'joinAlias' => null, 'joinCondition' => null]]],
- '`data1` d1 LEFT JOIN `data2` ON '
+ ['d1' => [['joinType' => 'left', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => null, 'joinCondition' => null]]],
+ '`*PREFIX*data1` d1 LEFT JOIN `*PREFIX*data2` ON '
],
[
'd1', 'data2', 'd2', null,
- ['d1' => [['joinType' => 'left', 'joinTable' => '`data2`', 'joinAlias' => 'd2', 'joinCondition' => null]]],
- '`data1` d1 LEFT JOIN `data2` d2 ON '
+ ['d1' => [['joinType' => 'left', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => 'd2', 'joinCondition' => null]]],
+ '`*PREFIX*data1` d1 LEFT JOIN `*PREFIX*data2` d2 ON '
],
[
'd1', 'data2', 'd2', 'd1.`field1` = d2.`field2`',
- ['d1' => [['joinType' => 'left', 'joinTable' => '`data2`', 'joinAlias' => 'd2', 'joinCondition' => 'd1.`field1` = d2.`field2`']]],
- '`data1` d1 LEFT JOIN `data2` d2 ON d1.`field1` = d2.`field2`'
+ ['d1' => [['joinType' => 'left', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => 'd2', 'joinCondition' => 'd1.`field1` = d2.`field2`']]],
+ '`*PREFIX*data1` d1 LEFT JOIN `*PREFIX*data2` d2 ON d1.`field1` = d2.`field2`'
],
];
}
@@ -513,18 +513,18 @@ class QueryBuilderTest extends \Test\TestCase {
return [
[
'd1', 'data2', null, null,
- ['d1' => [['joinType' => 'right', 'joinTable' => '`data2`', 'joinAlias' => null, 'joinCondition' => null]]],
- '`data1` d1 RIGHT JOIN `data2` ON '
+ ['d1' => [['joinType' => 'right', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => null, 'joinCondition' => null]]],
+ '`*PREFIX*data1` d1 RIGHT JOIN `*PREFIX*data2` ON '
],
[
'd1', 'data2', 'd2', null,
- ['d1' => [['joinType' => 'right', 'joinTable' => '`data2`', 'joinAlias' => 'd2', 'joinCondition' => null]]],
- '`data1` d1 RIGHT JOIN `data2` d2 ON '
+ ['d1' => [['joinType' => 'right', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => 'd2', 'joinCondition' => null]]],
+ '`*PREFIX*data1` d1 RIGHT JOIN `*PREFIX*data2` d2 ON '
],
[
'd1', 'data2', 'd2', 'd1.`field1` = d2.`field2`',
- ['d1' => [['joinType' => 'right', 'joinTable' => '`data2`', 'joinAlias' => 'd2', 'joinCondition' => 'd1.`field1` = d2.`field2`']]],
- '`data1` d1 RIGHT JOIN `data2` d2 ON d1.`field1` = d2.`field2`'
+ ['d1' => [['joinType' => 'right', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => 'd2', 'joinCondition' => 'd1.`field1` = d2.`field2`']]],
+ '`*PREFIX*data1` d1 RIGHT JOIN `*PREFIX*data2` d2 ON d1.`field1` = d2.`field2`'
],
];
}
@@ -591,7 +591,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
$this->assertSame(
- 'UPDATE `data` SET ' . $expectedQuery,
+ 'UPDATE `*PREFIX*data` SET ' . $expectedQuery,
$this->queryBuilder->getSQL()
);
}
@@ -774,7 +774,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
$this->assertSame(
- 'INSERT INTO `data` ' . $expectedQuery,
+ 'INSERT INTO `*PREFIX*data` ' . $expectedQuery,
$this->queryBuilder->getSQL()
);
}
@@ -799,7 +799,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
$this->assertSame(
- 'INSERT INTO `data` ' . $expectedQuery,
+ 'INSERT INTO `*PREFIX*data` ' . $expectedQuery,
$this->queryBuilder->getSQL()
);
}
@@ -996,4 +996,34 @@ class QueryBuilderTest extends \Test\TestCase {
$this->queryBuilder->getSQL()
);
}
+
+ public function dataGetTableName() {
+ return [
+ ['*PREFIX*table', null, '`*PREFIX*table`'],
+ ['*PREFIX*table', true, '`*PREFIX*table`'],
+ ['*PREFIX*table', false, '`*PREFIX*table`'],
+
+ ['table', null, '`*PREFIX*table`'],
+ ['table', true, '`*PREFIX*table`'],
+ ['table', false, '`table`'],
+ ];
+ }
+
+ /**
+ * @dataProvider dataGetTableName
+ *
+ * @param string $tableName
+ * @param bool $automatic
+ * @param string $expected
+ */
+ public function testGetTableName($tableName, $automatic, $expected) {
+ if ($automatic !== null) {
+ $this->queryBuilder->automaticTablePrefix($automatic);
+ }
+
+ $this->assertSame(
+ $expected,
+ $this->invokePrivate($this->queryBuilder, 'getTableName', [$tableName])
+ );
+ }
}
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index bf99a582117..bb42f385fc5 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -1386,7 +1386,9 @@ class View extends \Test\TestCase {
['/foo/files/bar', '/foo', true],
['/foo', '/foo', false],
['/foo', '/files/foo', true],
- ['/foo', 'filesfoo', false]
+ ['/foo', 'filesfoo', false],
+ ['', '/foo/files', true],
+ ['', '/foo/files/bar.txt', true]
];
}
diff --git a/tests/lib/repair/cleantags.php b/tests/lib/repair/cleantags.php
index 2f6d0879642..a511daa03d6 100644
--- a/tests/lib/repair/cleantags.php
+++ b/tests/lib/repair/cleantags.php
@@ -40,13 +40,13 @@ class CleanTags extends \Test\TestCase {
protected function cleanUpTables() {
$qb = $this->connection->getQueryBuilder();
- $qb->delete('*PREFIX*vcategory')
+ $qb->delete('vcategory')
->execute();
- $qb->delete('*PREFIX*vcategory_to_object')
+ $qb->delete('vcategory_to_object')
->execute();
- $qb->delete('*PREFIX*filecache')
+ $qb->delete('filecache')
->execute();
}
@@ -61,20 +61,20 @@ class CleanTags extends \Test\TestCase {
$this->addTagEntry(9999999, $cat3, 'contacts'); // Retained
$this->addTagEntry($this->getFileID(), $cat3 + 1, 'files'); // Deleted: Category is NULL
- $this->assertEntryCount('*PREFIX*vcategory_to_object', 4, 'Assert tag entries count before repair step');
- $this->assertEntryCount('*PREFIX*vcategory', 4, 'Assert tag categories count before repair step');
+ $this->assertEntryCount('vcategory_to_object', 4, 'Assert tag entries count before repair step');
+ $this->assertEntryCount('vcategory', 4, 'Assert tag categories count before repair step');
self::invokePrivate($this->repair, 'deleteOrphanFileEntries');
- $this->assertEntryCount('*PREFIX*vcategory_to_object', 3, 'Assert tag entries count after cleaning file entries');
- $this->assertEntryCount('*PREFIX*vcategory', 4, 'Assert tag categories count after cleaning file entries');
+ $this->assertEntryCount('vcategory_to_object', 3, 'Assert tag entries count after cleaning file entries');
+ $this->assertEntryCount('vcategory', 4, 'Assert tag categories count after cleaning file entries');
self::invokePrivate($this->repair, 'deleteOrphanTagEntries');
- $this->assertEntryCount('*PREFIX*vcategory_to_object', 2, 'Assert tag entries count after cleaning tag entries');
- $this->assertEntryCount('*PREFIX*vcategory', 4, 'Assert tag categories count after cleaning tag entries');
+ $this->assertEntryCount('vcategory_to_object', 2, 'Assert tag entries count after cleaning tag entries');
+ $this->assertEntryCount('vcategory', 4, 'Assert tag categories count after cleaning tag entries');
self::invokePrivate($this->repair, 'deleteOrphanCategoryEntries');
- $this->assertEntryCount('*PREFIX*vcategory_to_object', 2, 'Assert tag entries count after cleaning category entries');
- $this->assertEntryCount('*PREFIX*vcategory', 2, 'Assert tag categories count after cleaning category entries');
+ $this->assertEntryCount('vcategory_to_object', 2, 'Assert tag entries count after cleaning category entries');
+ $this->assertEntryCount('vcategory', 2, 'Assert tag categories count after cleaning category entries');
}
/**
@@ -100,7 +100,7 @@ class CleanTags extends \Test\TestCase {
*/
protected function addTagCategory($category, $type) {
$qb = $this->connection->getQueryBuilder();
- $qb->insert('*PREFIX*vcategory')
+ $qb->insert('vcategory')
->values([
'uid' => $qb->createNamedParameter('TestRepairCleanTags'),
'category' => $qb->createNamedParameter($category),
@@ -108,7 +108,7 @@ class CleanTags extends \Test\TestCase {
])
->execute();
- return (int) $this->getLastInsertID('*PREFIX*vcategory', 'id');
+ return (int) $this->getLastInsertID('vcategory', 'id');
}
/**
@@ -119,7 +119,7 @@ class CleanTags extends \Test\TestCase {
*/
protected function addTagEntry($objectId, $category, $type) {
$qb = $this->connection->getQueryBuilder();
- $qb->insert('*PREFIX*vcategory_to_object')
+ $qb->insert('vcategory_to_object')
->values([
'objid' => $qb->createNamedParameter($objectId, \PDO::PARAM_INT),
'categoryid' => $qb->createNamedParameter($category, \PDO::PARAM_INT),
@@ -141,21 +141,21 @@ class CleanTags extends \Test\TestCase {
// We create a new file entry and delete it after the test again
$fileName = $this->getUniqueID('TestRepairCleanTags', 12);
- $qb->insert('*PREFIX*filecache')
+ $qb->insert('filecache')
->values([
'path' => $qb->createNamedParameter($fileName),
'path_hash' => $qb->createNamedParameter(md5($fileName)),
])
->execute();
$fileName = $this->getUniqueID('TestRepairCleanTags', 12);
- $qb->insert('*PREFIX*filecache')
+ $qb->insert('filecache')
->values([
'path' => $qb->createNamedParameter($fileName),
'path_hash' => $qb->createNamedParameter(md5($fileName)),
])
->execute();
- $this->createdFile = (int) $this->getLastInsertID('*PREFIX*filecache', 'fileid');
+ $this->createdFile = (int) $this->getLastInsertID('filecache', 'fileid');
return $this->createdFile;
}
diff --git a/tests/lib/server.php b/tests/lib/server.php
index cf0ad8265bf..9c5c83ceb5c 100644
--- a/tests/lib/server.php
+++ b/tests/lib/server.php
@@ -1,6 +1,9 @@
<?php
/**
* @author Joas Schilling <nickvergessen@owncloud.com>
+ * @author Lukas Reschke <lukas@owncloud.com>
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ * @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
@@ -48,6 +51,7 @@ class Server extends \Test\TestCase {
['AvatarManager', '\OC\AvatarManager'],
['AvatarManager', '\OCP\IAvatarManager'],
+ ['CapabilitiesManager', '\OC\CapabilitiesManager'],
['ContactsManager', '\OC\ContactsManager'],
['ContactsManager', '\OCP\Contacts\IManager'],
['Crypto', '\OC\Security\Crypto'],
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index b6d3e16826d..ef0d9822085 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -1288,7 +1288,7 @@ class Test_Share extends \Test\TestCase {
// Find the share ID in the db
$qb = $connection->getQueryBuilder();
$qb->select('id')
- ->from('*PREFIX*share')
+ ->from('share')
->where($qb->expr()->eq('item_type', $qb->createParameter('type')))
->andWhere($qb->expr()->eq('item_source', $qb->createParameter('source')))
->andWhere($qb->expr()->eq('uid_owner', $qb->createParameter('owner')))
@@ -1309,7 +1309,7 @@ class Test_Share extends \Test\TestCase {
// Fetch the hash from the database
$qb = $connection->getQueryBuilder();
$qb->select('share_with')
- ->from('*PREFIX*share')
+ ->from('share')
->where($qb->expr()->eq('id', $qb->createParameter('id')))
->setParameter('id', $id);
$hash = $qb->execute()->fetch()['share_with'];
diff --git a/tests/settings/controller/CheckSetupControllerTest.php b/tests/settings/controller/CheckSetupControllerTest.php
index 6096aae8652..414b1b91e17 100644
--- a/tests/settings/controller/CheckSetupControllerTest.php
+++ b/tests/settings/controller/CheckSetupControllerTest.php
@@ -31,11 +31,24 @@ use OC_Util;
use Test\TestCase;
/**
+ * Mock version_compare
+ * @param string $version1
+ * @param string $version2
+ * @return int
+ */
+function version_compare($version1, $version2) {
+ return CheckSetupControllerTest::$version_compare;
+}
+
+/**
* Class CheckSetupControllerTest
*
* @package OC\Settings\Controller
*/
class CheckSetupControllerTest extends TestCase {
+ /** @var int */
+ public static $version_compare;
+
/** @var CheckSetupController */
private $checkSetupController;
/** @var IRequest */
@@ -209,6 +222,66 @@ class CheckSetupControllerTest extends TestCase {
);
}
+ public function testIsPhpSupportedFalse() {
+ self::$version_compare = -1;
+
+ $this->assertEquals(
+ ['eol' => true, 'version' => PHP_VERSION],
+ self::invokePrivate($this->checkSetupController, 'isPhpSupported')
+ );
+ }
+
+ public function testIsPhpSupportedTrue() {
+ self::$version_compare = 0;
+
+ $this->assertEquals(
+ ['eol' => false, 'version' => PHP_VERSION],
+ self::invokePrivate($this->checkSetupController, 'isPhpSupported')
+ );
+
+
+ self::$version_compare = 1;
+
+ $this->assertEquals(
+ ['eol' => false, 'version' => PHP_VERSION],
+ self::invokePrivate($this->checkSetupController, 'isPhpSupported')
+ );
+ }
+
+ public function testForwardedForHeadersWorkingFalse() {
+ $this->config->expects($this->once())
+ ->method('getSystemValue')
+ ->with('trusted_proxies', [])
+ ->willReturn(['1.2.3.4']);
+ $this->request->expects($this->once())
+ ->method('getRemoteAddress')
+ ->willReturn('1.2.3.4');
+
+ $this->assertFalse(
+ self::invokePrivate(
+ $this->checkSetupController,
+ 'forwardedForHeadersWorking'
+ )
+ );
+ }
+
+ public function testForwardedForHeadersWorkingTrue() {
+ $this->config->expects($this->once())
+ ->method('getSystemValue')
+ ->with('trusted_proxies', [])
+ ->willReturn(['1.2.3.4']);
+ $this->request->expects($this->once())
+ ->method('getRemoteAddress')
+ ->willReturn('4.3.2.1');
+
+ $this->assertTrue(
+ self::invokePrivate(
+ $this->checkSetupController,
+ 'forwardedForHeadersWorking'
+ )
+ );
+ }
+
public function testCheck() {
$this->config->expects($this->at(0))
->method('getSystemValue')
@@ -218,6 +291,14 @@ class CheckSetupControllerTest extends TestCase {
->method('getSystemValue')
->with('memcache.local', null)
->will($this->returnValue('SomeProvider'));
+ $this->config->expects($this->at(2))
+ ->method('getSystemValue')
+ ->with('trusted_proxies', [])
+ ->willReturn(['1.2.3.4']);
+
+ $this->request->expects($this->once())
+ ->method('getRemoteAddress')
+ ->willReturn('4.3.2.1');
$client = $this->getMockBuilder('\OCP\Http\Client\IClient')
->disableOriginalConstructor()->getMock();
@@ -244,6 +325,11 @@ class CheckSetupControllerTest extends TestCase {
->method('linkToDocs')
->with('admin-security')
->willReturn('https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html');
+ self::$version_compare = -1;
+ $this->urlGenerator->expects($this->at(2))
+ ->method('linkToDocs')
+ ->with('admin-reverse-proxy')
+ ->willReturn('reverse-proxy-doc-link');
$expected = new DataResponse(
[
@@ -254,6 +340,12 @@ class CheckSetupControllerTest extends TestCase {
'isUrandomAvailable' => self::invokePrivate($this->checkSetupController, 'isUrandomAvailable'),
'securityDocs' => 'https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html',
'isUsedTlsLibOutdated' => '',
+ 'phpSupported' => [
+ 'eol' => true,
+ 'version' => PHP_VERSION
+ ],
+ 'forwardedForHeadersWorking' => true,
+ 'reverseProxyDocs' => 'reverse-proxy-doc-link',
]
);
$this->assertEquals($expected, $this->checkSetupController->check());