diff options
author | Michael Weimann <mail@michael-weimann.eu> | 2018-08-20 20:46:11 +0200 |
---|---|---|
committer | Michael Weimann <mail@michael-weimann.eu> | 2018-08-20 20:46:23 +0200 |
commit | 2bab916c535173ac723f50fecb33518db3f293d5 (patch) | |
tree | 7496981d6756638837ef4c45e0c2e5691d4c32c2 /tests/Settings/Controller | |
parent | ce1e213760a0ac03e91daf6ebc08f401da27b8bc (diff) | |
parent | 6d749bf0215c4f155d402620544e669c0cce37ec (diff) | |
download | nextcloud-server-2bab916c535173ac723f50fecb33518db3f293d5.tar.gz nextcloud-server-2bab916c535173ac723f50fecb33518db3f293d5.zip |
Adds license to files. Updates the branch.
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Diffstat (limited to 'tests/Settings/Controller')
-rw-r--r-- | tests/Settings/Controller/CheckSetupControllerTest.php | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/Settings/Controller/CheckSetupControllerTest.php b/tests/Settings/Controller/CheckSetupControllerTest.php index a7689eed801..cc1ed6555c3 100644 --- a/tests/Settings/Controller/CheckSetupControllerTest.php +++ b/tests/Settings/Controller/CheckSetupControllerTest.php @@ -21,6 +21,7 @@ namespace Tests\Settings\Controller; +use OC; use OC\DB\Connection; use OC\MemoryInfo; use OC\Settings\Controller\CheckSetupController; @@ -46,6 +47,7 @@ use OC\IntegrityCheck\Checker; /** * Class CheckSetupControllerTest * + * @backupStaticAttributes * @package Tests\Settings\Controller */ class CheckSetupControllerTest extends TestCase { @@ -78,6 +80,13 @@ class CheckSetupControllerTest extends TestCase { /** @var MemoryInfo|MockObject */ private $memoryInfo; + /** + * Holds a list of directories created during tests. + * + * @var array + */ + private $dirsToRemove = []; + public function setUp() { parent::setUp(); @@ -143,9 +152,23 @@ class CheckSetupControllerTest extends TestCase { 'isSqliteUsed', 'isPhpMailerUsed', 'hasOpcacheLoaded', + 'getAppDirsWithDifferentOwner', ])->getMock(); } + /** + * Removes directories created during tests. + * + * @after + * @return void + */ + public function removeTestDirectories() { + foreach ($this->dirsToRemove as $dirToRemove) { + rmdir($dirToRemove); + } + $this->dirsToRemove = []; + } + public function testIsInternetConnectionWorkingDisabledViaConfig() { $this->config->expects($this->once()) ->method('getSystemValue') @@ -436,6 +459,11 @@ class CheckSetupControllerTest extends TestCase { ->method('isMemoryLimitSufficient') ->willReturn(true); + $this->checkSetupController + ->expects($this->once()) + ->method('getAppDirsWithDifferentOwner') + ->willReturn([]); + $expected = new DataResponse( [ 'isGetenvServerWorking' => true, @@ -477,6 +505,7 @@ class CheckSetupControllerTest extends TestCase { 'isPhpMailerUsed' => false, 'mailSettingsDocumentation' => 'https://server/index.php/settings/admin', 'isMemoryLimitSufficient' => true, + 'appDirsWithDifferentOwner' => [], ] ); $this->assertEquals($expected, $this->checkSetupController->check()); @@ -584,6 +613,56 @@ class CheckSetupControllerTest extends TestCase { $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated')); } + /** + * Setups a temp directory and some subdirectories. + * Then calls the 'getAppDirsWithDifferentOwner' method. + * The result is expected to be empty since + * there are no directories with different owners than the current user. + * + * @return void + */ + public function testAppDirectoryOwnersOk() { + $tempDir = tempnam(sys_get_temp_dir(), 'apps') . 'dir'; + mkdir($tempDir); + mkdir($tempDir . DIRECTORY_SEPARATOR . 'app1'); + mkdir($tempDir . DIRECTORY_SEPARATOR . 'app2'); + $this->dirsToRemove[] = $tempDir . DIRECTORY_SEPARATOR . 'app1'; + $this->dirsToRemove[] = $tempDir . DIRECTORY_SEPARATOR . 'app2'; + $this->dirsToRemove[] = $tempDir; + OC::$APPSROOTS = [ + [ + 'path' => $tempDir, + 'url' => '/apps', + 'writable' => true, + ], + ]; + $this->assertSame( + [], + $this->invokePrivate($this->checkSetupController, 'getAppDirsWithDifferentOwner') + ); + } + + /** + * Calls the check for a none existing app root that is marked as not writable. + * It's expected that no error happens since the check shouldn't apply. + * + * @return void + */ + public function testAppDirectoryOwnersNotWritable() { + $tempDir = tempnam(sys_get_temp_dir(), 'apps') . 'dir'; + OC::$APPSROOTS = [ + [ + 'path' => $tempDir, + 'url' => '/apps', + 'writable' => false, + ], + ]; + $this->assertSame( + [], + $this->invokePrivate($this->checkSetupController, 'getAppDirsWithDifferentOwner') + ); + } + public function testIsBuggyNss400() { $this->config->expects($this->any()) ->method('getSystemValue') |