]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add test to ensure that symlinked apps_paths are not resolved 19084/head
authorDaniel Kesselberg <mail@danielkesselberg.de>
Wed, 22 Jan 2020 20:14:36 +0000 (21:14 +0100)
committerDaniel Kesselberg <mail@danielkesselberg.de>
Fri, 24 Apr 2020 14:19:14 +0000 (16:19 +0200)
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
tests/lib/App/AppManagerTest.php

index 1a5d6c648a1fa25d679408e1bffc18e47159596b..5b6fedb1cc228b427a2773c1096404c44752f902 100644 (file)
@@ -338,6 +338,35 @@ class AppManagerTest extends TestCase {
                $this->assertEquals(\OC::$SERVERROOT . '/apps/files', $this->manager->getAppPath('files'));
        }
 
+       public function testGetAppPathSymlink() {
+               $fakeAppDirname = sha1(uniqid('test', true));
+               $fakeAppPath = sys_get_temp_dir() . '/' . $fakeAppDirname;
+               $fakeAppLink = \OC::$SERVERROOT . '/' . $fakeAppDirname;
+
+               mkdir($fakeAppPath);
+               if (symlink($fakeAppPath, $fakeAppLink) === false) {
+                       $this->markTestSkipped('Failed to create symlink');
+               }
+
+               // Use the symlink as the app path
+               \OC::$APPSROOTS[] = [
+                       'path' => $fakeAppLink,
+                       'url' => \OC::$WEBROOT . '/' . $fakeAppDirname,
+                       'writable' => false,
+               ];
+
+               $fakeTestAppPath = $fakeAppPath . '/' . 'test-test-app';
+               mkdir($fakeTestAppPath);
+
+               $generatedAppPath = $this->manager->getAppPath('test-test-app');
+
+               rmdir($fakeTestAppPath);
+               unlink($fakeAppLink);
+               rmdir($fakeAppPath);
+
+               $this->assertEquals($fakeAppLink . '/test-test-app', $generatedAppPath);
+       }
+
        public function testGetAppPathFail() {
                $this->expectException(AppPathNotFoundException::class);
                $this->manager->getAppPath('testnotexisting');