Skip to content

Commit

Permalink
Add test to ensure that symlinked apps_paths are not resolved
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
  • Loading branch information
kesselb committed Apr 24, 2020
1 parent 72a16b1 commit d766d09
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/lib/App/AppManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,35 @@ public function testGetAppPath() {
$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');
Expand Down

0 comments on commit d766d09

Please sign in to comment.