diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-07-20 16:00:33 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2015-07-20 16:00:33 +0200 |
commit | 570dd17d4fc43eea336a077ca5f41b5e8df49001 (patch) | |
tree | a917bc529ae42cc16f5ad5e574b0d837908d6305 /apps/encryption/tests | |
parent | 89d6439445da8e1cf133bc2e1b6db9709ce4af8b (diff) | |
download | nextcloud-server-570dd17d4fc43eea336a077ca5f41b5e8df49001.tar.gz nextcloud-server-570dd17d4fc43eea336a077ca5f41b5e8df49001.zip |
fix mount point detection
Diffstat (limited to 'apps/encryption/tests')
-rw-r--r-- | apps/encryption/tests/lib/MigrationTest.php | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/apps/encryption/tests/lib/MigrationTest.php b/apps/encryption/tests/lib/MigrationTest.php index a83909ac628..6742de574bf 100644 --- a/apps/encryption/tests/lib/MigrationTest.php +++ b/apps/encryption/tests/lib/MigrationTest.php @@ -179,7 +179,6 @@ class MigrationTest extends \Test\TestCase { $m->expects($this->any())->method('getSystemMountPoints') ->willReturn([['mountpoint' => 'folder1'], ['mountpoint' => 'folder2']]); - //$m = new Migration(\OC::$server->getConfig(), new \OC\Files\View(), \OC::$server->getDatabaseConnection(), $this->logger); $m->reorganizeFolderStructure(); // even if it runs twice folder should always move only once $m->reorganizeFolderStructure(); @@ -450,4 +449,80 @@ class MigrationTest extends \Test\TestCase { $this->assertSame(19, count($result)); } + /** + * @dataProvider dataTestGetTargetDir + */ + public function testGetTargetDir($user, $keyPath, $filename, $trash, $systemMounts, $expected) { + + $updater = $this->getMockBuilder('\OC\Files\Cache\Updater') + ->disableOriginalConstructor()->getMock(); + $view = $this->getMockBuilder('\OC\Files\View') + ->disableOriginalConstructor()->getMock(); + $view->expects($this->any())->method('file_exists')->willReturn(true); + $view->expects($this->any())->method('getUpdater')->willReturn($updater); + + + $m = $this->getMockBuilder('OCA\Encryption\Migration') + ->setConstructorArgs( + [ + \OC::$server->getConfig(), + $view, + \OC::$server->getDatabaseConnection(), + $this->logger + ] + )->setMethods(['getSystemMountPoints'])->getMock(); + + $m->expects($this->any())->method('getSystemMountPoints') + ->willReturn($systemMounts); + + $this->assertSame($expected, + $this->invokePrivate($m, 'getTargetDir', [$user, $keyPath, $filename, $trash]) + ); + } + + public function dataTestGetTargetDir() { + return [ + [ + 'user1', + '/files_encryption/keys/foo/bar.txt', + 'user1.shareKey', + false, + [], + 'user1/files_encryption/keys/files/foo/bar.txt/OC_DEFAULT_MODULE/user1.shareKey' + ], + [ + 'user1', + '/files_trashbin/keys/foo/bar.txt', + 'user1.shareKey', + true, + [], + 'user1/files_encryption/keys/files_trashbin/foo/bar.txt/OC_DEFAULT_MODULE/user1.shareKey' + ], + [ + '', + '/files_encryption/keys/foo/bar.txt', + 'user1.shareKey', + false, + [['mountpoint' => 'foo']], + '/files_encryption/keys/files/foo/bar.txt/OC_DEFAULT_MODULE/user1.shareKey' + ], + [ + '', + '/files_encryption/keys/foo/bar.txt', + 'user1.shareKey', + false, + [['mountpoint' => 'foobar']], + false + ], + [ + '', + '/files_encryption/keys/foobar/bar.txt', + 'user1.shareKey', + false, + [['mountpoint' => 'foo']], + false + ] + ]; + } + } |