diff options
author | Kyle Fazzari <kyrofa@ubuntu.com> | 2018-02-20 22:44:37 -0800 |
---|---|---|
committer | Kyle Fazzari <kyrofa@ubuntu.com> | 2018-02-20 22:45:10 -0800 |
commit | a1f18241166f335b89a6cf3d002efd3d825fde19 (patch) | |
tree | a0e2a5bab83f4c87b0e04ef03b4f730a904b7ce4 /apps/theming/tests/Controller/ThemingControllerTest.php | |
parent | 6591a3bc366874ead2de646ae1ca920277c17bff (diff) | |
download | nextcloud-server-a1f18241166f335b89a6cf3d002efd3d825fde19.tar.gz nextcloud-server-a1f18241166f335b89a6cf3d002efd3d825fde19.zip |
theming: handle not being in the serverroot
Currently, the theming app assumes it's in the serverroot. However, with
Nextcloud's flexibility regarding configurable app paths, this is not a
safe assumption to make. If it happens to be an incorrect assumption,
the theming app fails to work.
Instead of relying on the serverroot, just use the path from the
AppManager and utilize relative paths for assets from there.
Fix #8462
Signed-off-by: Kyle Fazzari <kyrofa@ubuntu.com>
Diffstat (limited to 'apps/theming/tests/Controller/ThemingControllerTest.php')
-rw-r--r-- | apps/theming/tests/Controller/ThemingControllerTest.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index 54b842bc4e8..9ab8d7a06e9 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -829,6 +829,40 @@ class ThemingControllerTest extends TestCase { $this->assertEquals($response, $actual); } + public function testGetStylesheetOutsideServerroot() { + $this->themingController = new ThemingController( + 'theming', + $this->request, + $this->config, + $this->themingDefaults, + $this->util, + $this->timeFactory, + $this->l10n, + $this->tempManager, + $this->appData, + $this->scssCacher, + $this->urlGenerator, + $this->appManager + ); + $this->appManager->expects($this->once())->method('getAppPath')->with('theming')->willReturn('/outside/serverroot/theming'); + $file = $this->createMock(ISimpleFile::class); + $file->expects($this->any())->method('getName')->willReturn('theming.css'); + $file->expects($this->any())->method('getContent')->willReturn('compiled'); + $this->scssCacher->expects($this->once())->method('process')->with('/outside/serverroot/theming', 'css/theming.scss', 'theming')->willReturn(true); + $this->scssCacher->expects($this->once())->method('getCachedCSS')->willReturn($file); + + $response = new Http\FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'text/css']); + $response->cacheFor(86400); + $expires = new \DateTime(); + $expires->setTimestamp($this->timeFactory->getTime()); + $expires->add(new \DateInterval('PT24H')); + $response->addHeader('Expires', $expires->format(\DateTime::RFC1123)); + $response->addHeader('Pragma', 'cache'); + + $actual = $this->themingController->getStylesheet(); + $this->assertEquals($response, $actual); + } + public function testGetJavascript() { $this->themingDefaults ->expects($this->at(0)) |