diff options
author | Robin Appelman <robin@icewind.nl> | 2021-01-14 21:03:39 +0300 |
---|---|---|
committer | Daniel Kesselberg <mail@danielkesselberg.de> | 2021-03-16 17:26:59 +0300 |
commit | 564390e303ed3e69477a8ddaedd03adaa0fb1201 (patch) | |
tree | 11802347f0b7dd2cc07a5b813f440d2f6991cce3 /tests | |
parent | f9c9e27e46303c85c2d55fa7d1da09329e819555 (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.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'; |