summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-09-09 12:32:56 +0200
committerLukas Reschke <lukas@statuscode.ch>2016-09-09 12:33:10 +0200
commit67439951e6751bb09161514da87a0c14b3831cc1 (patch)
tree27c4c2aade1c9e95a44f904dc85a3dcf7067f4c3 /apps/dav/tests
parentf5aafdc89789623e72f9a05ecc2629ed2894668b (diff)
downloadnextcloud-server-67439951e6751bb09161514da87a0c14b3831cc1.tar.gz
nextcloud-server-67439951e6751bb09161514da87a0c14b3831cc1.zip
Filter more mimetypes
There's no need to allow more than those defined mimetypes for images.
Diffstat (limited to 'apps/dav/tests')
-rw-r--r--apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php60
1 files changed, 51 insertions, 9 deletions
diff --git a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php
index 229fa7ec6f2..e878cbd4f59 100644
--- a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php
+++ b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php
@@ -107,9 +107,20 @@ class ImageExportPluginTest extends TestCase {
$this->plugin->expects($this->once())->method('getPhoto')->willReturn($getPhotoResult);
if (!$expected) {
- $this->response->expects($this->once())->method('setHeader');
- $this->response->expects($this->once())->method('setStatus');
- $this->response->expects($this->once())->method('setBody');
+ $this->response
+ ->expects($this->at(0))
+ ->method('setHeader')
+ ->with('Content-Type', $getPhotoResult['Content-Type']);
+ $this->response
+ ->expects($this->at(1))
+ ->method('setHeader')
+ ->with('Content-Disposition', 'attachment');
+ $this->response
+ ->expects($this->once())
+ ->method('setStatus');
+ $this->response
+ ->expects($this->once())
+ ->method('setBody');
}
$result = $this->plugin->httpGet($this->request, $this->response);
@@ -142,12 +153,43 @@ class ImageExportPluginTest extends TestCase {
public function providesPhotoData() {
return [
- 'empty vcard' => [false, ''],
- 'vcard without PHOTO' => [false, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nEND:VCARD\r\n"],
- 'vcard 3 with PHOTO' => [['Content-Type' => 'image/jpeg', 'body' => '12345'], "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO;ENCODING=b;TYPE=JPEG:MTIzNDU=\r\nEND:VCARD\r\n"],
- 'vcard 3 with PHOTO URL' => [false, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO;TYPE=JPEG;VALUE=URI:http://example.com/photo.jpg\r\nEND:VCARD\r\n"],
- 'vcard 4 with PHOTO' => [['Content-Type' => 'image/jpeg', 'body' => '12345'], "BEGIN:VCARD\r\nVERSION:4.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO:data:image/jpeg;base64,MTIzNDU=\r\nEND:VCARD\r\n"],
- 'vcard 4 with PHOTO URL' => [false, "BEGIN:VCARD\r\nVERSION:4.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO;MEDIATYPE=image/jpeg:http://example.org/photo.jpg\r\nEND:VCARD\r\n"],
+ 'empty vcard' => [
+ false,
+ ''
+ ],
+ 'vcard without PHOTO' => [
+ false,
+ "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nEND:VCARD\r\n"
+ ],
+ 'vcard 3 with PHOTO' => [
+ [
+ 'Content-Type' => 'image/jpeg',
+ 'body' => '12345'
+ ],
+ "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO;ENCODING=b;TYPE=JPEG:MTIzNDU=\r\nEND:VCARD\r\n"
+ ],
+ 'vcard 3 with PHOTO URL' => [
+ false,
+ "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO;TYPE=JPEG;VALUE=URI:http://example.com/photo.jpg\r\nEND:VCARD\r\n"
+ ],
+ 'vcard 4 with PHOTO' => [
+ [
+ 'Content-Type' => 'image/jpeg',
+ 'body' => '12345'
+ ],
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO:data:image/jpeg;base64,MTIzNDU=\r\nEND:VCARD\r\n"
+ ],
+ 'vcard 4 with PHOTO URL' => [
+ false,
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO;MEDIATYPE=image/jpeg:http://example.org/photo.jpg\r\nEND:VCARD\r\n"
+ ],
+ 'vcard 4 with PHOTO AND INVALID MIMEtYPE' => [
+ [
+ 'Content-Type' => 'application/octet-stream',
+ 'body' => '12345'
+ ],
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO:data:image/svg;base64,MTIzNDU=\r\nEND:VCARD\r\n"
+ ],
];
}
}