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
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-02-09 22:15:29 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2018-03-02 23:23:41 +0300
commit9413f97b9234ea94cfa881c5f0640f524ae98257 (patch)
tree6b8d916176520aefa64d11284fc304f439f8cc95 /tests
parent364e7fe1be64ea02dd817d4a458db8d50140b31a (diff)
Hardening of SimpleFile getContent
if file_get_contents fails remove the file. And traverse up the tree checking if the other folders are there. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/SimpleFS/SimpleFileTest.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/lib/Files/SimpleFS/SimpleFileTest.php b/tests/lib/Files/SimpleFS/SimpleFileTest.php
index 4e623eafa22..ab4970804a4 100644
--- a/tests/lib/Files/SimpleFS/SimpleFileTest.php
+++ b/tests/lib/Files/SimpleFS/SimpleFileTest.php
@@ -24,6 +24,9 @@ namespace Test\File\SimpleFS;
use OC\Files\SimpleFS\SimpleFile;
use OCP\Files\File;
+use OCP\Files\Folder;
+use OCP\Files\NotFoundException;
+use OCP\Files\NotPermittedException;
class SimpleFileTest extends \Test\TestCase {
/** @var File|\PHPUnit_Framework_MockObject_MockObject */
@@ -101,4 +104,23 @@ class SimpleFileTest extends \Test\TestCase {
$this->assertEquals('app/awesome', $this->simpleFile->getMimeType());
}
+
+ public function testGetContentInvalidAppData() {
+ $this->file->method('getContent')
+ ->willReturn(false);
+ $this->file->method('stat')->willReturn(false);
+
+ $parent = $this->createMock(Folder::class);
+ $parent->method('stat')->willReturn(false);
+
+ $root = $this->createMock(Folder::class);
+ $root->method('stat')->willReturn([]);
+
+ $this->file->method('getParent')->willReturn($parent);
+ $parent->method('getParent')->willReturn($root);
+
+ $this->expectException(NotFoundException::class);
+
+ $this->simpleFile->getContent();
+ }
}