diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-07-11 20:53:37 +0200 |
---|---|---|
committer | Andy Scherzinger <info@andy-scherzinger.de> | 2024-08-08 22:08:42 +0200 |
commit | 0563757ea43b853770305f80c763a547525abf66 (patch) | |
tree | c07ae092b92002e7a2f98fcdb55449e6306d092f /tests | |
parent | 8c0bece57aee2aca571650e6c2decad27088a5ae (diff) | |
download | nextcloud-server-0563757ea43b853770305f80c763a547525abf66.tar.gz nextcloud-server-0563757ea43b853770305f80c763a547525abf66.zip |
fix(SetupCheck): Properly check public access to data directory
When checking for public (web) access to the data directory the status is not enough
as you might have a webserver that forwards to e.g. a login page.
So instead check that the content of the file matches.
For this the `.ncdata` file (renamed from `.ocdata`¹) has minimal text content
to allow checking.
¹The file was renamed from the legacy `.ocdata`, there is a repair step to remove the old one.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/UtilCheckServerTest.php | 18 | ||||
-rw-r--r-- | tests/lib/UtilTest.php | 2 |
2 files changed, 10 insertions, 10 deletions
diff --git a/tests/lib/UtilCheckServerTest.php b/tests/lib/UtilCheckServerTest.php index f0cc8a57e6f..23da44b6e84 100644 --- a/tests/lib/UtilCheckServerTest.php +++ b/tests/lib/UtilCheckServerTest.php @@ -39,13 +39,13 @@ class UtilCheckServerTest extends \Test\TestCase { $this->datadir = \OC::$server->getTempManager()->getTemporaryFolder(); - file_put_contents($this->datadir . '/.ocdata', ''); + file_put_contents($this->datadir . '/.ncdata', '# Nextcloud data directory'); \OC::$server->getSession()->set('checkServer_succeeded', false); } protected function tearDown(): void { // clean up - @unlink($this->datadir . '/.ocdata'); + @unlink($this->datadir . '/.ncdata'); parent::tearDown(); } @@ -66,9 +66,9 @@ class UtilCheckServerTest extends \Test\TestCase { */ public function testCheckServerSkipDataDirValidityOnSetup() { // simulate old version that didn't have it - unlink($this->datadir . '/.ocdata'); + unlink($this->datadir . '/.ncdata'); - // even though ".ocdata" is missing, the error isn't + // even though ".ncdata" is missing, the error isn't // triggered to allow setup to run $result = \OC_Util::checkServer($this->getConfig([ 'installed' => false @@ -83,7 +83,7 @@ class UtilCheckServerTest extends \Test\TestCase { */ public function testCheckServerSkipDataDirValidityOnUpgrade() { // simulate old version that didn't have it - unlink($this->datadir . '/.ocdata'); + unlink($this->datadir . '/.ncdata'); $session = \OC::$server->getSession(); $oldCurrentVersion = $session->get('OC_Version'); @@ -91,7 +91,7 @@ class UtilCheckServerTest extends \Test\TestCase { // upgrade condition to simulate needUpgrade() === true $session->set('OC_Version', [6, 0, 0, 2]); - // even though ".ocdata" is missing, the error isn't + // even though ".ncdata" is missing, the error isn't // triggered to allow for upgrade $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true, @@ -105,7 +105,7 @@ class UtilCheckServerTest extends \Test\TestCase { /** * Test that checkDataDirectoryValidity returns no error - * when ".ocdata" is present. + * when ".ncdata" is present. */ public function testCheckDataDirValidity() { $result = \OC_Util::checkDataDirectoryValidity($this->datadir); @@ -114,10 +114,10 @@ class UtilCheckServerTest extends \Test\TestCase { /** * Test that checkDataDirectoryValidity and checkServer - * both return an error when ".ocdata" is missing. + * both return an error when ".ncdata" is missing. */ public function testCheckDataDirValidityWhenFileMissing() { - unlink($this->datadir . '/.ocdata'); + unlink($this->datadir . '/.ncdata'); $result = \OC_Util::checkDataDirectoryValidity($this->datadir); $this->assertEquals(1, count($result)); diff --git a/tests/lib/UtilTest.php b/tests/lib/UtilTest.php index a83f27d5cf7..cef3f4c063d 100644 --- a/tests/lib/UtilTest.php +++ b/tests/lib/UtilTest.php @@ -162,7 +162,7 @@ class UtilTest extends \Test\TestCase { public function testCheckDataDirectoryValidity() { $dataDir = \OC::$server->getTempManager()->getTemporaryFolder(); - touch($dataDir . '/.ocdata'); + touch($dataDir . '/.ncdata'); $errors = \OC_Util::checkDataDirectoryValidity($dataDir); $this->assertEmpty($errors); \OCP\Files::rmdirr($dataDir); |