Quellcode durchsuchen

Add test to ensure that symlinked apps_paths are not resolved

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
tags/v19.0.0beta6
Daniel Kesselberg vor 4 Jahren
Ursprung
Commit
d766d09f01
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden
1 geänderte Dateien mit 29 neuen und 0 gelöschten Zeilen
  1. 29
    0
      tests/lib/App/AppManagerTest.php

+ 29
- 0
tests/lib/App/AppManagerTest.php Datei anzeigen

$this->assertEquals(\OC::$SERVERROOT . '/apps/files', $this->manager->getAppPath('files')); $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() { public function testGetAppPathFail() {
$this->expectException(AppPathNotFoundException::class); $this->expectException(AppPathNotFoundException::class);
$this->manager->getAppPath('testnotexisting'); $this->manager->getAppPath('testnotexisting');

Laden…
Abbrechen
Speichern