diff options
author | Robin Appelman <robin@icewind.nl> | 2021-01-14 19:03:39 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2021-01-26 15:30:46 +0100 |
commit | a44aab11f726dfe9bacb38339e2da59cdeb8f467 (patch) | |
tree | 8506f5848ef6fd19a816a9df3fb3c2c095d3b752 /tests | |
parent | 7a892a310d46e3d99418f2c3cd58c1897679ce9e (diff) | |
download | nextcloud-server-a44aab11f726dfe9bacb38339e2da59cdeb8f467.tar.gz nextcloud-server-a44aab11f726dfe9bacb38339e2da59cdeb8f467.zip |
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.php | 37 |
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'; |