* This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ namespace Test; /** * Tests for server check functions * * @group DB */ class UtilCheckServerTest extends \Test\TestCase { private $datadir; /** * @param array $systemOptions * @return \OC\SystemConfig | \PHPUnit\Framework\MockObject\MockObject */ protected function getConfig($systemOptions) { $systemOptions['datadirectory'] = $this->datadir; $systemOptions['appstoreenabled'] = false; //it's likely that there is no app folder we can write in $config = $this->getMockBuilder('\OC\SystemConfig') ->disableOriginalConstructor() ->getMock(); $config->expects($this->any()) ->method('getValue') ->willReturnCallback(function ($key, $default) use ($systemOptions) { return isset($systemOptions[$key]) ? $systemOptions[$key] : $default; }); return $config; } protected function setUp(): void { parent::setUp(); $this->datadir = \OC::$server->getTempManager()->getTemporaryFolder(); file_put_contents($this->datadir . '/.ocdata', ''); \OC::$server->getSession()->set('checkServer_succeeded', false); } protected function tearDown(): void { // clean up @unlink($this->datadir . '/.ocdata'); parent::tearDown(); } /** * Test that checkServer() returns no errors in the regular case. */ public function testCheckServer() { $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true ])); $this->assertEmpty($result); } /** * Test that checkServer() does not check the data dir validity * when the server is not installed yet (else the setup cannot * be run...) */ public function testCheckServerSkipDataDirValidityOnSetup() { // simulate old version that didn't have it unlink($this->datadir . '/.ocdata'); // even though ".ocdata" is missing, the error isn't // triggered to allow setup to run $result = \OC_Util::checkServer($this->getConfig([ 'installed' => false ])); $this->assertEmpty($result); } /** * Test that checkServer() does not check the data dir validity * when an upgrade is required (else the upgrade cannot be * performed...) */ public function testCheckServerSkipDataDirValidityOnUpgrade() { // simulate old version that didn't have it unlink($this->datadir . '/.ocdata'); $session = \OC::$server->getSession(); $oldCurrentVersion = $session->get('OC_Version'); // upgrade condition to simulate needUpgrade() === true $session->set('OC_Version', [6, 0, 0, 2]); // even though ".ocdata" is missing, the error isn't // triggered to allow for upgrade $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true, 'version' => '6.0.0.1' ])); $this->assertEmpty($result); // restore versions $session->set('OC_Version', $oldCurrentVersion); } /** * Test that checkDataDirectoryValidity returns no error * when ".ocdata" is present. */ public function testCheckDataDirValidity() { $result = \OC_Util::checkDataDirectoryValidity($this->datadir); $this->assertEmpty($result); } /** * Test that checkDataDirectoryValidity and checkServer * both return an error when ".ocdata" is missing. */ public function testCheckDataDirValidityWhenFileMissing() { unlink($this->datadir . '/.ocdata'); $result = \OC_Util::checkDataDirectoryValidity($this->datadir); $this->assertEquals(1, count($result)); $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true, 'version' => implode('.', \OCP\Util::getVersion()) ])); $this->assertCount(1, $result); } /** * Tests that no error is given when the datadir is writable */ public function testDataDirWritable() { $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true, 'version' => implode('.', \OCP\Util::getVersion()) ])); $this->assertEmpty($result); } /** * Tests an error is given when the datadir is not writable */ public function testDataDirNotWritable() { $this->markTestSkipped('TODO: Disable because fails on drone'); chmod($this->datadir, 0300); $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true, 'version' => implode('.', \OCP\Util::getVersion()) ])); $this->assertCount(1, $result); } /** * Tests no error is given when the datadir is not writable during setup */ public function testDataDirNotWritableSetup() { chmod($this->datadir, 0300); $result = \OC_Util::checkServer($this->getConfig([ 'installed' => false, 'version' => implode('.', \OCP\Util::getVersion()) ])); chmod($this->datadir, 0700); //needed for cleanup $this->assertEmpty($result); } } n value='artonge/chore/update_password_confirmation_v5.3.1'>artonge/chore/update_password_confirmation_v5.3.1 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Encryption/Exceptions/EncryptionHeaderToLargeException.php
blob: 00bb0cf4262b145c6f8e4b1398292c4b9e89890a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
/**
 * @copyright Copyright (c) 2016, ownCloud, Inc.
 *
 * @author Clark Tomlinson <fallen013@gmail.com>
 * @author Thomas Müller <thomas.mueller@tmit.eu>
 *
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */


namespace OC\Encryption\Exceptions;

use OCP\Encryption\Exceptions\GenericEncryptionException;

class EncryptionHeaderToLargeException extends GenericEncryptionException {

	public function __construct() {
		parent::__construct('max header size exceeded');
	}

}