summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-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/RequestTest.php87
-rw-r--r--tests/lib/appframework/http/ResponseTest.php2
-rw-r--r--tests/lib/files/storage/wrapper/encryption.php23
-rw-r--r--tests/lib/files/view.php131
-rw-r--r--tests/lib/l10n.php6
-rw-r--r--tests/lib/preview.php119
-rw-r--r--tests/lib/repair/repairinvalidsharestest.php123
-rw-r--r--tests/lib/repair/repairmimetypes.php83
-rw-r--r--tests/lib/util.php4
12 files changed, 544 insertions, 144 deletions
diff --git a/tests/lib/appframework/controller/ControllerTest.php b/tests/lib/appframework/controller/ControllerTest.php
index 243014a91a7..c847525c263 100644
--- a/tests/lib/appframework/controller/ControllerTest.php
+++ b/tests/lib/appframework/controller/ControllerTest.php
@@ -178,7 +178,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' data:;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: blob:;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 082c032a420..6d9c6d7b8d9 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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data: 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: blob: 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' data: 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: blob: 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' data:;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: blob:;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' data: 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: blob: 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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' data:;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: blob:;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' 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";
+ $expectedPolicy = "default-src 'none';script-src 'self' script.owncloud.org;style-src 'self' style.owncloud.org;img-src 'self' data: blob: 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 2b7817c28e9..e3d5689d54c 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' data:;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: blob:;font-src 'self';connect-src 'self';media-src 'self'",
];
$expectedHeaders = array_merge($expectedHeaders, $headers);
diff --git a/tests/lib/appframework/http/RequestTest.php b/tests/lib/appframework/http/RequestTest.php
index deb28909869..e9a0755d1f8 100644
--- a/tests/lib/appframework/http/RequestTest.php
+++ b/tests/lib/appframework/http/RequestTest.php
@@ -60,18 +60,18 @@ class RequestTest extends \Test\TestCase {
);
// Countable
- $this->assertEquals(2, count($request));
+ $this->assertSame(2, count($request));
// Array access
- $this->assertEquals('Joey', $request['nickname']);
+ $this->assertSame('Joey', $request['nickname']);
// "Magic" accessors
- $this->assertEquals('Joey', $request->{'nickname'});
+ $this->assertSame('Joey', $request->{'nickname'});
$this->assertTrue(isset($request['nickname']));
$this->assertTrue(isset($request->{'nickname'}));
- $this->assertEquals(false, isset($request->{'flickname'}));
+ $this->assertFalse(isset($request->{'flickname'}));
// Only testing 'get', but same approach for post, files etc.
- $this->assertEquals('Joey', $request->get['nickname']);
+ $this->assertSame('Joey', $request->get['nickname']);
// Always returns null if variable not set.
- $this->assertEquals(null, $request->{'flickname'});
+ $this->assertSame(null, $request->{'flickname'});
}
@@ -92,9 +92,9 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals(3, count($request));
- $this->assertEquals('Janey', $request->{'nickname'});
- $this->assertEquals('Johnny Weissmüller', $request->{'name'});
+ $this->assertSame(3, count($request));
+ $this->assertSame('Janey', $request->{'nickname'});
+ $this->assertSame('Johnny Weissmüller', $request->{'name'});
}
@@ -172,10 +172,10 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('GET', $request->method);
+ $this->assertSame('GET', $request->method);
$result = $request->get;
- $this->assertEquals('John Q. Public', $result['name']);
- $this->assertEquals('Joey', $result['nickname']);
+ $this->assertSame('John Q. Public', $result['name']);
+ $this->assertSame('Joey', $result['nickname']);
}
public function testJsonPost() {
@@ -194,12 +194,12 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('POST', $request->method);
+ $this->assertSame('POST', $request->method);
$result = $request->post;
- $this->assertEquals('John Q. Public', $result['name']);
- $this->assertEquals('Joey', $result['nickname']);
- $this->assertEquals('Joey', $request->params['nickname']);
- $this->assertEquals('Joey', $request['nickname']);
+ $this->assertSame('John Q. Public', $result['name']);
+ $this->assertSame('Joey', $result['nickname']);
+ $this->assertSame('Joey', $request->params['nickname']);
+ $this->assertSame('Joey', $request['nickname']);
}
public function testPatch() {
@@ -219,11 +219,11 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('PATCH', $request->method);
+ $this->assertSame('PATCH', $request->method);
$result = $request->patch;
- $this->assertEquals('John Q. Public', $result['name']);
- $this->assertEquals('Joey', $result['nickname']);
+ $this->assertSame('John Q. Public', $result['name']);
+ $this->assertSame('Joey', $result['nickname']);
}
public function testJsonPatchAndPut() {
@@ -244,11 +244,11 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('PUT', $request->method);
+ $this->assertSame('PUT', $request->method);
$result = $request->put;
- $this->assertEquals('John Q. Public', $result['name']);
- $this->assertEquals('Joey', $result['nickname']);
+ $this->assertSame('John Q. Public', $result['name']);
+ $this->assertSame('Joey', $result['nickname']);
// PATCH content
$data = '{"name": "John Q. Public", "nickname": null}';
@@ -265,11 +265,11 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('PATCH', $request->method);
+ $this->assertSame('PATCH', $request->method);
$result = $request->patch;
- $this->assertEquals('John Q. Public', $result['name']);
- $this->assertEquals(null, $result['nickname']);
+ $this->assertSame('John Q. Public', $result['name']);
+ $this->assertSame(null, $result['nickname']);
}
public function testPutStream() {
@@ -290,10 +290,10 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('PUT', $request->method);
+ $this->assertSame('PUT', $request->method);
$resource = $request->put;
$contents = stream_get_contents($resource);
- $this->assertEquals($data, $contents);
+ $this->assertSame($data, $contents);
try {
$resource = $request->put;
@@ -322,7 +322,7 @@ class RequestTest extends \Test\TestCase {
$newParams = array('id' => '3', 'test' => 'test2');
$request->setUrlParameters($newParams);
- $this->assertEquals('test2', $request->getParam('test'));
+ $this->assertSame('test2', $request->getParam('test'));
$this->assertEquals('3', $request->getParam('id'));
$this->assertEquals('3', $request->getParams()['id']);
}
@@ -660,7 +660,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals($matches, $request->isUserAgent($userAgent));
+ $this->assertSame($matches, $request->isUserAgent($userAgent));
}
/**
@@ -749,7 +749,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('from.server.name:8080', $request->getInsecureServerHost());
+ $this->assertSame('from.server.name:8080', $request->getInsecureServerHost());
}
public function testInsecureServerHostHttpHostHeader() {
@@ -766,7 +766,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('from.host.header:8080', $request->getInsecureServerHost());
+ $this->assertSame('from.host.header:8080', $request->getInsecureServerHost());
}
public function testInsecureServerHostHttpFromForwardedHeaderSingle() {
@@ -784,7 +784,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('from.forwarded.host:8080', $request->getInsecureServerHost());
+ $this->assertSame('from.forwarded.host:8080', $request->getInsecureServerHost());
}
public function testInsecureServerHostHttpFromForwardedHeaderStacked() {
@@ -802,7 +802,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('from.forwarded.host2:8080', $request->getInsecureServerHost());
+ $this->assertSame('from.forwarded.host2:8080', $request->getInsecureServerHost());
}
public function testGetServerHostWithOverwriteHost() {
@@ -830,7 +830,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('my.overwritten.host', $request->getServerHost());
+ $this->assertSame('my.overwritten.host', $request->getServerHost());
}
public function testGetServerHostWithTrustedDomain() {
@@ -852,7 +852,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('my.trusted.host', $request->getServerHost());
+ $this->assertSame('my.trusted.host', $request->getServerHost());
}
public function testGetServerHostWithUntrustedDomain() {
@@ -879,7 +879,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('my.trusted.host', $request->getServerHost());
+ $this->assertSame('my.trusted.host', $request->getServerHost());
}
public function testGetServerHostWithNoTrustedDomain() {
@@ -906,7 +906,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('', $request->getServerHost());
+ $this->assertSame('', $request->getServerHost());
}
public function testGetOverwriteHostDefaultNull() {
@@ -967,7 +967,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals('apps/files/', $request->getPathInfo());
+ $this->assertSame('apps/files/', $request->getPathInfo());
}
/**
@@ -1032,7 +1032,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals($expected, $request->getPathInfo());
+ $this->assertSame($expected, $request->getPathInfo());
}
/**
@@ -1055,7 +1055,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals($expected, $request->getRawPathInfo());
+ $this->assertSame($expected, $request->getRawPathInfo());
}
/**
@@ -1078,7 +1078,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals($expected, $request->getRawPathInfo());
+ $this->assertSame($expected, $request->getRawPathInfo());
}
/**
@@ -1101,7 +1101,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertEquals($expected, $request->getPathInfo());
+ $this->assertSame($expected, $request->getPathInfo());
}
/**
@@ -1109,6 +1109,7 @@ class RequestTest extends \Test\TestCase {
*/
public function genericPathInfoProvider() {
return [
+ ['/core/index.php?XDEBUG_SESSION_START=14600', '/core/index.php', ''],
['/index.php/apps/files/', 'index.php', '/apps/files/'],
['/index.php/apps/files/../&/&?someQueryParameter=QueryParam', 'index.php', '/apps/files/../&/&'],
['/remote.php/漢字編碼方法 / 汉字编码方法', 'remote.php', '/漢字編碼方法 / 汉字编码方法'],
diff --git a/tests/lib/appframework/http/ResponseTest.php b/tests/lib/appframework/http/ResponseTest.php
index 61dd95e5948..f845f02d984 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' data:;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: blob:;font-src 'self';connect-src 'self';media-src 'self'";
$this->assertEquals($expected, $headers);
}
diff --git a/tests/lib/files/storage/wrapper/encryption.php b/tests/lib/files/storage/wrapper/encryption.php
index 44e910b901f..095405462df 100644
--- a/tests/lib/files/storage/wrapper/encryption.php
+++ b/tests/lib/files/storage/wrapper/encryption.php
@@ -558,4 +558,27 @@ class Encryption extends \Test\Files\Storage\Storage {
$this->assertFalse(false);
}
+
+ /**
+ * @dataProvider dataTestIsVersion
+ * @param string $path
+ * @param bool $expected
+ */
+ public function testIsVersion($path, $expected) {
+ $this->assertSame($expected,
+ $this->invokePrivate($this->instance, 'isVersion', [$path])
+ );
+ }
+
+ public function dataTestIsVersion() {
+ return [
+ ['files_versions/foo', true],
+ ['/files_versions/foo', true],
+ ['//files_versions/foo', true],
+ ['files/versions/foo', false],
+ ['files/files_versions/foo', false],
+ ['files_versions_test/foo', false],
+ ];
+ }
+
}
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index ceeb9ba7a94..94f9e209152 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -104,6 +104,9 @@ class View extends \Test\TestCase {
$this->userObject->delete();
$this->groupObject->delete();
+ $mountProviderCollection = \OC::$server->getMountProviderCollection();
+ \Test\TestCase::invokePrivate($mountProviderCollection, 'providers', [[]]);
+
parent::tearDown();
}
@@ -1486,6 +1489,112 @@ class View extends \Test\TestCase {
$this->assertEquals($shouldEmit, $result);
}
+ /**
+ * Create test movable mount points
+ *
+ * @param array $mountPoints array of mount point locations
+ * @return array array of MountPoint objects
+ */
+ private function createTestMovableMountPoints($mountPoints) {
+ $mounts = [];
+ foreach ($mountPoints as $mountPoint) {
+ $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
+ ->setMethods([])
+ ->getMock();
+
+ $mounts[] = $this->getMock(
+ '\Test\TestMoveableMountPoint',
+ ['moveMount'],
+ [$storage, $mountPoint]
+ );
+ }
+
+ $mountProvider = $this->getMock('\OCP\Files\Config\IMountProvider');
+ $mountProvider->expects($this->any())
+ ->method('getMountsForUser')
+ ->will($this->returnValue($mounts));
+
+ $mountProviderCollection = \OC::$server->getMountProviderCollection();
+ $mountProviderCollection->registerProvider($mountProvider);
+
+ return $mounts;
+ }
+
+ /**
+ * Test mount point move
+ */
+ public function testMountPointMove() {
+ $this->loginAsUser($this->user);
+
+ list($mount1, $mount2) = $this->createTestMovableMountPoints([
+ $this->user . '/files/mount1',
+ $this->user . '/files/mount2',
+ ]);
+ $mount1->expects($this->once())
+ ->method('moveMount')
+ ->will($this->returnValue(true));
+
+ $mount2->expects($this->once())
+ ->method('moveMount')
+ ->will($this->returnValue(true));
+
+ $view = new \OC\Files\View('/' . $this->user . '/files/');
+ $view->mkdir('sub');
+
+ $this->assertTrue($view->rename('mount1', 'renamed_mount'), 'Can rename mount point');
+ $this->assertTrue($view->rename('mount2', 'sub/moved_mount'), 'Can move a mount point into a subdirectory');
+ }
+ /**
+ * Test that moving a mount point into another is forbidden
+ */
+ public function testMoveMountPointIntoAnother() {
+ $this->loginAsUser($this->user);
+
+ list($mount1, $mount2) = $this->createTestMovableMountPoints([
+ $this->user . '/files/mount1',
+ $this->user . '/files/mount2',
+ ]);
+
+ $mount1->expects($this->never())
+ ->method('moveMount');
+
+ $mount2->expects($this->never())
+ ->method('moveMount');
+
+ $view = new \OC\Files\View('/' . $this->user . '/files/');
+
+ $this->assertFalse($view->rename('mount1', 'mount2'), 'Cannot overwrite another mount point');
+ $this->assertFalse($view->rename('mount1', 'mount2/sub'), 'Cannot move a mount point into another');
+ }
+ /**
+ * Test that moving a mount point into a shared folder is forbidden
+ */
+ public function testMoveMountPointIntoSharedFolder() {
+ $this->loginAsUser($this->user);
+
+ list($mount1) = $this->createTestMovableMountPoints([
+ $this->user . '/files/mount1',
+ ]);
+
+ $mount1->expects($this->never())
+ ->method('moveMount');
+
+ $view = new \OC\Files\View('/' . $this->user . '/files/');
+ $view->mkdir('shareddir');
+ $view->mkdir('shareddir/sub');
+ $view->mkdir('shareddir/sub2');
+
+ $fileId = $view->getFileInfo('shareddir')->getId();
+ $userObject = \OC::$server->getUserManager()->createUser('test2', 'IHateNonMockableStaticClasses');
+ $this->assertTrue(\OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, 'test2', \OCP\Constants::PERMISSION_READ));
+
+ $this->assertFalse($view->rename('mount1', 'shareddir'), 'Cannot overwrite shared folder');
+ $this->assertFalse($view->rename('mount1', 'shareddir/sub'), 'Cannot move mount point into shared folder');
+ $this->assertFalse($view->rename('mount1', 'shareddir/sub/sub2'), 'Cannot move mount point into shared subfolder');
+
+ $this->assertTrue(\OCP\Share::unshare('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, 'test2'));
+ $userObject->delete();
+ }
public function basicOperationProviderForLocks() {
return [
@@ -2042,23 +2151,9 @@ class View extends \Test\TestCase {
public function testLockMoveMountPoint() {
$this->loginAsUser('test');
- $subStorage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
- ->setMethods([])
- ->getMock();
-
- $mount = $this->getMock(
- '\Test\TestMoveableMountPoint',
- ['moveMount'],
- [$subStorage, $this->user . '/files/substorage']
- );
-
- $mountProvider = $this->getMock('\OCP\Files\Config\IMountProvider');
- $mountProvider->expects($this->once())
- ->method('getMountsForUser')
- ->will($this->returnValue([$mount]));
-
- $mountProviderCollection = \OC::$server->getMountProviderCollection();
- $mountProviderCollection->registerProvider($mountProvider);
+ list($mount) = $this->createTestMovableMountPoints([
+ $this->user . '/files/substorage',
+ ]);
$view = new \OC\Files\View('/' . $this->user . '/files/');
$view->mkdir('subdir');
@@ -2109,8 +2204,6 @@ class View extends \Test\TestCase {
$this->assertNull($this->getFileLockType($view, $sourcePath, false), 'Shared storage root not locked after operation');
$this->assertNull($this->getFileLockType($view, $sourcePath, true), 'Source path not locked after operation');
$this->assertNull($this->getFileLockType($view, $targetPath, true), 'Target path not locked after operation');
-
- \Test\TestCase::invokePrivate($mountProviderCollection, 'providers', [[]]);
}
/**
diff --git a/tests/lib/l10n.php b/tests/lib/l10n.php
index d5f9a5ca3fa..cb2f4179c4d 100644
--- a/tests/lib/l10n.php
+++ b/tests/lib/l10n.php
@@ -92,8 +92,7 @@ class Test_L10n extends \Test\TestCase {
* @dataProvider localizationDataProvider
*/
public function testNumericStringLocalization($expectedDate, $lang, $type, $value) {
- $l = new OC_L10N('test');
- $l->forceLanguage($lang);
+ $l = new OC_L10N('test', $lang);
$this->assertSame($expectedDate, $l->l($type, $value));
}
@@ -110,8 +109,7 @@ class Test_L10n extends \Test\TestCase {
* @param $lang
*/
public function testFirstWeekDay($expected, $lang) {
- $l = new OC_L10N('test');
- $l->forceLanguage($lang);
+ $l = new OC_L10N('test', $lang);
$this->assertSame($expected, $l->l('firstday', 'firstday'));
}
diff --git a/tests/lib/preview.php b/tests/lib/preview.php
index 9e118014bac..e4c599c66cf 100644
--- a/tests/lib/preview.php
+++ b/tests/lib/preview.php
@@ -22,7 +22,15 @@
namespace Test;
+use OC\Files\FileInfo;
+use OC\Files\Storage\Temporary;
+use OC\Files\View;
+use Test\Traits\MountProviderTrait;
+use Test\Traits\UserTrait;
+
class Preview extends TestCase {
+ use UserTrait;
+ use MountProviderTrait;
const TEST_PREVIEW_USER1 = "test-preview-user1";
@@ -59,11 +67,7 @@ class Preview extends TestCase {
protected function setUp() {
parent::setUp();
- $userManager = \OC::$server->getUserManager();
- $userManager->clearBackends();
- $backend = new \Test\Util\User\Dummy();
- $userManager->registerBackend($backend);
- $backend->createUser(self::TEST_PREVIEW_USER1, self::TEST_PREVIEW_USER1);
+ $this->createUser(self::TEST_PREVIEW_USER1, self::TEST_PREVIEW_USER1);
$this->loginAsUser(self::TEST_PREVIEW_USER1);
$storage = new \OC\Files\Storage\Temporary([]);
@@ -75,13 +79,13 @@ class Preview extends TestCase {
// We simulate the max dimension set in the config
\OC::$server->getConfig()
- ->setSystemValue('preview_max_x', $this->configMaxWidth);
+ ->setSystemValue('preview_max_x', $this->configMaxWidth);
\OC::$server->getConfig()
- ->setSystemValue('preview_max_y', $this->configMaxHeight);
+ ->setSystemValue('preview_max_y', $this->configMaxHeight);
// Used to test upscaling
$this->maxScaleFactor = 2;
\OC::$server->getConfig()
- ->setSystemValue('preview_max_scale_factor', $this->maxScaleFactor);
+ ->setSystemValue('preview_max_scale_factor', $this->maxScaleFactor);
// We need to enable the providers we're going to use in the tests
$providers = [
@@ -92,7 +96,7 @@ class Preview extends TestCase {
'OC\\Preview\\Postscript'
];
\OC::$server->getConfig()
- ->setSystemValue('enabledPreviewProviders', $providers);
+ ->setSystemValue('enabledPreviewProviders', $providers);
// Sample is 1680x1050 JPEG
$this->prepareSample('testimage.jpg', 1680, 1050);
@@ -161,7 +165,7 @@ class Preview extends TestCase {
$fileId = $fileInfo['fileid'];
$thumbCacheFolder = '/' . self::TEST_PREVIEW_USER1 . '/' . \OC\Preview::THUMBNAILS_FOLDER .
- '/' . $fileId . '/';
+ '/' . $fileId . '/';
$this->assertSame(true, $this->rootView->is_dir($thumbCacheFolder), "$thumbCacheFolder \n");
@@ -318,7 +322,7 @@ class Preview extends TestCase {
// There should be no cached thumbnails
$thumbnailFolder = '/' . self::TEST_PREVIEW_USER1 . '/' . \OC\Preview::THUMBNAILS_FOLDER .
- '/' . $sampleFileId;
+ '/' . $sampleFileId;
$this->assertSame(false, $this->rootView->is_dir($thumbnailFolder));
$image = $preview->getPreview();
@@ -534,10 +538,10 @@ class Preview extends TestCase {
// Small thumbnails are always cropped
$this->keepAspect = false;
// Smaller previews should be based on the previous, larger preview, with the correct aspect ratio
- $this->createThumbnailFromBiggerCachedPreview($fileId, 36, 36);
+ $this->createThumbnailFromBiggerCachedPreview($fileId, 32, 32);
// 2nd cache query should indicate that we have a cached copy of the exact dimension
- $this->getCachedSmallThumbnail($fileId, 36, 36);
+ $this->getCachedSmallThumbnail($fileId, 32, 32);
// We create a preview in order to be able to delete the cache
$preview = $this->createPreview(rand(), rand());
@@ -611,7 +615,7 @@ class Preview extends TestCase {
// Need to take care of special postfix added to the dimensions
$postfix = '';
$isMaxPreview = ($width === $this->maxPreviewWidth
- && $height === $this->maxPreviewHeight) ? true : false;
+ && $height === $this->maxPreviewHeight) ? true : false;
if ($isMaxPreview) {
$postfix = '-max';
}
@@ -731,7 +735,7 @@ class Preview extends TestCase {
}
return $userPath . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId
- . '/' . $width . '-' . $height . $postfix . '.png';
+ . '/' . $width . '-' . $height . $postfix . '.png';
}
/**
@@ -752,11 +756,11 @@ class Preview extends TestCase {
$this->samples[] =
[
- 'sampleFileId' => $fileInfo['fileid'],
- 'sampleFileName' => $fileName,
- 'sampleWidth' => $sampleWidth,
- 'sampleHeight' => $sampleHeight,
- 'maxPreviewWidth' => $maxPreviewWidth,
+ 'sampleFileId' => $fileInfo['fileid'],
+ 'sampleFileName' => $fileName,
+ 'sampleWidth' => $sampleWidth,
+ 'sampleHeight' => $sampleHeight,
+ 'maxPreviewWidth' => $maxPreviewWidth,
'maxPreviewHeight' => $maxPreviewHeight
];
}
@@ -874,4 +878,79 @@ class Preview extends TestCase {
return [(int)$askedWidth, (int)$askedHeight];
}
+
+ public function testKeepAspectRatio() {
+ $originalWidth = 1680;
+ $originalHeight = 1050;
+ $originalAspectRation = $originalWidth / $originalHeight;
+
+ $preview = new \OC\Preview(
+ self::TEST_PREVIEW_USER1, 'files/', 'testimage.jpg',
+ 150,
+ 150
+ );
+ $preview->setKeepAspect(true);
+ $image = $preview->getPreview();
+
+ $aspectRatio = $image->width() / $image->height();
+ $this->assertEquals(round($originalAspectRation, 2), round($aspectRatio, 2));
+
+ $this->assertLessThanOrEqual(150, $image->width());
+ $this->assertLessThanOrEqual(150, $image->height());
+ }
+
+ public function testKeepAspectRatioCover() {
+ $originalWidth = 1680;
+ $originalHeight = 1050;
+ $originalAspectRation = $originalWidth / $originalHeight;
+
+ $preview = new \OC\Preview(
+ self::TEST_PREVIEW_USER1, 'files/', 'testimage.jpg',
+ 150,
+ 150
+ );
+ $preview->setKeepAspect(true);
+ $preview->setMode(\OC\Preview::MODE_COVER);
+ $image = $preview->getPreview();
+
+ $aspectRatio = $image->width() / $image->height();
+ $this->assertEquals(round($originalAspectRation, 2), round($aspectRatio, 2));
+
+ $this->assertGreaterThanOrEqual(150, $image->width());
+ $this->assertGreaterThanOrEqual(150, $image->height());
+ }
+
+ public function testSetFileWithInfo() {
+ $info = new FileInfo('/foo', null, '/foo', ['mimetype' => 'foo/bar'], null);
+ $preview = new \OC\Preview();
+ $preview->setFile('/foo', $info);
+ $this->assertEquals($info, $this->invokePrivate($preview, 'getFileInfo'));
+ }
+
+ public function testIsCached() {
+ $sourceFile = __DIR__ . '/../data/testimage.png';
+ $userId = $this->getUniqueID();
+ $this->createUser($userId, 'pass');
+
+ $storage = new Temporary();
+ $storage->mkdir('files');
+ $this->registerMount($userId, $storage, '/' . $userId);
+
+ \OC_Util::tearDownFS();
+ \OC_Util::setupFS($userId);
+ $preview = new \OC\Preview($userId, 'files');
+ $view = new View('/' . $userId . '/files');
+ $view->file_put_contents('test.png', file_get_contents($sourceFile));
+ $info = $view->getFileInfo('test.png');
+ $preview->setFile('test.png', $info);
+
+ $preview->setMaxX(64);
+ $preview->setMaxY(64);
+
+ $this->assertFalse($preview->isCached($info->getId()));
+
+ $preview->getPreview();
+
+ $this->assertEquals('thumbnails/' . $info->getId() . '/64-64.png', $preview->isCached($info->getId()));
+ }
}
diff --git a/tests/lib/repair/repairinvalidsharestest.php b/tests/lib/repair/repairinvalidsharestest.php
new file mode 100644
index 00000000000..89a5ba470e1
--- /dev/null
+++ b/tests/lib/repair/repairinvalidsharestest.php
@@ -0,0 +1,123 @@
+<?php
+/**
+ * Copyright (c) 2015 Vincent Petry <pvince81@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Repair;
+
+
+use OC\Repair\RepairInvalidShares;
+use OC\Share\Constants;
+use Test\TestCase;
+
+/**
+ * Tests for repairing invalid shares
+ *
+ * @see \OC\Repair\RepairInvalidShares
+ */
+class RepairInvalidSharesTest extends TestCase {
+
+ /** @var \OC\RepairStep */
+ private $repair;
+
+ /** @var \OCP\IDBConnection */
+ private $connection;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $config = $this->getMockBuilder('OCP\IConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $config->expects($this->any())
+ ->method('getSystemValue')
+ ->with('version')
+ ->will($this->returnValue('8.0.0.0'));
+
+ $this->connection = \OC::$server->getDatabaseConnection();
+ $this->deleteAllShares();
+
+ /** @var \OCP\IConfig $config */
+ $this->repair = new RepairInvalidShares($config, $this->connection);
+ }
+
+ protected function tearDown() {
+ $this->deleteAllShares();
+
+ parent::tearDown();
+ }
+
+ protected function deleteAllShares() {
+ $qb = $this->connection->getQueryBuilder();
+ $qb->delete('share')->execute();
+ }
+
+ /**
+ * Test remove expiration date for non-link shares
+ */
+ public function testRemoveExpirationDateForNonLinkShares() {
+ // user share with bogus expiration date
+ $qb = $this->connection->getQueryBuilder();
+ $qb->insert('share')
+ ->values([
+ 'share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_USER),
+ 'share_with' => $qb->expr()->literal('recipientuser1'),
+ 'uid_owner' => $qb->expr()->literal('user1'),
+ 'item_type' => $qb->expr()->literal('folder'),
+ 'item_source' => $qb->expr()->literal(123),
+ 'item_target' => $qb->expr()->literal('/123'),
+ 'file_source' => $qb->expr()->literal(123),
+ 'file_target' => $qb->expr()->literal('/test'),
+ 'permissions' => $qb->expr()->literal(1),
+ 'stime' => $qb->expr()->literal(time()),
+ 'expiration' => $qb->expr()->literal('2015-09-25 00:00:00')
+ ])
+ ->execute();
+
+ // select because lastInsertId does not work with OCI
+ $results = $this->connection->getQueryBuilder()
+ ->select('id')
+ ->from('share')
+ ->execute()
+ ->fetchAll();
+ $bogusShareId = $results[0]['id'];
+
+ // link share with expiration date
+ $qb = $this->connection->getQueryBuilder();
+ $qb->insert('share')
+ ->values([
+ 'share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_LINK),
+ 'uid_owner' => $qb->expr()->literal('user1'),
+ 'item_type' => $qb->expr()->literal('folder'),
+ 'item_source' => $qb->expr()->literal(123),
+ 'item_target' => $qb->expr()->literal('/123'),
+ 'file_source' => $qb->expr()->literal(123),
+ 'file_target' => $qb->expr()->literal('/test'),
+ 'permissions' => $qb->expr()->literal(1),
+ 'stime' => $qb->expr()->literal(time()),
+ 'expiration' => $qb->expr()->literal('2015-09-25 00:00:00'),
+ 'token' => $qb->expr()->literal('abcdefg')
+ ])->execute();
+
+ $this->repair->run();
+
+ $results = $this->connection->getQueryBuilder()
+ ->select('*')
+ ->from('share')
+ ->orderBy('share_type', 'ASC')
+ ->execute()
+ ->fetchAll();
+
+ $this->assertCount(2, $results);
+
+ $userShare = $results[0];
+ $linkShare = $results[1];
+ $this->assertEquals($bogusShareId, $userShare['id'], 'sanity check');
+ $this->assertNull($userShare['expiration'], 'bogus expiration date was removed');
+ $this->assertNotNull($linkShare['expiration'], 'valid link share expiration date still there');
+ }
+}
+
diff --git a/tests/lib/repair/repairmimetypes.php b/tests/lib/repair/repairmimetypes.php
index da36e7de58a..0288a476ede 100644
--- a/tests/lib/repair/repairmimetypes.php
+++ b/tests/lib/repair/repairmimetypes.php
@@ -26,8 +26,17 @@ class RepairMimeTypes extends \Test\TestCase {
$this->savedMimetypeLoader = \OC::$server->getMimeTypeLoader();
$this->mimetypeLoader = \OC::$server->getMimeTypeLoader();
+ $config = $this->getMockBuilder('OCP\IConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $config->expects($this->any())
+ ->method('getSystemValue')
+ ->with('version')
+ ->will($this->returnValue('8.0.0.0'));
+
$this->storage = new \OC\Files\Storage\Temporary([]);
- $this->repair = new \OC\Repair\RepairMimeTypes();
+
+ $this->repair = new \OC\Repair\RepairMimeTypes($config);
}
protected function tearDown() {
@@ -274,6 +283,68 @@ class RepairMimeTypes extends \Test\TestCase {
}
/**
+ * Test renaming the java mime types
+ */
+ public function testRenameJavaMimeType() {
+ $currentMimeTypes = [
+ ['test.java', 'application/octet-stream'],
+ ['test.class', 'application/octet-stream'],
+ ];
+
+ $fixedMimeTypes = [
+ ['test.java', 'text/x-java-source'],
+ ['test.class', 'application/java'],
+ ];
+
+ $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);
+ }
+
+ /**
+ * Test renaming the hpp mime type
+ */
+ public function testRenameHppMimeType() {
+ $currentMimeTypes = [
+ ['test.hpp', 'application/octet-stream'],
+ ];
+
+ $fixedMimeTypes = [
+ ['test.hpp', 'text/x-h'],
+ ];
+
+ $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);
+ }
+
+ /**
+ * Test renaming the rss mime type
+ */
+ public function testRenameRssMimeType() {
+ $currentMimeTypes = [
+ ['test.rss', 'application/octet-stream'],
+ ];
+
+ $fixedMimeTypes = [
+ ['test.rss', 'application/rss+xml'],
+ ];
+
+ $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);
+ }
+
+ /**
+ * Test renaming the hpp mime type
+ */
+ public function testRenameRtfMimeType() {
+ $currentMimeTypes = [
+ ['test.rtf', 'application/octet-stream'],
+ ];
+
+ $fixedMimeTypes = [
+ ['test.rtf', 'text/rtf'],
+ ];
+
+ $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);
+ }
+
+ /**
* Test renaming and splitting old office mime types when
* new ones already exist
*/
@@ -390,6 +461,11 @@ class RepairMimeTypes extends \Test\TestCase {
['test.cnf', 'text/plain'],
['test.yaml', 'application/yaml'],
['test.yml', 'application/yaml'],
+ ['test.java', 'text/x-java-source'],
+ ['test.class', 'application/java'],
+ ['test.hpp', 'text/x-h'],
+ ['test.rss', 'application/rss+xml'],
+ ['test.rtf', 'text/rtf'],
];
$fixedMimeTypes = [
@@ -429,6 +505,11 @@ class RepairMimeTypes extends \Test\TestCase {
['test.cnf', 'text/plain'],
['test.yaml', 'application/yaml'],
['test.yml', 'application/yaml'],
+ ['test.java', 'text/x-java-source'],
+ ['test.class', 'application/java'],
+ ['test.hpp', 'text/x-h'],
+ ['test.rss', 'application/rss+xml'],
+ ['test.rtf', 'text/rtf'],
];
$this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);
diff --git a/tests/lib/util.php b/tests/lib/util.php
index b9b8062653e..eaa3d0795e3 100644
--- a/tests/lib/util.php
+++ b/tests/lib/util.php
@@ -303,7 +303,7 @@ class Test_Util extends \Test\TestCase {
}
$appConfig = \OC::$server->getAppConfig();
- $appConfig->setValue('core', 'shareapi_exclude_groups_list', implode(',', $excludedGroups));
+ $appConfig->setValue('core', 'shareapi_exclude_groups_list', json_encode($excludedGroups));
$appConfig->setValue('core', 'shareapi_exclude_groups', 'yes');
$result = \OCP\Util::isSharingDisabledForUser();
@@ -406,11 +406,13 @@ class Test_Util extends \Test\TestCase {
OC_Config::setValue('version', '7.0.0.0');
\OC::$server->getSession()->set('OC_Version', array(7, 0, 0, 1));
+ self::invokePrivate(new \OCP\Util, 'needUpgradeCache', array(null));
$this->assertTrue(\OCP\Util::needUpgrade());
OC_Config::setValue('version', $oldConfigVersion);
$oldSessionVersion = \OC::$server->getSession()->set('OC_Version', $oldSessionVersion);
+ self::invokePrivate(new \OCP\Util, 'needUpgradeCache', array(null));
$this->assertFalse(\OCP\Util::needUpgrade());
}