Adds a test for the app directory permission check.
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
This commit is contained in:
parent
b2e60e365d
commit
0017cbe18a
|
@ -21,6 +21,7 @@
|
|||
|
||||
namespace Tests\Settings\Controller;
|
||||
|
||||
use OC;
|
||||
use OC\DB\Connection;
|
||||
use OC\Settings\Controller\CheckSetupController;
|
||||
use OCP\AppFramework\Http;
|
||||
|
@ -44,6 +45,7 @@ use OC\IntegrityCheck\Checker;
|
|||
/**
|
||||
* Class CheckSetupControllerTest
|
||||
*
|
||||
* @backupStaticAttributes
|
||||
* @package Tests\Settings\Controller
|
||||
*/
|
||||
class CheckSetupControllerTest extends TestCase {
|
||||
|
@ -74,6 +76,13 @@ class CheckSetupControllerTest extends TestCase {
|
|||
/** @var IDateTimeFormatter|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $dateTimeFormatter;
|
||||
|
||||
/**
|
||||
* Holds a list of directories created during tests.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $dirsToRemove = [];
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
|
@ -135,9 +144,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')
|
||||
|
@ -425,6 +448,11 @@ class CheckSetupControllerTest extends TestCase {
|
|||
->method('hasPassedCheck')
|
||||
->willReturn(true);
|
||||
|
||||
$this->checkSetupController
|
||||
->expects($this->once())
|
||||
->method('getAppDirsWithDifferentOwner')
|
||||
->willReturn([]);
|
||||
|
||||
$expected = new DataResponse(
|
||||
[
|
||||
'isGetenvServerWorking' => true,
|
||||
|
@ -465,6 +493,7 @@ class CheckSetupControllerTest extends TestCase {
|
|||
'missingIndexes' => [],
|
||||
'isPhpMailerUsed' => false,
|
||||
'mailSettingsDocumentation' => 'https://server/index.php/settings/admin',
|
||||
'appDirsWithDifferentOwner' => [],
|
||||
]
|
||||
);
|
||||
$this->assertEquals($expected, $this->checkSetupController->check());
|
||||
|
@ -571,6 +600,35 @@ 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')
|
||||
);
|
||||
}
|
||||
|
||||
public function testIsBuggyNss400() {
|
||||
$this->config->expects($this->any())
|
||||
->method('getSystemValue')
|
||||
|
|
Loading…
Reference in New Issue