Skip to content

Commit d0a5fe0

Browse files
committed
Add test to ensure that symlinked apps_paths are not resolved
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
1 parent b3c5358 commit d0a5fe0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/lib/App/AppManagerTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,36 @@ public function testGetAppPath() {
336336
$this->assertEquals(\OC::$SERVERROOT . '/apps/files', $this->manager->getAppPath('files'));
337337
}
338338

339+
public function testGetAppPathSymlink() {
340+
$fakeAppDirname = sha1(uniqid('test', true));
341+
$fakeAppPath = sys_get_temp_dir() . '/' . $fakeAppDirname;
342+
$fakeAppLink = \OC::$SERVERROOT . '/' . $fakeAppDirname;
343+
344+
mkdir($fakeAppPath);
345+
if (symlink($fakeAppPath, $fakeAppLink) === false) {
346+
$this->markTestSkipped('Failed to create symlink');
347+
}
348+
349+
// Use the symlink as the app path
350+
\OC::$APPSROOTS[] = [
351+
'path' => $fakeAppLink,
352+
'url' => \OC::$WEBROOT . '/' . $fakeAppDirname,
353+
'writable' => false,
354+
];
355+
356+
$fakeTestAppPath = $fakeAppPath . '/' . 'test-test-app';
357+
mkdir($fakeTestAppPath);
358+
359+
$generatedAppPath = $this->manager->getAppPath('test-test-app');
360+
361+
rmdir($fakeTestAppPath);
362+
unlink($fakeAppLink);
363+
rmdir($fakeAppPath);
364+
365+
$this->assertEquals($fakeAppLink . '/test-test-app', $generatedAppPath);
366+
}
367+
368+
339369
public function testGetAppPathFail() {
340370
$this->expectException(AppPathNotFoundException::class);
341371
$this->manager->getAppPath('testnotexisting');

0 commit comments

Comments
 (0)