Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weimann <mail@michael-weimann.eu>2018-09-02 15:17:17 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2018-09-05 21:50:21 +0300
commit38ea5d14b38d86fe09acf0df34857c9eba6e1c6f (patch)
treea598a2f6c5ecfacefcdf0c4fc9ae640925558cd7 /apps/theming/tests
parent0899f2cbc43b05005dc045db001c41e199192f67 (diff)
Disables SVG favicon uploads when imagemagick is missing.
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Diffstat (limited to 'apps/theming/tests')
-rw-r--r--apps/theming/tests/Controller/IconControllerTest.php4
-rw-r--r--apps/theming/tests/Controller/ThemingControllerTest.php55
2 files changed, 57 insertions, 2 deletions
diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php
index b4b45a065b0..e749a1dbd44 100644
--- a/apps/theming/tests/Controller/IconControllerTest.php
+++ b/apps/theming/tests/Controller/IconControllerTest.php
@@ -117,7 +117,7 @@ class IconControllerTest extends TestCase {
}
$file = $this->iconFileMock('filename', 'filecontent');
$this->imageManager->expects($this->once())
- ->method('getImage')
+ ->method('getImage', false)
->with('favicon')
->will($this->throwException(new NotFoundException()));
$this->imageManager->expects($this->any())
@@ -142,7 +142,7 @@ class IconControllerTest extends TestCase {
public function testGetFaviconFail() {
$this->imageManager->expects($this->once())
->method('getImage')
- ->with('favicon')
+ ->with('favicon', false)
->will($this->throwException(new NotFoundException()));
$this->imageManager->expects($this->any())
->method('shouldReplaceIcons')
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php
index a2105264f10..457e9900b5e 100644
--- a/apps/theming/tests/Controller/ThemingControllerTest.php
+++ b/apps/theming/tests/Controller/ThemingControllerTest.php
@@ -246,6 +246,61 @@ class ThemingControllerTest extends TestCase {
$this->assertEquals($expected, $this->themingController->uploadImage());
}
+ /**
+ * Checks that trying to upload an SVG favicon without imagemagick
+ * results in an unsupported media type response.
+ *
+ * @test
+ * @return void
+ */
+ public function testUploadSVGFaviconWithoutImagemagick() {
+ $this->imageManager
+ ->method('shouldReplaceIcons')
+ ->willReturn(false);
+
+ $this->request
+ ->expects($this->at(0))
+ ->method('getParam')
+ ->with('key')
+ ->willReturn('favicon');
+ $this->request
+ ->expects($this->at(1))
+ ->method('getUploadedFile')
+ ->with('image')
+ ->willReturn([
+ 'tmp_name' => __DIR__ . '/../../../../tests/data/testimagelarge.svg',
+ 'type' => 'image/svg',
+ 'name' => 'testimagelarge.svg',
+ 'error' => 0,
+ ]);
+ $this->l10n
+ ->expects($this->any())
+ ->method('t')
+ ->will($this->returnCallback(function($str) {
+ return $str;
+ }));
+
+ $folder = $this->createMock(ISimpleFolder::class);
+ $this->appData
+ ->expects($this->once())
+ ->method('getFolder')
+ ->with('images')
+ ->willReturn($folder);
+
+ $expected = new DataResponse(
+ [
+ 'data' =>
+ [
+ 'message' => 'Unsupported image type',
+ ],
+ 'status' => 'failure'
+ ],
+ Http::STATUS_UNPROCESSABLE_ENTITY
+ );
+
+ $this->assertEquals($expected, $this->themingController->uploadImage());
+ }
+
public function testUpdateLogoInvalidMimeType() {
$this->request
->expects($this->at(0))