-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2797 from nextcloud/fix-encryption-scanner
- Loading branch information
Showing
2 changed files
with
63 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace OCA\groupfolders\tests\ACL; | ||
|
||
use OC\Files\Storage\Temporary; | ||
use OCA\GroupFolders\ACL\ACLManager; | ||
use OCA\GroupFolders\ACL\ACLStorageWrapper; | ||
use OCP\Constants; | ||
use Test\TestCase; | ||
|
||
/** | ||
* @group DB | ||
*/ | ||
class ACLScannerTest extends TestCase { | ||
private function getAclManager(array $rules): ACLManager { | ||
$manager = $this->getMockBuilder(ACLManager::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$manager->method('getACLPermissionsForPath') | ||
->willReturnCallback(function ($path) use ($rules) { | ||
return $rules[$path] ?? Constants::PERMISSION_ALL; | ||
}); | ||
return $manager; | ||
} | ||
|
||
public function testScanAclStorage() { | ||
$baseStorage = new Temporary([]); | ||
$baseStorage->mkdir('foo'); | ||
$baseStorage->mkdir('foo/bar'); | ||
$baseStorage->mkdir('foo/bar/asd'); | ||
$cache = $baseStorage->getCache(); | ||
$baseStorage->getScanner()->scan(''); | ||
|
||
$cache->update($cache->getId('foo/bar/asd'), ['size' => -1]); | ||
$cache->calculateFolderSize('foo/bar'); | ||
$cache->calculateFolderSize('foo'); | ||
|
||
$this->assertEquals(-1, $cache->get('foo/bar')->getSize()); | ||
|
||
$acls = $this->getAclManager([ | ||
'foo/bar' => 0, | ||
'foo/bar/asd' => 0, | ||
]); | ||
|
||
$aclStorage = new ACLStorageWrapper([ | ||
'storage' => $baseStorage, | ||
'acl_manager' => $acls, | ||
'in_share' => false, | ||
]); | ||
|
||
$scanner = $aclStorage->getScanner(); | ||
$aclCache = $aclStorage->getCache(); | ||
$scanner->scan(''); | ||
|
||
$this->assertEquals(0, $cache->get('foo/bar')->getSize()); | ||
|
||
$this->assertEquals(31, $cache->get('foo/bar')->getPermissions()); | ||
$this->assertEquals(false, $aclCache->get('foo/bar')); | ||
} | ||
} |