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:
authorRobin Appelman <robin@icewind.nl>2021-01-14 21:03:39 +0300
committerDaniel Kesselberg <mail@danielkesselberg.de>2021-03-16 17:22:22 +0300
commit5d08beb3d2e2c25ac765fa54a670bd400a3fac69 (patch)
tree7add7324c417bf9f6b392fafbdaed1ebd9c64b07 /tests
parenta6357ebcbac7c7fb2d92884a353a937d8d37aa0a (diff)
do cachejail search filtering in sql
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Cache/Wrapper/CacheJailTest.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
index f0943ba5a03..83173efd3b6 100644
--- a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
+++ b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
@@ -9,6 +9,11 @@
namespace Test\Files\Cache\Wrapper;
use OC\Files\Cache\Wrapper\CacheJail;
+use OC\Files\Search\SearchComparison;
+use OC\Files\Search\SearchQuery;
+use OC\User\User;
+use OCP\Files\Search\ISearchComparison;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Test\Files\Cache\CacheTest;
/**
@@ -46,6 +51,38 @@ class CacheJailTest extends CacheTest {
$this->assertEquals('foobar', $result[0]['path']);
}
+ public function testSearchMimeOutsideJail() {
+ $file1 = 'foo/foobar';
+ $file2 = 'folder/foobar';
+ $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'];
+
+ $this->sourceCache->put($file1, $data1);
+ $this->sourceCache->put($file2, $data1);
+
+ $this->assertCount(2, $this->sourceCache->searchByMime('foo/folder'));
+
+ $result = $this->cache->search('%foobar%');
+ $this->assertCount(1, $result);
+ $this->assertEquals('foobar', $result[0]['path']);
+ }
+
+ public function testSearchQueryOutsideJail() {
+ $file1 = 'foo/foobar';
+ $file2 = 'folder/foobar';
+ $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'];
+
+ $this->sourceCache->put($file1, $data1);
+ $this->sourceCache->put($file2, $data1);
+
+ $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->search('%foobar%');
+ $this->assertCount(1, $result);
+ $this->assertEquals('foobar', $result[0]['path']);
+ }
+
public function testClearKeepEntriesOutsideJail() {
$file1 = 'foo/foobar';
$file2 = 'foo/foobar/asd';