]> source.dussan.org Git - nextcloud-server.git/commitdiff
Adding test case for getPathById including a jailed cache where root is just empty 746/head
authorThomas Müller <thomas.mueller@tmit.eu>
Fri, 5 Aug 2016 11:32:26 +0000 (13:32 +0200)
committerRobin Appelman <icewind@owncloud.com>
Fri, 5 Aug 2016 12:06:05 +0000 (14:06 +0200)
lib/private/Files/Cache/Wrapper/CacheJail.php
tests/lib/Files/Cache/Wrapper/CacheJailTest.php

index 90226e5614402981318fc32ce67dd59735bd3edf..1196c6b0760131c3bc36ddfc3d925d5e9c747d28 100644 (file)
@@ -59,6 +59,9 @@ class CacheJail extends CacheWrapper {
         * @return null|string the jailed path or null if the path is outside the jail
         */
        protected function getJailedPath($path) {
+               if ($this->root === '') {
+                       return $path;
+               }
                $rootLength = strlen($this->root) + 1;
                if ($path === $this->root) {
                        return '';
@@ -290,7 +293,6 @@ class CacheJail extends CacheWrapper {
         */
        public function getPathById($id) {
                $path = $this->cache->getPathById($id);
-               $path = $this->getSourcePath($path);
                return $this->getJailedPath($path);
        }
 
index 6ef6716f72138d533f826660cc79f9ae33eba160..e3043c50d57688a7c581a8a8f0bf94d1f3a3e90f 100644 (file)
@@ -63,8 +63,17 @@ class CacheJailTest extends CacheTest {
        }
 
        function testGetById() {
-               //not supported
-               $this->assertTrue(true);
+               $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
+               $id = $this->sourceCache->put('foo/bar', $data1);
+
+               // path from jailed foo of foo/bar is bar
+               $path = $this->cache->getPathById($id);
+               $this->assertEquals('bar', $path);
+
+               // path from jailed '' of foo/bar is foo/bar
+               $this->cache = new \OC\Files\Cache\Wrapper\CacheJail($this->sourceCache, '');
+               $path = $this->cache->getPathById($id);
+               $this->assertEquals('foo/bar', $path);
        }
 
        function testGetIncomplete() {