Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2020-01-22 23:14:36 +0300
committerDaniel Kesselberg <mail@danielkesselberg.de>2020-04-24 17:19:14 +0300
commitd766d09f01314c5db7dc54288884edb6a159321e (patch)
treefaac138379184a016d42e558635bc4013d4a61b8 /tests/lib/App
parent72a16b17792e2a5353cc0ffce8fc24ed4ff1351c (diff)
Add test to ensure that symlinked apps_paths are not resolved
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'tests/lib/App')
-rw-r--r--tests/lib/App/AppManagerTest.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php
index 1a5d6c648a1..5b6fedb1cc2 100644
--- a/tests/lib/App/AppManagerTest.php
+++ b/tests/lib/App/AppManagerTest.php
@@ -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');