Adding test case for getPathById including a jailed cache where root is just empty

This commit is contained in:
Thomas Müller 2016-08-05 13:32:26 +02:00 committed by Bjoern Schiessle
parent 0253300e2a
commit 2e0e2064e8
No known key found for this signature in database
GPG Key ID: 2378A753E2BF04F6
2 changed files with 14 additions and 3 deletions

View 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);
}

View 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() {