summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-01-19 15:30:27 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2021-03-15 17:51:32 +0000
commiteb56b1d0bd4ce523d65505a6f409b65d92f6c94c (patch)
tree9a362814a96d13eb82811d6708d2bfe0d27d1e28 /tests
parent046638abeb50ccfd07069ac3c4f9c9428c3f23ed (diff)
downloadnextcloud-server-eb56b1d0bd4ce523d65505a6f409b65d92f6c94c.tar.gz
nextcloud-server-eb56b1d0bd4ce523d65505a6f409b65d92f6c94c.zip
fix cachjail searching for root
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Cache/Wrapper/CacheJailTest.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
index 83173efd3b6..de54333312b 100644
--- a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
+++ b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
@@ -37,6 +37,7 @@ class CacheJailTest extends CacheTest {
}
public function testSearchOutsideJail() {
+ $this->storage->getScanner()->scan('');
$file1 = 'foo/foobar';
$file2 = 'folder/foobar';
$data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'];
@@ -49,9 +50,18 @@ class CacheJailTest extends CacheTest {
$result = $this->cache->search('%foobar%');
$this->assertCount(1, $result);
$this->assertEquals('foobar', $result[0]['path']);
+
+ $result = $this->cache->search('%foo%');
+ $this->assertCount(2, $result);
+ usort($result, function ($a, $b) {
+ return $a['path'] <=> $b['path'];
+ });
+ $this->assertEquals('', $result[0]['path']);
+ $this->assertEquals('foobar', $result[1]['path']);
}
public function testSearchMimeOutsideJail() {
+ $this->storage->getScanner()->scan('');
$file1 = 'foo/foobar';
$file2 = 'folder/foobar';
$data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'];
@@ -67,6 +77,7 @@ class CacheJailTest extends CacheTest {
}
public function testSearchQueryOutsideJail() {
+ $this->storage->getScanner()->scan('');
$file1 = 'foo/foobar';
$file2 = 'folder/foobar';
$data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'];
@@ -76,11 +87,15 @@ class CacheJailTest extends CacheTest {
$user = new User('foo', null, $this->createMock(EventDispatcherInterface::class));
$query = new SearchQuery(new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'name', 'foobar'), 10, 0, [], $user);
- $this->assertCount(2, $this->sourceCache->searchQuery($query));
+ $result = $this->cache->searchQuery($query);
- $result = $this->cache->search('%foobar%');
$this->assertCount(1, $result);
$this->assertEquals('foobar', $result[0]['path']);
+
+ $query = new SearchQuery(new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'name', 'foo'), 10, 0, [], $user);
+ $result = $this->cache->searchQuery($query);
+ $this->assertCount(1, $result);
+ $this->assertEquals('', $result[0]['path']);
}
public function testClearKeepEntriesOutsideJail() {